/* ============================================================
   SmartCash — sistema de diseño
   Azul noche + verde esmeralda. Poppins para títulos, Inter para
   datos (los números tienen que leerse rápido y sin ambigüedad).

   PRINCIPIO VISUAL: la app se lee en 5 segundos. Un número grande,
   un color que dice si está bien o mal, y una frase en español. Las
   tablas densas existen, pero nunca son lo primero que se ve.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary:        #10B981;
  --primary-dark:   #059669;
  --primary-light:  #34D399;
  --accent:         #38BDF8;
  --violet:         #A78BFA;

  --bg-dark:        #0B1120;
  --bg-card:        #131C2E;
  --bg-sidebar:     #0A0F1C;
  --surface:        #1B2438;
  --surface-2:      #273349;
  --border:         #223049;
  --border-light:   #31405C;

  --text-main:      #F1F5F9;
  --text-muted:     #94A3B8;
  --text-dim:       #64748B;

  --success:        #22C55E;
  --danger:         #EF4444;
  --warning:        #F59E0B;
  --info:           #38BDF8;

  --sidebar-w:      262px;
  --header-h:       60px;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 10px 34px rgba(0,0,0,.45);
  --shadow-sm:      0 3px 12px rgba(0,0,0,.30);
  --transition:     all .22s ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, .font-title { font-family: 'Poppins', sans-serif; font-weight: 600; margin: 0; }
a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--primary); }

.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-ok    { color: var(--success); }
.text-bad   { color: var(--danger); }
.text-warn  { color: var(--warning); }
.text-info  { color: var(--info); }
.text-right { text-align: right; }
.text-center{ text-align: center; }
.nowrap     { white-space: nowrap; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.hide { display: none !important; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(1100px 620px at 15% -5%, #0d2b23 0%, var(--bg-dark) 58%);
  overflow-y: auto;
}

.login-card {
  width: 100%; max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px 26px 24px;
  text-align: center; margin: auto;
}

.login-mark {
  width: 78px; height: 78px; margin: 0 auto 14px;
  border-radius: 20px;
  background: linear-gradient(150deg, #062e26, #0f3b31);
  border: 1px solid rgba(16,185,129,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 26px;
  color: var(--primary-light); letter-spacing: .5px;
  box-shadow: var(--shadow-sm);
}
.login-mark span { display: block; width: 34px; height: 4px; border-radius: 2px; background: var(--primary); margin-top: 4px; }

.login-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.login-card h1 em { font-style: normal; color: var(--primary); }
.login-card > p { color: var(--text-muted); font-size: 13.5px; margin: 0 0 20px; }

.login-note { color: var(--text-dim); font-size: 11.5px; margin-top: 14px; line-height: 1.55; }

.login-promesa {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
  display: grid; gap: 9px; text-align: left;
}
.login-promesa div { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--text-muted); }
.login-promesa span { font-size: 15px; }

.setup-banner {
  background: rgba(245,158,11,.10);
  border: 1px solid rgba(245,158,11,.35);
  color: #FCD9A0;
  border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 12.5px; text-align: left; line-height: 1.6;
  margin-bottom: 14px;
}
.setup-banner code { background: rgba(0,0,0,.35); padding: 1px 5px; border-radius: 3px; font-size: 11.5px; }

.google-btn {
  width: 100%; min-height: 46px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #FFFFFF; color: #202124;
  border: none; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: 14.5px;
  cursor: pointer; transition: var(--transition);
}
.google-btn:hover { background: #F1F3F4; }

.login-progress {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 14px; color: var(--text-muted); font-size: 13px;
}

.spinner {
  width: 18px; height: 18px; flex: none;
  border: 2.4px solid rgba(16,185,129,.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   LAYOUT
   ============================================================ */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 60;
  transition: transform .25s ease;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  background: linear-gradient(150deg, #062e26, #12503f);
  border: 1px solid rgba(16,185,129,.3);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 14px; color: var(--primary-light);
}
.brand-name { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 17px; }
.brand-name span { color: var(--primary); }

.nav-group-label {
  padding: 15px 18px 6px; font-size: 10.5px; letter-spacing: 1.1px;
  text-transform: uppercase; color: var(--text-dim); font-weight: 600;
}
.nav-list { list-style: none; margin: 0; padding: 0 10px 10px; overflow-y: auto; flex: 1; }
.nav-list li { margin-bottom: 2px; }
.nav-sep { padding: 14px 8px 5px; }
.nav-sep span {
  font-size: 10.5px; letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--text-dim); font-weight: 600;
}

.nav-item {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: none; background: none;
  color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 500;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  transition: var(--transition);
}
.nav-item:hover { background: var(--surface); color: var(--text-main); }
.nav-item.active { background: rgba(16,185,129,.13); color: var(--primary-light); font-weight: 600; }
.nav-ico { width: 20px; flex: none; text-align: center; font-size: 14.5px; }

.nav-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border); }
.nav-user img { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--surface-2); object-fit: cover; }
.nav-user-info { min-width: 0; flex: 1; }
.nav-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-user-email { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-signout { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); flex: none; font-size: 15px; }
.nav-signout:hover { color: var(--danger); background: var(--surface); }

.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.62); backdrop-filter: blur(2px); }
.sidebar-overlay.open { display: block; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h); flex: none;
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.topbar-add { flex: none; }

.hamburger { display: none; background: none; border: none; color: var(--text-main); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); font-size: 19px; }
.hamburger:hover { background: var(--surface); }

/* Selector de mes: el eje de toda la app */
.mes-switch {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 22px; padding: 3px 6px;
}
.mes-nav {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 3px 8px; border-radius: 50%;
}
.mes-nav:hover { background: var(--surface-2); color: var(--text-main); }
.mes-label { font-size: 12.5px; font-weight: 600; min-width: 96px; text-align: center; text-transform: capitalize; }

.sync-pill { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-dim); white-space: nowrap; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.sync-dot.syncing { background: var(--warning); animation: pulse 1s infinite; }
.sync-dot.offline { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.content { flex: 1; padding: 22px; max-width: 1500px; width: 100%; }

/* ============================================================
   TARJETAS
   ============================================================ */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-title { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-title .sp { flex: 1; }
.card-sub { color: var(--text-muted); font-size: 12.5px; margin: -8px 0 14px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head h2 { font-size: 19px; font-weight: 700; }
.section-head .text-muted { font-size: 12.5px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }

/* ============================================================
   EL TITULAR — lo primero que se ve al abrir
   ============================================================ */
.hero {
  background: linear-gradient(135deg, #0e2a24 0%, var(--bg-card) 55%);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
}
.hero.mal { background: linear-gradient(135deg, #35141a 0%, var(--bg-card) 55%); border-left-color: var(--danger); }
.hero.ojo { background: linear-gradient(135deg, #33270f 0%, var(--bg-card) 55%); border-left-color: var(--warning); }
.hero-saludo { font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }
.hero-monto { font-family: 'Poppins', sans-serif; font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; }
.hero-monto small { font-size: 13px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
.hero-frase { margin-top: 10px; font-size: 14px; color: var(--text-main); max-width: 720px; }
.hero-extra { margin-top: 14px; display: flex; gap: 18px; flex-wrap: wrap; }
.hero-extra div { font-size: 12px; color: var(--text-muted); }
.hero-extra strong { display: block; font-size: 15px; color: var(--text-main); font-weight: 600; }

/* ============================================================
   KPI
   ============================================================ */
.kpi {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; position: relative; overflow: hidden;
}
.kpi-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; display: flex; align-items: center; gap: 6px; }
.kpi-valor { font-family: 'Poppins', sans-serif; font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px; }
.kpi-pie { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; }
.kpi.ok  .kpi-valor { color: var(--success); }
.kpi.bad .kpi-valor { color: var(--danger); }
.kpi.warn .kpi-valor { color: var(--warning); }
.kpi.info .kpi-valor { color: var(--info); }

/* ============================================================
   INSIGHTS — las frases del CFO
   ============================================================ */
.insight {
  display: flex; gap: 13px; padding: 14px 15px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--text-dim);
  border-radius: var(--radius-sm);
}
.insight + .insight { margin-top: 10px; }
.insight.bien { border-left-color: var(--success); }
.insight.ojo  { border-left-color: var(--warning); }
.insight.mal  { border-left-color: var(--danger); }
.insight.info { border-left-color: var(--info); }
.insight-ico { font-size: 20px; line-height: 1.2; flex: none; }
.insight-cuerpo { min-width: 0; flex: 1; }
.insight-titulo { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.insight-detalle { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.insight-accion { margin-top: 9px; }

/* ============================================================
   BARRAS DE PROGRESO
   ============================================================ */
.barra { height: 9px; background: var(--surface); border-radius: 6px; overflow: hidden; }
.barra > span { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width .4s ease; }
.barra.alta > span { background: var(--warning); }
.barra.critica > span { background: var(--danger); }
.barra-etiqueta { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; gap: 10px; }
.barra-etiqueta strong { font-weight: 600; }

/* Barra segmentada del plan de gasto */
.plan-barra { display: flex; height: 26px; border-radius: 7px; overflow: hidden; background: var(--surface); }
.plan-barra div { display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 600; color: #06121f; min-width: 0; }
.plan-leyenda { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12px; }
.plan-leyenda span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.plan-leyenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.plan-fila { padding: 12px 0; border-bottom: 1px solid var(--border); }
.plan-fila:last-child { border-bottom: none; }
.plan-rango { font-size: 11.5px; color: var(--text-dim); }
.plan-estado { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.plan-estado.dentro { background: rgba(34,197,94,.15); color: var(--success); }
.plan-estado.sobre  { background: rgba(239,68,68,.15); color: var(--danger); }
.plan-estado.bajo   { background: rgba(56,189,248,.15); color: var(--info); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: var(--transition); background: var(--surface); color: var(--text-main);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #052e21; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-outline { background: none; border-color: var(--border-light); color: var(--text-main); }
.btn-outline:hover { background: var(--surface); }
.btn-ghost { background: none; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text-main); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 9px; font-size: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 20px; font-size: 12.5px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border-light); color: var(--text-muted);
  cursor: pointer; transition: var(--transition);
}
.chip:hover { color: var(--text-main); }
.chip.on { background: rgba(16,185,129,.15); border-color: var(--primary); color: var(--primary-light); font-weight: 600; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.ok   { background: rgba(34,197,94,.15); color: var(--success); }
.badge.bad  { background: rgba(239,68,68,.15); color: var(--danger); }
.badge.warn { background: rgba(245,158,11,.15); color: var(--warning); }
.badge.info { background: rgba(56,189,248,.15); color: var(--info); }
.badge.neutro { background: var(--surface-2); color: var(--text-muted); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); color: var(--text-main);
  font-family: 'Inter', sans-serif; font-size: 14px; outline: none;
  transition: var(--transition);
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.input::placeholder { color: var(--text-dim); }
textarea.input { resize: vertical; min-height: 72px; }
select.input option { background: var(--bg-card); }
.input.grande { font-family: 'Poppins', sans-serif; font-size: 26px; font-weight: 700; text-align: center; padding: 14px; }
.hint { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; line-height: 1.5; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch-row .hint { margin-top: 3px; }

/* Selector de tipo del formulario rápido */
.tipo-sel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.tipo-sel button {
  padding: 11px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border-light);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  font-size: 12.5px; font-weight: 600; font-family: 'Inter', sans-serif;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tipo-sel button .ico { font-size: 17px; }
.tipo-sel button.on-gasto      { background: rgba(239,68,68,.15); border-color: var(--danger); color: #FCA5A5; }
.tipo-sel button.on-ingreso    { background: rgba(34,197,94,.15); border-color: var(--success); color: #86EFAC; }
.tipo-sel button.on-transferencia { background: rgba(56,189,248,.15); border-color: var(--info); color: #7DD3FC; }

/* ============================================================
   TABLAS Y LISTAS
   ============================================================ */
.tabla-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tabla th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-dim); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tabla td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tabla tr:last-child td { border-bottom: none; }
table.tabla tbody tr:hover { background: rgba(255,255,255,.02); }
table.tabla td.num, table.tabla th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tabla .acciones { text-align: right; white-space: nowrap; }

/* Lista de movimientos: en móvil es lo que más se mira */
.mov { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.mov:last-child { border-bottom: none; }
.mov-ico {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: var(--surface);
}
.mov-cuerpo { flex: 1; min-width: 0; }
.mov-concepto { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mov-meta { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mov-valor { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14px; white-space: nowrap; flex: none; }
.mov-valor.ingreso { color: var(--success); }
.mov-valor.gasto { color: var(--text-main); }
.mov-valor.transferencia { color: var(--info); }
.mov-acciones { flex: none; display: flex; gap: 2px; opacity: .55; }
.mov:hover .mov-acciones { opacity: 1; }

.dia-sep {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 4px 6px; font-size: 11.5px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .6px; font-weight: 600;
}

.vacio { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.vacio .ico { font-size: 40px; display: block; margin-bottom: 12px; opacity: .7; }
.vacio h3 { font-size: 16px; color: var(--text-muted); margin-bottom: 6px; }
.vacio p { font-size: 13px; max-width: 420px; margin: 0 auto 16px; line-height: 1.6; }

/* Tarjetas de cuenta / meta / deuda */
.tarjeta {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; position: relative;
  transition: var(--transition);
}
.tarjeta:hover { border-color: var(--border-light); }
.tarjeta-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.tarjeta-ico {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--surface);
}
.tarjeta-nombre { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 14.5px; }
.tarjeta-sub { font-size: 11.5px; color: var(--text-dim); }
.tarjeta-monto { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 20px; }

/* ============================================================
   GRÁFICOS
   ============================================================ */
.chart-box { position: relative; height: 260px; }
.chart-box.alto { height: 320px; }
.chart-box.bajo { height: 180px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(3,7,18,.72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  overflow-y: auto;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  width: 100%; max-width: 460px; margin: auto;
  max-height: calc(100vh - 36px); display: flex; flex-direction: column;
}
.modal-wide { max-width: 680px; }
.modal-xl { max-width: 940px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16.5px; font-weight: 600; }
.modal-head > div { flex: 1; min-width: 0; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 25px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }

/* ============================================================
   TOASTS Y BADGE DEL OUTBOX
   ============================================================ */
#toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 900; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--surface-2); color: var(--text-main);
  border: 1px solid var(--border-light); border-left: 3px solid var(--primary);
  padding: 11px 17px; border-radius: var(--radius-sm); font-size: 13.5px;
  box-shadow: var(--shadow); max-width: 90vw; animation: subir .25s ease;
}
.toast.ok  { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
@keyframes subir { from { opacity: 0; transform: translateY(12px); } }

.outbox-badge {
  position: fixed; bottom: 18px; right: 18px; z-index: 850;
  display: none; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border-light);
  padding: 9px 14px; border-radius: 22px; font-size: 12.5px; box-shadow: var(--shadow);
}
.outbox-badge.on { display: flex; }

/* ============================================================
   MOBILE
   ============================================================ */
.mobile-tabbar { display: none; }

@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .content { padding: 15px 13px 88px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-add { display: none; }
  .sync-pill span:not(.sync-dot) { display: none; }
  .mes-label { min-width: 76px; font-size: 12px; }
  .hero-monto { font-size: 28px; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }

  .mobile-tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
    background: var(--bg-card); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabbar button {
    background: none; border: none; color: var(--text-dim); cursor: pointer;
    padding: 8px 2px 9px; font-size: 10.5px; font-family: 'Inter', sans-serif;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
  }
  .mobile-tabbar button .ico { font-size: 17px; }
  .mobile-tabbar button.active { color: var(--primary-light); }
  .mobile-tabbar button.tab-add .ico {
    background: var(--primary); color: #052e21; width: 34px; height: 34px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    margin-top: -12px; box-shadow: 0 4px 12px rgba(16,185,129,.4); font-weight: 700;
  }
  .modal { max-width: 100%; }
  .modal-foot .btn { flex: 1; }
}

/* ============================================================
   DOCUMENTO IMPRIMIBLE (PDF)
   Oculto en pantalla; al imprimir se oculta la app y se muestra esto.
   ============================================================ */
.print-doc { display: none; }

@media print {
  @page { size: A4 portrait; margin: 12mm 10mm; }
  body { background: #fff !important; color: #111 !important; }
  #app, #loginScreen, #toast-host, .outbox-badge, .modal-backdrop, .mobile-tabbar { display: none !important; }
  .print-doc { display: block !important; font-family: 'Inter', sans-serif; color: #111; font-size: 11px; }

  .pd-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #10B981; padding-bottom: 10px; margin-bottom: 16px; }
  .pd-marca { font-family: 'Poppins', sans-serif; font-size: 20px; font-weight: 800; color: #0B1120; }
  .pd-marca span { color: #10B981; }
  .pd-sub { font-size: 11px; color: #555; margin-top: 2px; }
  .pd-meta { text-align: right; font-size: 10px; color: #555; line-height: 1.7; }

  .pd-titulo { font-family: 'Poppins', sans-serif; font-size: 14px; font-weight: 700; margin: 18px 0 8px; color: #0B1120; }
  .pd-kpis { display: flex; gap: 10px; margin-bottom: 14px; }
  .pd-kpi { flex: 1; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 10px; }
  .pd-kpi span { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: #64748b; }
  .pd-kpi strong { font-size: 14px; font-family: 'Poppins', sans-serif; }

  .pd-tabla { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
  .pd-tabla th { background: #0B1120; color: #fff; font-size: 9.5px; text-transform: uppercase; letter-spacing: .4px; padding: 6px 7px; text-align: left; }
  .pd-tabla td { padding: 5px 7px; border-bottom: 1px solid #e2e8f0; font-size: 10.5px; }
  .pd-tabla tr:nth-child(even) td { background: #f8fafc; }
  .pd-tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
  .pd-tabla tfoot td { font-weight: 700; border-top: 1.5px solid #0B1120; background: #fff !important; }

  .pd-insight { border-left: 3px solid #10B981; padding: 6px 10px; margin-bottom: 8px; background: #f8fafc; page-break-inside: avoid; }
  .pd-insight.mal { border-left-color: #EF4444; }
  .pd-insight.ojo { border-left-color: #F59E0B; }
  .pd-insight.info { border-left-color: #38BDF8; }
  .pd-insight b { display: block; font-size: 11px; margin-bottom: 2px; }
  .pd-insight span { font-size: 10px; color: #444; }

  .pd-pie { margin-top: 20px; border-top: 1px solid #e2e8f0; padding-top: 8px; font-size: 9px; color: #94a3b8; text-align: center; }
  .pd-salto { page-break-before: always; }
}
