/* Clara · sistema de diseño
   Tokens en :root, tema oscuro por preferencia del sistema o elección del usuario, acento configurable. */

:root {
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, monospace;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --gap: 20px;
  --sidebar: 268px;
  --tabbar: 68px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --bg: #f4f6f8;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #e3e8ee;
  --border-strong: #cfd7e0;
  --text: #0f1b2a;
  --text-2: #3d4b5c;
  --muted: #6b7a8c;
  --shadow: 0 1px 2px rgba(15, 27, 42, .05), 0 6px 24px -12px rgba(15, 27, 42, .18);
  --shadow-lg: 0 12px 40px -12px rgba(15, 27, 42, .28);

  --income: #059669;
  --income-soft: #d1fae5;
  --expense: #e11d48;
  --expense-soft: #ffe4e6;
  --transfer: #2563eb;
  --transfer-soft: #dbeafe;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --info-soft: #e0f2fe;

  --c1: #14b8a6; --c2: #6366f1; --c3: #f59e0b; --c4: #ec4899; --c5: #0ea5e9; --c6: #84cc16; --c7: #a855f7; --c8: #64748b;

  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-contrast: #ffffff;
  --brand-dark: #0f3d4c;
  --accent-text: var(--accent-strong);
  color-scheme: light;
}

[data-accent="indigo"] { --accent: #4f46e5; --accent-strong: #4338ca; --accent-soft: #e0e7ff; }
[data-accent="violet"] { --accent: #7c3aed; --accent-strong: #6d28d9; --accent-soft: #ede9fe; }
[data-accent="rose"] { --accent: #e11d48; --accent-strong: #be123c; --accent-soft: #ffe4e6; }
[data-accent="amber"] { --accent: #d97706; --accent-strong: #b45309; --accent-soft: #fef3c7; }
[data-accent="emerald"] { --accent: #059669; --accent-strong: #047857; --accent-soft: #d1fae5; }
[data-accent="sky"] { --accent: #0284c7; --accent-strong: #0369a1; --accent-soft: #e0f2fe; }
[data-accent="slate"] { --accent: #475569; --accent-strong: #334155; --accent-soft: #e2e8f0; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1118; --surface: #121a24; --surface-2: #17212d; --surface-3: #1e2a38; --border: #233243; --border-strong: #2f4257;
    --text: #e7eef6; --text-2: #c2cfdd; --muted: #8696a9;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px -14px rgba(0, 0, 0, .7); --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, .8);
    --income: #34d399; --income-soft: rgba(52, 211, 153, .14); --expense: #fb7185; --expense-soft: rgba(251, 113, 133, .14);
    --transfer: #60a5fa; --transfer-soft: rgba(96, 165, 250, .14); --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .14);
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, .14); --ok: #34d399; --ok-soft: rgba(52, 211, 153, .14);
    --info-soft: rgba(56, 189, 248, .12); --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
    --accent: color-mix(in srgb, var(--accent-strong) 55%, #ffffff 45%);
    --accent-text: var(--accent);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1118; --surface: #121a24; --surface-2: #17212d; --surface-3: #1e2a38; --border: #233243; --border-strong: #2f4257;
  --text: #e7eef6; --text-2: #c2cfdd; --muted: #8696a9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px -14px rgba(0, 0, 0, .7); --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, .8);
  --income: #34d399; --income-soft: rgba(52, 211, 153, .14); --expense: #fb7185; --expense-soft: rgba(251, 113, 133, .14);
  --transfer: #60a5fa; --transfer-soft: rgba(96, 165, 250, .14); --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .14);
  --danger: #f87171; --danger-soft: rgba(248, 113, 113, .14); --ok: #34d399; --ok-soft: rgba(52, 211, 153, .14);
  --info-soft: rgba(56, 189, 248, .12); --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  --accent: color-mix(in srgb, var(--accent-strong) 55%, #ffffff 45%);
  --accent-text: var(--accent);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text);
  background: var(--bg-grad), var(--bg); background-attachment: fixed; min-height: 100vh;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .8em; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.num, .amount, td.num, .kpi-value { font-variant-numeric: tabular-nums; }
.pos { color: var(--income); }
.neg { color: var(--expense); }
.zero { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.icon { flex: none; vertical-align: middle; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }

/* ------------------------------------------------------------ estructura */
.layout { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.layout > div { min-width: 0; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 14px 24px; border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(14px);
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 18px; color: var(--text); font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 10px; box-shadow: var(--shadow); }
.brand small { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.nav-group { margin: 14px 0 4px; }
.nav-title { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding: 0 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 12px; margin: 1px 0; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550; font-size: .93rem; transition: background .18s var(--ease), color .18s;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-link .icon { opacity: .85; }
.sidebar-foot { margin-top: 18px; padding: 14px 12px 0; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .9rem;
  color: var(--accent-contrast); background: linear-gradient(135deg, var(--accent), var(--brand-dark));
}
.main { min-width: 0; padding: 26px clamp(16px, 3vw, 40px) 60px; max-width: 1320px; width: 100%; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabbar { display: none; }
.greeting { font-size: .95rem; color: var(--muted); margin: 0 0 2px; font-weight: 550; }

@media (max-width: 1023px) {
  .layout { display: block; }
  .sidebar { display: none; }
  .main { padding: 14px 16px calc(var(--tabbar) + 34px + env(safe-area-inset-bottom)); }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 30; align-items: center; justify-content: space-between; gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(16px); border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  }
  .topbar .brand { padding: 0; font-size: 1.08rem; }
  .topbar .brand img { width: 30px; height: 30px; border-radius: 9px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.5) blur(18px);
    border-top: 1px solid var(--border);
  }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: .7rem; font-weight: 600; }
  .tab:hover { text-decoration: none; }
  .tab.active { color: var(--accent-text); }
  .tab-add span.fab {
    width: 54px; height: 54px; margin-top: -26px; border-radius: 18px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(140deg, var(--accent), var(--accent-strong)); box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--accent) 70%, transparent);
    transition: transform .2s var(--ease);
  }
  .tab-add:active span.fab { transform: scale(.94); }
  .tab-add small { margin-top: 1px; }
  h1 { font-size: 1.4rem; }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
}

/* ------------------------------------------------------------ componentes */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); min-width: 0; animation: rise .45s var(--ease) both;
}
.card + .card { margin-top: var(--gap); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .link { font-size: .87rem; font-weight: 600; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 18px 20px 0; }
.card.tint { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), var(--surface)); }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack > * + * { margin-top: var(--gap); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .card { padding: 16px; } :root { --gap: 14px; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi {
  position: relative; padding: 16px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: hidden; animation: rise .45s var(--ease) both;
}
.kpi::after { content: ""; position: absolute; inset: auto -30px -40px auto; width: 110px; height: 110px; border-radius: 50%; background: var(--kpi-tint, var(--accent-soft)); opacity: .55; }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.45rem; font-weight: 780; letter-spacing: -.02em; margin-top: 6px; position: relative; z-index: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot { font-size: .82rem; color: var(--muted); margin-top: 4px; position: relative; z-index: 1; }
.kpi.income { --kpi-tint: var(--income-soft); } .kpi.income .kpi-value { color: var(--income); }
.kpi.expense { --kpi-tint: var(--expense-soft); } .kpi.expense .kpi-value { color: var(--expense); }
.kpi.transfer { --kpi-tint: var(--transfer-soft); }
.kpi.hero {
  color: #fff; border: 0; background: linear-gradient(135deg, var(--accent-strong), var(--brand-dark));
  box-shadow: 0 18px 40px -18px color-mix(in srgb, var(--accent-strong) 80%, transparent);
}
.kpi.hero .kpi-label, .kpi.hero .kpi-foot { color: rgba(255, 255, 255, .78); }
.kpi.hero::after { background: rgba(255, 255, 255, .12); opacity: 1; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .kpi { padding: 13px 14px; } .kpi-value { font-size: 1.22rem; } .kpis .kpi.hero { grid-column: 1 / -1; } .kpi.hero .kpi-value { font-size: 1.7rem; } }

.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 650;
  font-size: .92rem; cursor: pointer; transition: transform .12s var(--ease), background .18s, border-color .18s, box-shadow .18s;
  text-decoration: none; white-space: nowrap; min-height: 40px;
}
.btn:hover { text-decoration: none; background: var(--surface-3); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary, a.btn.primary { background: linear-gradient(140deg, var(--accent), var(--accent-strong)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger, a.btn.danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.btn.small { padding: 5px 11px; min-height: 32px; font-size: .84rem; border-radius: 9px; }
.btn.icon-only { padding: 0; width: 38px; min-height: 38px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }
.btn.armed { background: var(--danger); color: #fff; border-color: transparent; }
button.link { background: none; border: 0; color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.6;
}
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.cleared, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.income { background: var(--income-soft); color: var(--income); }
.badge.expense { background: var(--expense-soft); color: var(--expense); }
.badge.transfer { background: var(--transfer-soft); color: var(--transfer); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; margin-bottom: 14px; font-size: .93rem; }
.alert .icon { margin-top: 2px; }
.alert.info { background: var(--info-soft); }
.alert.success { background: var(--ok-soft); color: var(--text); }
.alert.success .icon { color: var(--ok); }
.alert.warning { background: var(--warn-soft); }
.alert.warning .icon { color: var(--warn); }
.alert.error { background: var(--danger-soft); }
.alert.error .icon { color: var(--danger); }
.messages { position: relative; z-index: 5; }
.messages .alert { animation: rise .35s var(--ease) both; box-shadow: var(--shadow); }
.alert .close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .6; padding: 0 2px; }

/* ------------------------------------------------------------ tablas y listas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 750; border-top: 2px solid var(--border-strong); border-bottom: 0; }
th.num, td.num { text-align: right; white-space: nowrap; }
table.compact td, table.compact th { padding: 7px 10px; }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 2; }
tr.is-current td { background: var(--accent-soft); }
tr.muted-row td { color: var(--muted); }
@media (max-width: 720px) {
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: 10px 2px; border-bottom: 1px solid var(--border); }
  table.responsive td { border: 0; padding: 3px 4px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; font-weight: 600; text-align: left; }
  table.responsive td.primary { font-weight: 700; font-size: 1rem; }
  table.responsive td.primary::before { display: none; }
  table.responsive tfoot { display: block; }
}

.list { list-style: none; margin: 0; padding: 0; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 4px 6px; font-size: .78rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.mov {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 12px;
  border-radius: 13px; color: var(--text); transition: background .15s;
}
.mov:hover { background: var(--surface-2); text-decoration: none; }
.mov + .mov { border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
.mov-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; }
.mov-icon.income { background: var(--income-soft); color: var(--income); }
.mov-icon.expense { background: var(--expense-soft); color: var(--expense); }
.mov-icon.transfer { background: var(--transfer-soft); color: var(--transfer); }
.mov-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mov-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.mov-amount { text-align: right; font-weight: 750; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mov-amount small { display: block; font-weight: 600; margin-top: 2px; }
.mov.selectable { grid-template-columns: 28px 42px minmax(0, 1fr) auto; cursor: pointer; }
.mov.selectable:has(input:checked) { background: var(--accent-soft); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------ formularios */
form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 650; font-size: .88rem; color: var(--text-2); }
.field .help { font-size: .8rem; color: var(--muted); }
.field .errors { color: var(--danger); font-size: .84rem; font-weight: 600; margin: 0; padding: 0; list-style: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"],
input[type="month"], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: 16px; min-height: 44px; transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7a8c' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type="checkbox"], input[type="radio"] { width: 19px; height: 19px; accent-color: var(--accent); margin: 0; flex: none; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 550; cursor: pointer; }
.money-input { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.amount-hero input { font-size: 2.1rem; font-weight: 800; text-align: center; letter-spacing: -.02em; min-height: 64px; border-radius: 16px; }
.code-input { font-size: 1.6rem !important; letter-spacing: .32em; text-align: center; font-weight: 750; font-family: var(--mono); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.form-actions .spacer { flex: 1; }
@media (max-width: 720px) {
  .form-actions.sticky { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); padding: 8px; margin: 16px -8px 0; border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 20; flex-wrap: nowrap; gap: 8px; }
  .form-actions.sticky .btn { flex: 1; min-width: 0; padding-left: 10px; padding-right: 10px; }
  .form-actions.sticky .btn.ghost, .form-actions.sticky .spacer, .form-actions.sticky > .muted { display: none; }
  .form-actions .btn.primary { flex: 1.3; }
}
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-3); }
.segmented label { display: flex; justify-content: center; align-items: center; gap: 7px; padding: 9px 8px; border-radius: 11px; cursor: pointer; font-weight: 650; font-size: .9rem; color: var(--text-2); transition: background .18s, color .18s, box-shadow .18s; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented label.income:has(input:checked) { color: var(--income); }
.segmented label.expense:has(input:checked) { color: var(--expense); }
.segmented label.transfer:has(input:checked) { color: var(--transfer); }
.radio-list { display: flex; gap: 14px; flex-wrap: wrap; }
.radio-list label { display: flex; gap: 8px; align-items: center; font-weight: 550; cursor: pointer; }
details.more { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 4px 14px; }
details.more[open] { padding-bottom: 14px; }
details.more summary { cursor: pointer; font-weight: 650; padding: 8px 0; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: "▾"; margin-left: auto; transition: transform .2s; }
details.more[open] summary::after { transform: rotate(180deg); }
.suggestion { display: none; font-size: .82rem; color: var(--accent-text); font-weight: 600; }
.suggestion.show { display: flex; gap: 6px; align-items: center; animation: rise .25s var(--ease); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .84rem; font-weight: 600; cursor: pointer; color: var(--text-2); }
.chip.active, .chip:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); text-decoration: none; }

/* ------------------------------------------------------------ filtros y navegación de periodo */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 40px; border-radius: 13px; }
.filters { margin-bottom: 16px; }
.filters summary { list-style: none; }
.filters summary::-webkit-details-marker { display: none; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; padding: 16px; margin-top: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.filter-grid .actions { display: flex; gap: 8px; align-items: end; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.period-nav { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.period-nav strong { min-width: 130px; text-align: center; font-weight: 700; text-transform: capitalize; }
.period-nav .btn { min-height: 34px; width: 34px; padding: 0; border: 0; }
.year-select select { width: auto; min-height: 38px; padding-top: 6px; padding-bottom: 6px; font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; font-weight: 650; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.summary-bar { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: .9rem; margin-bottom: 14px; }
.summary-bar strong { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ progreso, gráficos */
.progress { display: block; width: 100%; height: 8px; overflow: visible; }
.progress .track { fill: var(--surface-3); }
.progress .fill { fill: var(--accent); transform-box: fill-box; transform-origin: left; animation: grow-x .8s var(--ease) both; }
.progress.warn .fill { fill: var(--warn); }
.progress.over .fill, .progress.danger .fill { fill: var(--expense); }
.progress.ok .fill { fill: var(--income); }
.cat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cat-row:last-child { border-bottom: 0; }
.cat-row .name { font-weight: 650; display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cat-row .bar { grid-column: 1 / -1; }
.cat-row .sub { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1.2; }
.chart .baseline.danger { stroke: var(--expense); stroke-dasharray: 4 4; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { transform-box: fill-box; transform-origin: bottom; animation: grow-y .7s var(--ease) both; transition: opacity .15s; cursor: pointer; }
.chart .bar:hover { opacity: .78; }
.chart .c-income { fill: var(--income); }
.chart .c-expense { fill: var(--expense); }
.chart .c-prev { fill: var(--border-strong); }
.chart .c-accent { fill: var(--accent); }
.chart .stroke { fill: none; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 2400; stroke-dashoffset: 2400; animation: draw 1.4s var(--ease) forwards; }
.chart .stroke.line-a { stroke: var(--accent); }
.chart .stroke.line-b { stroke: var(--transfer); }
.chart .area { opacity: .14; animation: fade .9s ease both; }
.chart .area.line-a { fill: var(--accent); }
.chart .area.line-b { fill: var(--transfer); }
.chart .dot { stroke: var(--surface); stroke-width: 1.5; cursor: pointer; }
.chart .dot.line-a { fill: var(--accent); }
.chart .dot.line-b { fill: var(--transfer); }
.chart .dot:hover { r: 5; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .84rem; color: var(--text-2); margin-top: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-income { background: var(--income); } .legend-expense { background: var(--expense); } .legend-prev { background: var(--border-strong); }
.legend-accent { background: var(--accent); } .legend-transfer { background: var(--transfer); }
.donut-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; }
@media (max-width: 520px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.donut { display: block; }
.donut-track { stroke: var(--surface-3); }
.donut .seg { transition: stroke-width .2s; cursor: pointer; animation: fade .8s ease both; }
.donut .seg:hover { stroke-width: 32; }
.donut-total { fill: var(--text); font-size: 20px; font-weight: 800; font-family: var(--font); }
.donut-sub { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.c1 { stroke: var(--c1); background: var(--c1); } .c2 { stroke: var(--c2); background: var(--c2); } .c3 { stroke: var(--c3); background: var(--c3); }
.c4 { stroke: var(--c4); background: var(--c4); } .c5 { stroke: var(--c5); background: var(--c5); } .c6 { stroke: var(--c6); background: var(--c6); }
.c7 { stroke: var(--c7); background: var(--c7); } .c8 { stroke: var(--c8); background: var(--c8); }
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; width: 100%; }
.legend-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: .9rem; }
.legend-list li span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tip { position: fixed; z-index: 100; pointer-events: none; padding: 7px 11px; border-radius: 10px; background: var(--text); color: var(--surface); font-size: .82rem; font-weight: 650; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; white-space: nowrap; }
.chart-tip.show { opacity: 1; transform: none; }

/* ------------------------------------------------------------ piezas específicas */
.account-card { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--border); color: var(--text); }
.account-card:last-child { border-bottom: 0; }
.account-card:hover { text-decoration: none; background: var(--surface-2); border-radius: 12px; }
.account-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.account-icon.investment { background: color-mix(in srgb, var(--c2) 18%, transparent); color: var(--c2); }
.account-icon.credit, .account-icon.debt { background: var(--expense-soft); color: var(--expense); }
.account-icon.cash { background: color-mix(in srgb, var(--c3) 18%, transparent); color: var(--c3); }
.setup { display: grid; gap: 8px; counter-reset: step; }
.setup a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; }
.setup a:hover { text-decoration: none; border-color: var(--accent); }
.setup .tick { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); flex: none; }
.setup .done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.setup .done { color: var(--muted); text-decoration: line-through; }
.alert-list { display: grid; gap: 8px; }
.alert-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-size: .92rem; }
.alert-item:hover { text-decoration: none; background: var(--surface-3); }
.alert-item .icon { color: var(--warn); }
.alert-item.ok .icon { color: var(--ok); }
.alert-item strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.more-grid a { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 650; box-shadow: var(--shadow); }
.more-grid a:hover { text-decoration: none; border-color: var(--accent); }
.more-grid .icon-wrap { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .icon-wrap { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty h3 { color: var(--text); }
.stat-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .93rem; }
.stat-line:last-child { border-bottom: 0; }
.stat-line strong { font-variant-numeric: tabular-nums; }
.pill-state { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); }
.goal { padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); display: grid; gap: 10px; box-shadow: var(--shadow); }
.goal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.goal-figures { display: flex; justify-content: space-between; font-size: .88rem; color: var(--muted); }
.goal-figures strong { color: var(--text); font-size: 1.08rem; }
.qr { width: 220px; height: 220px; padding: 10px; background: #fff; border-radius: 16px; margin: 0 auto; box-shadow: var(--shadow); }
.qr svg { width: 100%; height: 100%; }
.secret { font-family: var(--mono); font-size: 1.02rem; letter-spacing: .08em; text-align: center; padding: 10px; border-radius: 12px; background: var(--surface-3); word-break: break-all; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font-family: var(--mono); font-size: 1.05rem; font-weight: 700; }
.codes span { padding: 9px; text-align: center; border-radius: 10px; background: var(--surface-3); user-select: all; }
.steps-list { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps-list li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.steps-list li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; font-size: .85rem; }
.matrix input { min-width: 92px; text-align: right; padding: 7px 9px; min-height: 36px; font-size: .9rem; font-variant-numeric: tabular-nums; }
.matrix td, .matrix th { padding: 5px 6px; }
.matrix .cat { font-weight: 650; white-space: nowrap; }
.matrix td.current, .matrix th.current { background: var(--accent-soft); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.kbd { font-family: var(--mono); font-size: .8rem; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); }

/* ------------------------------------------------------------ acceso */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 10% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%), radial-gradient(800px 600px at 100% 100%, color-mix(in srgb, var(--brand-dark) 35%, transparent), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 30px 26px; box-shadow: var(--shadow-lg); animation: rise .5s var(--ease) both; }
.auth-card.wide { max-width: 560px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.auth-brand img { width: 60px; height: 60px; border-radius: 18px; box-shadow: var(--shadow-lg); }
.auth-brand h1 { margin: 0; font-size: 1.5rem; }
.auth-brand p { margin: 0; color: var(--muted); }
.auth-foot { margin-top: 18px; text-align: center; font-size: .82rem; color: var(--muted); display: flex; justify-content: center; gap: 6px; align-items: center; }

/* ------------------------------------------------------------ preferencias */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--text); }
.sw-teal { background: #0d9488; } .sw-indigo { background: #4f46e5; } .sw-violet { background: #7c3aed; } .sw-rose { background: #e11d48; }
.sw-amber { background: #d97706; } .sw-emerald { background: #059669; } .sw-sky { background: #0284c7; } .sw-slate { background: #475569; }

/* densidad compacta */
[data-density="compact"] { --gap: 14px; }
[data-density="compact"] .card { padding: 14px; }
[data-density="compact"] td { padding: 6px 10px; }
[data-density="compact"] .mov { padding: 7px 10px; }
[data-density="compact"] .kpi { padding: 12px 14px; }

/* importes ocultos */
.hide-amounts .amount, .hide-amounts .kpi-value, .hide-amounts .mov-amount, .hide-amounts td.num, .hide-amounts .donut-total, .hide-amounts .chart .axis { filter: blur(7px); transition: filter .2s; }
.hide-amounts .amount:hover, .hide-amounts .kpi-value:hover { filter: none; }

/* ------------------------------------------------------------ animaciones */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.grid > .card:nth-child(2), .kpis > .kpi:nth-child(2) { animation-delay: .04s; }
.grid > .card:nth-child(3), .kpis > .kpi:nth-child(3) { animation-delay: .08s; }
.grid > .card:nth-child(4), .kpis > .kpi:nth-child(4) { animation-delay: .12s; }
.kpis > .kpi:nth-child(5) { animation-delay: .16s; }
.kpis > .kpi:nth-child(6) { animation-delay: .2s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .chart .stroke { stroke-dashoffset: 0; } }

@media print {
  .sidebar, .topbar, .tabbar, .page-actions, .no-print, .messages { display: none !important; }
  .layout { display: block; } .main { padding: 0; } .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* utilidades */
.row-actions.start { justify-content: flex-start; }
.minw0 { min-width: 0; }
.mt { margin-top: var(--gap); }
.mt-s { margin-top: 10px; }
.mb-0 { margin-bottom: 0; }
.gap-s { gap: 8px; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.w-auto { width: auto; }
.card-pad { padding: 0 20px 18px; }
@media (max-width: 720px) { .card-pad { padding: 10px; } }
@media (max-width: 1100px) { .grid-main.dash > .stack:last-child { order: -1; } }

@media (max-width: 720px) { .segmented label { flex-direction: column; gap: 2px; font-size: .8rem; padding: 8px 4px; } }
.show-sm { display: none; }
@media (max-width: 720px) { .hide-sm { display: none; } .show-sm { display: inline; } }
/* En rejillas el espacio lo da el gap, no el margen entre tarjetas. */
.grid > .card + .card, .grid > .goal + .goal { margin-top: 0; }
a.goal, a.card { color: var(--text); transition: border-color .18s, transform .18s var(--ease); }
a.goal:hover, a.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
@media (max-width: 720px) {
  .more-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .more-grid a { padding: 12px 8px; gap: 8px; align-items: center; text-align: center; font-size: .82rem; line-height: 1.25; border-radius: 14px; }
  .more-grid .icon-wrap { width: 38px; height: 38px; }
  h2.mt { margin-top: 18px; }
}

.install-hint { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: .9rem; }
.install-hint .icon { color: var(--accent-text); }
.install-hint .close { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; }
.install-hint.hidden { display: none; }
