/* ============================================================
   NOVUS · Sistema de diseño
   Marca: navy institucional + verde-crecimiento. Display serif editorial.
   Tema dual (claro/oscuro). Movimiento contenido, respeta reduce-motion.
   ============================================================ */

:root {
  /* Marca institucional */
  --navy:      #0E2A47;
  --navy-2:    #14395f;
  --blue:      #2E6DB4;
  --blue-lite: #4E97DD;
  --leaf:      #3FA98C;   /* verde-hoja: crecimiento */
  --leaf-2:    #5fc0a5;
  --leaf-soft: #d7efe7;

  /* Neutros con leve sesgo frío (elegidos) */
  --paper:     #F4F7FB;
  --paper-2:   #eaf1f9;
  --card:      #FFFFFF;
  --ink:       #142433;
  --ink-soft:  #4A5D71;
  --ink-faint: #7f93a8;
  --line:      #dce5f0;
  --line-2:    #eef3f9;

  /* Semáforo (independiente del acento) */
  --go:    #34a853;
  --wait:  #f5a623;
  --stop:  #e0553d;

  /* Forma: un solo sistema de radios */
  --r-lg: 20px;
  --r:    14px;
  --r-sm: 10px;
  --r-pill: 999px;

  /* Sombras tintadas a la marca (nunca negro puro) */
  --sh-sm: 0 1px 2px rgba(14,42,71,.05), 0 4px 10px -6px rgba(14,42,71,.15);
  --sh:    0 1px 2px rgba(14,42,71,.05), 0 14px 34px -14px rgba(14,42,71,.22);
  --sh-lg: 0 30px 70px -30px rgba(14,42,71,.45);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:#0b1622; --paper-2:#0e1c2c; --card:#0f2032;
    --ink:#e8eef6; --ink-soft:#a7bace; --ink-faint:#6f869d;
    --line:#21384f; --line-2:#182a3d;
    --navy:#0a1e33; --navy-2:#122c49; --leaf-soft:#123028;
    --sh-sm: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px -6px rgba(0,0,0,.5);
    --sh:    0 1px 2px rgba(0,0,0,.3), 0 16px 36px -16px rgba(0,0,0,.6);
    --sh-lg: 0 30px 80px -30px rgba(0,0,0,.8);
  }
}
:root[data-theme="dark"] {
  --paper:#0b1622; --paper-2:#0e1c2c; --card:#0f2032;
  --ink:#e8eef6; --ink-soft:#a7bace; --ink-faint:#6f869d;
  --line:#21384f; --line-2:#182a3d; --navy:#0a1e33; --navy-2:#122c49; --leaf-soft:#123028;
  --sh-sm:0 1px 2px rgba(0,0,0,.3),0 4px 12px -6px rgba(0,0,0,.5);
  --sh:0 1px 2px rgba(0,0,0,.3),0 16px 36px -16px rgba(0,0,0,.6);
  --sh-lg:0 30px 80px -30px rgba(0,0,0,.8);
}
:root[data-theme="light"] {
  --paper:#F4F7FB; --paper-2:#eaf1f9; --card:#FFFFFF; --ink:#142433;
  --ink-soft:#4A5D71; --ink-faint:#7f93a8; --line:#dce5f0; --line-2:#eef3f9;
  --navy:#0E2A47; --navy-2:#14395f; --leaf-soft:#d7efe7;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
.muted { color: var(--ink-soft); }
.serif { font-family: var(--serif); }

/* Motion tokens */
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .7s cubic-bezier(.16,1,.3,1) both; }
  .rise-2 { animation: rise .7s cubic-bezier(.16,1,.3,1) .08s both; }
  .rise-3 { animation: rise .7s cubic-bezier(.16,1,.3,1) .16s both; }
  @keyframes rise { from { opacity:0; transform: translateY(14px); } to { opacity:1; transform:none; } }
}

/* ============ LOGO (placa de marca) ============ */
.logo-plate {
  display: inline-flex; background: #fff; border-radius: 14px;
  padding: 12px 16px; box-shadow: var(--sh);
}
.logo-plate img { display: block; height: 60px; width: auto; }
.topbar .logo-plate { padding: 5px 10px; border-radius: 9px; box-shadow: var(--sh-sm); }
.topbar .logo-plate img { height: 30px; }
.portal-top .logo-plate { padding: 5px 9px; border-radius: 9px; }
.portal-top .logo-plate img { height: 28px; }
.pt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ============ BOTONES ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: 15px;
  padding: 12px 18px; border-radius: var(--r-pill); border: 1px solid transparent;
  cursor: pointer; transition: transform .12s ease, filter .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  color: #fff;
  background: linear-gradient(145deg, var(--blue), var(--blue-lite));
  box-shadow: 0 10px 24px -12px rgba(46,109,180,.9);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--blue-lite); color: var(--blue); }
.btn-block { width: 100%; }

/* ============ LOGIN (split de lujo) ============ */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.auth-brand {
  position: relative; overflow: hidden;
  color: #eaf2fb;
  background:
    radial-gradient(1100px 460px at 82% -12%, rgba(78,151,221,.34), transparent 60%),
    radial-gradient(820px 460px at -5% 112%, rgba(63,169,140,.26), transparent 55%),
    linear-gradient(155deg, var(--navy), var(--navy-2));
  padding: 48px 52px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-brand .brandline { display: flex; align-items: center; gap: 12px; }
.auth-brand .mark {
  width: 46px; height: 46px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--blue-lite), var(--leaf));
  box-shadow: 0 10px 26px -8px rgba(78,151,221,.7);
}
.auth-brand .mark svg { width: 27px; height: 27px; }
.auth-brand .brandline b { font-size: 19px; letter-spacing: .01em; }
.auth-brand .brandline span { display:block; color: #9dc1e8; font-size: 12.5px; }
.auth-brand h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(30px, 3.4vw, 46px); letter-spacing: -.01em; max-width: 15ch;
}
.auth-brand .lede { margin-top: 16px; max-width: 42ch; color: #c6dcf3; font-size: 17px; }
.auth-trust { display: flex; flex-direction: column; gap: 12px; }
.auth-trust .t {
  display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: #bcd6f2;
}
.auth-trust .t svg { width: 19px; height: 19px; color: var(--leaf-2); flex: none; }

.auth-form-wrap { display: grid; place-items: center; padding: 40px 28px; background: var(--paper); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--blue);
}
.auth-card h2 { font-family: var(--serif); font-weight: 600; font-size: 28px; margin-top: 8px; }
.auth-card .sub { color: var(--ink-soft); margin-top: 8px; font-size: 15px; }
form.form { display: flex; flex-direction: column; gap: 16px; margin-top: 28px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input {
  padding: 13px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-size: 15.5px; transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--ink-faint); }
.field input:focus {
  outline: none; border-color: var(--blue-lite);
  box-shadow: 0 0 0 4px rgba(78,151,221,.16);
}
.form .error { color: var(--stop); font-size: 13.5px; min-height: 1.1rem; text-align: center; margin: 0; }
.auth-foot { margin-top: 22px; font-size: 12.5px; color: var(--ink-faint); text-align: center; }

/* ============ APP SHELL ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 66px; padding: 0 22px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 11px; }
.topbar .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--blue), var(--leaf));
}
.topbar .mark svg { width: 20px; height: 20px; }
.topbar .brand b { font-size: 16px; }
.topbar .brand small { display: block; color: var(--ink-faint); font-size: 11px; letter-spacing: .04em; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.userchip { display: flex; align-items: center; gap: 10px; }
.userchip .av {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #08221a;
  background: linear-gradient(140deg, var(--leaf), var(--blue-lite));
}
.userchip .who b { font-size: 13.5px; display: block; line-height: 1.2; }
.userchip .who small { font-size: 11px; color: var(--ink-faint); }
.iconbtn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); cursor: pointer;
}
.iconbtn:hover { color: var(--blue); border-color: var(--blue-lite); }
.iconbtn svg { width: 18px; height: 18px; }

.shell { max-width: 1120px; margin: 0 auto; padding: 30px 22px 70px; }
.page-head { margin-bottom: 26px; }
.page-head .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--blue); }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(26px, 3.4vw, 36px); margin-top: 8px; }
.page-head p { color: var(--ink-soft); margin-top: 8px; max-width: 60ch; }

/* KPI stats: sin caja pesada, separadas por línea */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 6px 0 30px;
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--card); box-shadow: var(--sh-sm); }
.stat { padding: 20px 22px; border-right: 1px solid var(--line-2); }
.stat:last-child { border-right: 0; }
.stat .k { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.stat .v { font-family: var(--serif); font-size: 34px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; color: var(--ink-faint); font-family: var(--sans); }

/* Bento de módulos */
.bento { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.tile {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 22px; box-shadow: var(--sh-sm); color: inherit;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
  display: flex; flex-direction: column; gap: 12px; min-height: 148px;
}
a.tile:hover { transform: translateY(-3px); box-shadow: var(--sh); border-color: color-mix(in srgb, var(--blue-lite) 50%, var(--line)); }
.tile .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; }
.tile .ic svg { width: 23px; height: 23px; }
.tile h3 { font-size: 16px; }
.tile p { font-size: 13.5px; color: var(--ink-soft); }
.tile .soon { margin-top: auto; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.tile.wide { grid-column: span 2; }
.ic.n1 { background: linear-gradient(145deg, var(--navy), var(--blue)); }
.ic.n2 { background: linear-gradient(145deg, var(--blue), var(--blue-lite)); }
.ic.n3 { background: linear-gradient(145deg, var(--leaf), var(--leaf-2)); }
.ic.n4 { background: linear-gradient(145deg, #6b5bd0, #8f7ce6); }
.ic.n5 { background: linear-gradient(145deg, #d98a3a, #e6b25f); }

/* ============ PORTAL PADRES ============ */
.portal { max-width: 480px; margin: 0 auto; padding: 0 0 90px; }
.portal-top {
  color: #eaf2fb;
  background:
    radial-gradient(520px 240px at 85% -20%, rgba(78,151,221,.32), transparent 60%),
    linear-gradient(155deg, var(--navy), var(--blue));
  padding: 22px 20px 26px; border-radius: 0 0 26px 26px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22);
  padding: 4px 11px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 600;
}
.status-pill .live { width: 7px; height: 7px; border-radius: 50%; background: var(--leaf-2); }
.status-pill.offline .live { background: var(--wait); }
@media (prefers-reduced-motion: no-preference) {
  .status-pill .live { animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(95,192,165,.45);} 50% { box-shadow: 0 0 0 5px rgba(95,192,165,0);} }
}
.portal-top .hello { margin-top: 14px; font-size: 13px; color: #bcd6f2; }
.switcher {
  margin-top: 8px; display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.16);
  border-radius: var(--r); padding: 10px 13px;
}
.switcher .who { display: flex; align-items: center; gap: 11px; }
.switcher .av {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #08221a;
  background: linear-gradient(140deg, var(--leaf), var(--blue-lite));
}
.switcher b { font-size: 15px; }
.switcher small { display: block; font-size: 11.5px; color: #a9c6e5; }

.portal-body { padding: 18px 18px 0; display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--sh-sm);
}
.next-cita { border-left: 4px solid var(--leaf); }
.next-cita .lab { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--leaf); font-weight: 700; }
.next-cita .when { font-family: var(--serif); font-size: 22px; font-weight: 600; margin-top: 4px; }
.next-cita .what { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }

.semaforo .h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.semaforo .h b { font-size: 14px; }
.semaforo .h span { font-size: 11px; color: var(--ink-faint); }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row .n { width: 74px; font-size: 12.5px; color: var(--ink-soft); }
.bar { flex: 1; height: 8px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: var(--r-pill); }
@media (prefers-reduced-motion: no-preference) { .bar i { animation: grow .9s cubic-bezier(.16,1,.3,1) both; } @keyframes grow { from { width: 0 !important; } } }
.bar-row .p { width: 34px; text-align: right; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.p-tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px 10px; text-align: center; box-shadow: var(--sh-sm);
  display: flex; flex-direction: column; align-items: center; gap: 8px; color: inherit;
  transition: transform .14s ease, box-shadow .18s ease;
}
a.p-tile:active { transform: scale(.97); }
.p-tile .pic { width: 26px; height: 26px; color: var(--blue); }
.p-tile.leaf .pic { color: var(--leaf); }
.p-tile span { font-size: 11.5px; font-weight: 600; color: var(--ink); }
.p-tile.note { grid-column: span 3; flex-direction: row; justify-content: flex-start; text-align: left; gap: 12px;
  background: var(--leaf-soft); border-color: transparent; }
.p-tile.note .pic { color: var(--leaf); }
.p-tile.note .txt b { display: block; font-size: 13px; }
.p-tile.note .txt small { font-size: 11.5px; color: var(--ink-soft); }

.empty { text-align: center; color: var(--ink-soft); padding: 22px 10px; }
.empty svg { width: 34px; height: 34px; color: var(--ink-faint); margin-bottom: 8px; }

/* Tab bar inferior */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: flex; justify-content: space-around; padding: 9px 0 12px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--ink-faint); }
.tabbar a.on { color: var(--blue); }
.tabbar svg { width: 21px; height: 21px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 30px 26px; min-height: auto; }
  .auth-brand h1 { font-size: 28px; }
  .auth-brand .lede { display: none; }
  .auth-trust { flex-direction: row; flex-wrap: wrap; gap: 10px 18px; margin-top: 18px; }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .tile.wide { grid-column: span 2; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:last-child { grid-column: span 2; border-top: 1px solid var(--line-2); }
}
@media (max-width: 480px) {
  .bento { grid-template-columns: 1fr; }
  .tile.wide { grid-column: span 1; }
  .userchip .who { display: none; }
}
