/*
 * GoldPhases web. Lenguaje propio: oro lunar sobre azul noche (oscuro) o blanco luna (claro).
 * VOICE: tranquila y precisa, como un buen estado de cuenta.
 * LAYOUT: barra lateral en pantallas anchas, barra inferior en el teléfono.
 */
:root {
  color-scheme: dark;
  --bg: #0B1422; --surface: #111D30; --surface2: #16253C; --line: #22324D; --ink: #EEF1F6; --muted: #93A0B5;
  --gold: #D4AF37; --gold2: #EAC66D; --gold-ink: #1A1305; --navy: #101D2C;
  --income: #3DBE8B; --expense: #EF5D63; --transfer: #8C95F5; --warn: #F2A93B;
  --radius: 16px; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
:root[data-theme=light] {
  color-scheme: light;
  --bg: #F5F5F7; --surface: #FFFFFF; --surface2: #EEF1F6; --line: #DCE1EA; --ink: #101D2C; --muted: #5E6B80;
  --gold: #B08A1E; --gold2: #9D7019; --gold-ink: #FFFFFF;
  --income: #16885C; --expense: #C8333B; --transfer: #4F5BD5; --warn: #B8700C; --shadow: 0 10px 30px rgba(16, 29, 44, .12);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme=dark]) {
    color-scheme: light;
    --bg: #F5F5F7; --surface: #FFFFFF; --surface2: #EEF1F6; --line: #DCE1EA; --ink: #101D2C; --muted: #5E6B80;
    --gold: #B08A1E; --gold2: #9D7019; --gold-ink: #FFFFFF;
    --income: #16885C; --expense: #C8333B; --transfer: #4F5BD5; --warn: #B8700C; --shadow: 0 10px 30px rgba(16, 29, 44, .12);
  }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
body { overflow-x: clip; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold2); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; border-radius: 8px; }

/* Logos según el tema */
.logo-light { display: none; }
:root[data-theme=light] .logo-dark { display: none; } :root[data-theme=light] .logo-light { display: inline; }
@media (prefers-color-scheme: light) { :root:not([data-theme=dark]) .logo-dark { display: none; } :root:not([data-theme=dark]) .logo-light { display: inline; } }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; background: var(--surface); }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.side .brand img { height: 40px; width: auto; }
.side .brand b { font-size: 20px; letter-spacing: -.01em; }
.side .brand b span { color: var(--gold); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; }
.nav a svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.nav a:hover { background: var(--surface2); }
.nav a.on { background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold2); }
.nav a.on svg { color: var(--gold2); }
.side .grow { flex: 1; }
.syncbox { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface2); font-size: 13px; color: var(--muted); border: 0; cursor: pointer; text-align: left; width: 100%; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--income); flex: none; }
.dot.busy { background: var(--gold); animation: pulse 1s infinite alternate; }
.dot.err { background: var(--expense); }
@keyframes pulse { to { opacity: .3; } }

.main { padding: 24px clamp(16px, 3vw, 40px) 120px; max-width: 1180px; width: 100%; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { margin: 0; font-size: clamp(24px, 3vw, 32px); line-height: 1.1; letter-spacing: -.02em; flex: 1; }
.mobilebar, .bottomnav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .mobilebar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 5; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
  .mobilebar img { height: 30px; }
  .mobilebar .grow { flex: 1; }
  .main { padding: 16px 14px 140px; }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 10px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a.on { color: var(--gold2); }
}

/* ---------- Piezas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 17px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.card h2 .sp { flex: 1; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.inc { color: var(--income); } .exp { color: var(--expense); } .tra { color: var(--transfer); }
.row { display: flex; align-items: center; gap: 12px; }
.row .sp { flex: 1; }
.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }

.hero { background: linear-gradient(135deg, #0D1B2E 0%, #13284A 60%, #3A2C0C 130%); color: #F5F5F7; border: 0; position: relative; overflow: hidden; }
.hero .k { color: #C8D0DD; font-size: 14px; font-weight: 600; }
.hero .big { font-size: clamp(30px, 5vw, 46px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0 14px; }
.hero .split { display: flex; gap: 22px; flex-wrap: wrap; font-size: 14px; color: #C8D0DD; }
.hero .split b { display: block; color: #fff; font-size: 17px; }
.hero img { position: absolute; right: -18px; bottom: -22px; width: 150px; opacity: .22; pointer-events: none; }

.stat { display: grid; gap: 2px; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }

.bar { height: 8px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 6px; }
.bar i.over { background: var(--expense); }

/* Listas */
.list { display: grid; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 10px; }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface2); }
.item .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .main2 { flex: 1; display: grid; }
.item .amt { text-align: right; font-weight: 700; }
.void .t, .void .amt { text-decoration: line-through; opacity: .55; }
.ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 15px; color: #fff; }
.day { display: flex; justify-content: space-between; padding: 14px 6px 6px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: capitalize; }
.group-h { display: flex; justify-content: space-between; padding: 14px 6px 4px; font-size: 13px; font-weight: 800; color: var(--gold2); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--surface2); color: var(--muted); vertical-align: middle; }
.pill.CLEARED { background: color-mix(in srgb, var(--transfer) 18%, transparent); color: var(--transfer); }
.pill.RECONCILED { background: color-mix(in srgb, var(--income) 18%, transparent); color: var(--income); }
.pill.VOID { background: color-mix(in srgb, var(--expense) 18%, transparent); color: var(--expense); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 600; min-height: 36px; }
.chip.on { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--gold2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* Botones y campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.gold:hover { filter: brightness(1.06); }
.btn.danger { color: var(--expense); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.fab { position: fixed; right: max(24px, env(safe-area-inset-right)); bottom: 28px; z-index: 7; width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--gold); color: var(--gold-ink);
  box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; }
.fab svg { width: 28px; height: 28px; }
@media (max-width: 860px) { .fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 16px; } }

label.f { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.in { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 16px; color: var(--ink); }
textarea.in { min-height: 80px; resize: vertical; }
.in:focus { border-color: var(--gold); outline: none; }
.amount-in { font-size: 28px; font-weight: 800; text-align: right; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.seg button.on.EXPENSE { color: var(--expense); } .seg button.on.INCOME { color: var(--income); } .seg button.on.TRANSFER { color: var(--transfer); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.form { display: grid; gap: 14px; }
.form .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 520px) { .form .two { grid-template-columns: minmax(0, 1fr); } }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.warn { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); font-size: 14px; font-weight: 600; }
.ok { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--income) 15%, transparent); color: var(--income); font-size: 14px; font-weight: 600; }

/* Filtros */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .in { min-height: 42px; width: auto; flex: 1 1 160px; font-size: 15px; }
.filters .search { flex: 3 1 240px; }

/* Diálogos */
dialog.sheet { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: 22px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow); }
dialog.sheet::backdrop { background: rgba(4, 8, 14, .6); backdrop-filter: blur(2px); }
.sheet .hd { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sheet .hd h3 { margin: 0; font-size: 18px; flex: 1; }
.sheet .bd { padding: 18px; overflow: auto; }
.sheet .ft { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); }
.sheet .ft .sp { flex: 1; }
@media (max-width: 600px) {
  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 94vh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
}
.x { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface2); cursor: pointer; display: grid; place-items: center; }

#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .25s; background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 50; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* Inicio de sesión */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1000px 500px at 80% -10%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 60%), var(--bg); }
.login .box { width: min(420px, 100%); display: grid; gap: 16px; }
.login .box > img { width: 240px; justify-self: center; }
.login h1 { margin: 0; font-size: 22px; text-align: center; }
.login p { margin: 0; text-align: center; }

/* Mi plan */
.timeline .item { cursor: default; }
.kind { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.more { display: flex; justify-content: center; padding: 14px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td, table.t th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.t td.r, table.t th.r { text-align: right; }

/* Tamaño de los íconos dentro de títulos y botones */
svg { flex: none; }
.card h2 svg { width: 20px; height: 20px; color: var(--gold2); }
.btn svg, .x svg { width: 18px; height: 18px; }
.btn.sm svg { width: 16px; height: 16px; }
.mbrand { font-size: 18px; letter-spacing: -.01em; } .mbrand span { color: var(--gold); }
.top h1 { flex: 1 1 220px; }
