:root {
  --black: #0a0a0a;
  --black-soft: #111111;
  --black-elevated: #161616;
  --gold: #c5a021;
  --gold-light: #e8c547;
  --white: #ffffff;
  --gray: #b0b0b0;
  --gray-dark: #666666;
  --danger: #e05757;
  --ok: #3d9b6a;
  --font: "Montserrat", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shell-max: 420px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--black);
  color: var(--white);
  line-height: 1.5;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

a { color: inherit; text-decoration: none; }

.app {
  min-height: 100dvh;
  min-height: 100svh;
}

.app[data-role="dador"] {
  --shell-max: 720px;
}

.screen {
  min-height: 100dvh;
  min-height: 100svh;
}

.screen[hidden] { display: none !important; }

/* ===== Auth screens ===== */
.screen-auth {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    calc(28px + var(--safe-top))
    24px
    calc(32px + var(--safe-bottom));
  overflow-x: hidden;
  overflow-y: auto;
}

.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10, 10, 10, 0.2) 0%, rgba(10, 10, 10, 0.88) 48%, #0a0a0a 100%),
    radial-gradient(100% 70% at 50% -15%, #2a2410 0%, transparent 55%),
    linear-gradient(145deg, #121212 0%, #0a0a0a 50%, #1a1608 100%);
}

.auth-shell {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: 4px;
  animation: riseIn 0.55s var(--ease) both;
}

.auth-shell-form {
  padding-bottom: 8px;
}

.auth-shell-wide {
  max-width: min(var(--shell-max), 100%);
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  margin-bottom: 28px;
}

.brand-compact {
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  text-align: center;
}

.brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
}

.brand-mark.sm {
  width: 40px;
  height: 40px;
  margin-bottom: 0;
}

.brand-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
}

.brand-ruta { color: var(--gold); font-size: 1.3rem; }
.brand-federal { color: var(--white); font-size: 1.3rem; }
.brand-compact .brand-ruta,
.brand-compact .brand-federal { font-size: 1rem; }

.brand-chevron {
  width: 22px;
  height: 14px;
}

.brand-tag {
  margin-top: 8px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gray);
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  text-align: center;
}

.auth-sub {
  color: var(--gray);
  font-size: 0.92rem;
  margin-bottom: 22px;
  text-align: center;
}

.role-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
}

.back-link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  color: var(--gray);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 14px;
  padding: 6px 0;
  -webkit-tap-highlight-color: transparent;
}

.role-grid {
  display: grid;
  gap: 12px;
}

.role-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 2px;
  align-items: center;
  text-align: left;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.role-card:active { transform: scale(0.985); }

.role-card:hover,
.role-card:focus-visible {
  border-color: rgba(197, 160, 33, 0.55);
  background: rgba(197, 160, 33, 0.06);
  outline: none;
}

.role-icon {
  grid-row: 1 / span 2;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--gold);
  background: rgba(197, 160, 33, 0.1);
  border-radius: 12px;
}

.role-icon svg { width: 24px; height: 24px; }

.role-label {
  font-size: 1rem;
  font-weight: 700;
}

.role-desc {
  font-size: 0.82rem;
  color: var(--gray);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray);
}

.field input,
.field select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  background: var(--black-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23b0b0b0' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.field input::placeholder { color: #555; }

.field input:focus,
.field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 160, 33, 0.18);
}

.field-password { position: relative; }
.field-password input { padding-right: 48px; }

.toggle-pass {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--gray);
}

.toggle-pass svg { width: 20px; height: 20px; }

.form-msg {
  font-size: 0.88rem;
  line-height: 1.4;
}

.form-error { color: var(--danger); }
.form-ok { color: var(--ok); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.btn:active { transform: scale(0.98); }

.btn-gold {
  background: var(--gold);
  color: var(--black);
  width: 100%;
}

.btn-gold:hover { background: var(--gold-light); }
.btn:disabled { opacity: 0.65; cursor: wait; }

.btn.is-loading .btn-text { opacity: 0; }
.btn.is-loading .btn-spinner { opacity: 1; }

.btn-spinner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(10, 10, 10, 0.25);
  border-top-color: var(--black);
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.7s linear infinite;
}

.btn-spinner.dark {
  position: static;
  opacity: 1;
  border-color: rgba(197, 160, 33, 0.25);
  border-top-color: var(--gold);
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--gray);
}

.link-btn {
  color: var(--gold);
  font-weight: 700;
  padding: 4px;
}

.activate-state {
  text-align: center;
  padding: 24px 0;
}

.activate-state .btn { margin-top: 12px; }

/* ===== Home ===== */
.screen-home {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  background:
    radial-gradient(90% 50% at 50% -5%, rgba(197, 160, 33, 0.12), transparent 60%),
    var(--black);
  animation: fadeHome 0.4s var(--ease) both;
}

@keyframes fadeHome {
  from { opacity: 0; }
  to { opacity: 1; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
}

.topbar-brand img { width: 32px; height: 32px; }

.btn-text-only {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 8px;
}

.home-main {
  flex: 1;
  padding: 28px 20px 24px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.home-greeting {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.home-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.home-sub {
  color: var(--gray);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

.home-placeholder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pulse-line,
.pulse-block {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(197, 160, 33, 0.1) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  background-size: 200% 100%;
  border-radius: 10px;
  animation: shimmer 2.2s ease-in-out infinite;
}

.pulse-line { height: 14px; width: 100%; }
.pulse-line.short { width: 62%; }
.pulse-block { height: 120px; width: 100%; margin-top: 4px; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 8px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 20;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--gray-dark);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  min-height: var(--tabbar-h);
}

.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--gold); }
.tab:disabled { opacity: 0.45; cursor: default; }

/* ===== Responsive (dador / desktop) ===== */
@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-span-2,
  .field-cuit {
    grid-column: 1 / -1;
  }

  .role-grid {
    grid-template-columns: 1fr 1fr;
  }

  .screen-auth {
    padding: 48px 32px;
  }
}

@media (min-width: 900px) {
  .app[data-role="dador"] .auth-shell-wide {
    max-width: 760px;
  }

  .app[data-role="dador"] .auth-title {
    font-size: 1.7rem;
  }

  .app[data-role="dador"] .screen-home .tabbar {
    /* En escritorio el tabbar sigue útil pero más estrecho centrado visualmente */
    max-width: 560px;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
  }
}
