/* Cognitiva Finanzas · línea gráfica «Pulso» */
:root {
  --bg: #FFFFFF;
  --surface: #F4F6F9;
  --surface-2: #FFFFFF;
  --line: #E6E9EF;
  --text: #0B0E14;
  --text-2: #4B5463;
  --ink: #0B0E14;
  --on-ink: #F3F5F8;
  --cyan: #22A6CB;
  --cyan-text: #0F6E8C;
  --magenta: #ED1456;
  --red-text: #C8104B;
  --red-soft: #FCE3EA;
  --amber: #F5A524;
  --amber-text: #7A4A00;
  --amber-soft: #FDEBD0;
  --green: #18A058;
  --green-text: #13703F;
  --green-soft: #E3F1E9;
  --track: #E6E9EF;
  --shadow: 0 1px 3px rgba(11, 14, 20, .08), 0 8px 24px rgba(11, 14, 20, .06);
  --nav-bg: #0B0E14;
  --nav-icon: #A5AEBC;
  --radius: 22px;
  --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0A0D12;
  --surface: #141922;
  --surface-2: #1A202A;
  --line: #242B36;
  --text: #F3F5F8;
  --text-2: #A5AEBC;
  --ink: #F3F5F8;
  --on-ink: #0A0D12;
  --cyan: #3CC3E8;
  --cyan-text: #3CC3E8;
  --magenta: #FF5C8A;
  --red-text: #FF7AA0;
  --red-soft: #3A1622;
  --amber: #FFC24D;
  --amber-text: #FFC24D;
  --amber-soft: #3A2E12;
  --green: #3DD68C;
  --green-text: #3DD68C;
  --green-soft: #12301F;
  --track: #242B36;
  --shadow: none;
  --nav-bg: #1C222C;
  --nav-icon: #A5AEBC;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cyan-text); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.app { max-width: 560px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 20px calc(120px + env(safe-area-inset-bottom)); }
.view { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Encabezado */
.top { display: flex; align-items: center; gap: 10px; }
.top .titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.top h1 { font-size: 24px; font-weight: 800; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); flex: none; text-decoration: none; }
.avatar { width: 44px; height: 44px; border-radius: 14px; background: var(--cyan); color: #0B0E14; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; text-decoration: none; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Controles */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 4px; border-radius: 14px; background: var(--surface); }
.seg button { height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 3px rgba(11,14,20,.12); font-weight: 700; }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: #242B36; box-shadow: none; }
.period { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.period strong { font-family: var(--font-display); font-size: 15px; }
.btn { height: 48px; padding: 0 20px; border-radius: 16px; border: 0; background: var(--ink); color: var(--on-ink); font-family: var(--font-display); font-weight: 700; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); }
.btn.cyan { background: var(--cyan); color: #0B0E14; }
.btn.danger { background: var(--red-soft); color: var(--red-text); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--cyan-text); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.rojo { background: var(--red-soft); color: var(--red-text); }
.chip.amarillo { background: var(--amber-soft); color: var(--amber-text); }
.chip.verde { background: var(--green-soft); color: var(--green-text); }
.chip.sin_datos, .chip.neutral { background: var(--surface); color: var(--text-2); }
.chip.cyan { background: color-mix(in srgb, var(--cyan) 18%, transparent); color: var(--cyan-text); }

/* Tarjetas */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.ink { background: var(--ink); color: var(--on-ink); }
.card.ink .muted { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }
.card.outline { background: transparent; border: 1px solid var(--line); }
.card h3 { font-size: 16px; font-weight: 800; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hero { display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; }
.hero .label { font-size: 13px; color: var(--text-2); }
.amount-xl { font-family: var(--font-display); font-weight: 800; font-size: 48px; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.amount-l { font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.flow { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; font-weight: 600; }
.up { color: var(--cyan-text); }
.down { color: var(--text-2); }
.neg { color: var(--red-text); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
:root[data-theme="dark"] .kpi { background: #1A202A; }
.kpi strong { font-family: var(--font-display); font-size: 18px; }
.kpi span { font-size: 12px; color: var(--text-2); }

/* Barras de categoría */
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-row .row { font-size: 14px; }
.bar-row .name { font-weight: 600; flex: 1; min-width: 0; }
.bar-row .val { font-weight: 700; white-space: nowrap; }
.track { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; position: relative; }
.track > i { display: block; height: 100%; border-radius: 999px; }
.dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }

/* Lista de movimientos */
.tx-day { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--text-2); text-transform: uppercase; margin-top: 8px; }
.tx { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; border-bottom: 1px solid var(--line); }
.tx .ic { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.tx .t1 { font-weight: 600; font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .t2 { font-size: 12px; color: var(--text-2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Navegación flotante */
.tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); width: min(520px, calc(100% - 32px)); height: 64px; border-radius: 22px; background: var(--nav-bg); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; z-index: 20; box-shadow: 0 8px 30px rgba(11,14,20,.25); }
:root[data-theme="dark"] .tabbar { border: 1px solid #2A313C; }
.tabbar a, .tabbar label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--nav-icon); text-decoration: none; font-size: 10px; font-weight: 600; height: 100%; cursor: pointer; }
.tabbar a[aria-current="page"] { color: #FFFFFF; }
.tabbar .scan { width: 52px; height: 52px; border-radius: 18px; background: var(--cyan); color: #0B0E14; display: flex; align-items: center; justify-content: center; }
.fab { position: fixed; right: max(20px, calc(50% - 260px)); bottom: calc(96px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--ink); color: var(--on-ink); display: flex; align-items: center; justify-content: center; z-index: 19; cursor: pointer; box-shadow: var(--shadow); }

/* Hoja inferior (formularios) */
.sheet-bg { position: fixed; inset: 0; background: rgba(5, 7, 10, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { width: min(560px, 100%); max-height: 92dvh; overflow: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input { height: 48px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 14px; font-size: 16px; width: 100%; }
textarea.input { height: 80px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--cyan); outline: none; }
.input.big { height: 64px; font-family: var(--font-display); font-size: 30px; font-weight: 800; }
.input.loading { background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--cyan) 18%, transparent), transparent); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.cats { display: flex; flex-wrap: wrap; gap: 8px; }
.cats button { min-height: 40px; padding: 6px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-align: left; }
.cats button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--on-ink); }

/* Apariencia */
.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.theme-opt { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px; border: 2px solid var(--line); cursor: pointer; background: var(--bg); }
.theme-opt:has(input:checked) { border-color: var(--ink); }
.theme-opt .prev { height: 56px; border-radius: 10px; overflow: hidden; display: grid; }
.theme-opt span { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }

/* Escáner */
.scan-hero { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.scan-big { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 220px; border-radius: 24px; background: var(--ink); color: var(--on-ink); cursor: pointer; font-family: var(--font-display); font-weight: 800; font-size: 20px; text-align: center; padding: 24px; }
.scan-big .circle { width: 76px; height: 76px; border-radius: 26px; background: var(--cyan); color: #0B0E14; display: flex; align-items: center; justify-content: center; }
.receipt-img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 18px; background: var(--surface); }
.status { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.spinner { width: 18px; height: 18px; border-radius: 999px; border: 2.5px solid var(--track); border-top-color: var(--cyan); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Gráficos */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font-body); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.donut-wrap { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; align-items: center; }
.donut-list { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.donut-list .row span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; height: 18px; border-radius: 8px; overflow: hidden; gap: 2px; }
.stack i { display: block; height: 100%; }
.heat { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.heat div { aspect-ratio: 1; border-radius: 7px; font-size: 11px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.heat .wd { aspect-ratio: auto; font-size: 11px; color: var(--text-2); }
.tabs { display: flex; gap: 6px; overflow-x: auto; }
.tabs button { height: 38px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--surface); color: var(--text-2); font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--on-ink); }
.rec { display: flex; gap: 12px; align-items: flex-start; }
.rec .num { width: 32px; height: 32px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 800; font-family: var(--font-display); }
.rec p { margin: 4px 0 0; font-size: 14px; line-height: 1.45; color: var(--text-2); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; color: var(--text-2); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.table td.r, .table th.r { text-align: right; }
.scroll-x { overflow-x: auto; }
ul.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.45; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--on-ink); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); }
.empty { text-align: center; padding: 28px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.skeleton { height: 120px; border-radius: var(--radius); background: var(--surface); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* Ingreso */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 24px; max-width: 440px; margin: 0 auto; padding: 32px 24px; }
.login .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-2); }
.login h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
.login .features { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.login .features li { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.login .features li span { width: 36px; height: 36px; border-radius: 12px; background: var(--surface); display: flex; align-items: center; justify-content: center; flex: none; }
.gbtn { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--line); }

@media (max-width: 380px) {
  .amount-xl { font-size: 40px; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
