:root {
  --bg: #0c0d10;
  --surface: #14161b;
  --surface-2: #1b1e25;
  --line: #262a33;
  --text: #ecebe6;
  --muted: #8d929c;
  --accent: #ffb238;
  --accent-ink: #1a1203;
  --accent-soft: rgba(255, 178, 56, .12);
  --ok: #57d68d;
  --bad: #ff6b5b;
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f4ef; --surface: #ffffff; --surface-2: #f0ede6; --line: #e2ddd2; --text: #1b1a17; --muted: #6f6b62;
    --accent: #d98a00; --accent-ink: #ffffff; --accent-soft: rgba(217, 138, 0, .12); --ok: #1f9d55; --bad: #d23f2f;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* marca: un anillo ámbar con núcleo */
.mark { width: 22px; height: 22px; border-radius: 50%; display: inline-block; flex: none;
  background: radial-gradient(circle, var(--accent) 0 22%, transparent 24% 46%, var(--accent) 48% 62%, transparent 64%); }
.mark.big { width: 64px; height: 64px; filter: drop-shadow(0 0 18px rgba(255, 178, 56, .35)); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(340px, 100%); display: grid; gap: 14px; justify-items: center; }
.login-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.02em; }
.login-card input, .login-card button { width: 100%; }

/* ---------- layout ---------- */
.app { height: 100dvh; display: grid; grid-template-rows: 1fr var(--nav-h); }
.main { min-height: 0; grid-row: 1; }
.view { height: 100%; display: flex; flex-direction: column; min-height: 0; max-width: 820px; margin: 0 auto; }
.nav {
  grid-row: 2; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom);
}
.brand { display: none; }
.tab { display: grid; justify-items: center; align-content: center; gap: 2px; border: 0; background: none; color: var(--muted); font-size: 11px; }
.tab[aria-current="page"] { color: var(--accent); }
@media (min-width: 860px) {
  .app { grid-template-columns: 210px 1fr; grid-template-rows: 1fr; }
  .main { grid-row: 1; grid-column: 2; }
  .nav { grid-row: 1; grid-column: 1; grid-template-columns: 1fr; align-content: start; gap: 4px; border-top: 0;
    border-right: 1px solid var(--line); padding: 20px 12px; }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; padding: 0 10px 18px; }
  .tab { display: flex; gap: 12px; justify-content: start; padding: 10px; border-radius: 10px; font-size: 14px; }
  .tab:hover { background: var(--surface); color: var(--text); }
  .tab[aria-current="page"] { background: var(--accent-soft); }
}

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px;
  padding-top: max(14px, env(safe-area-inset-top)); }
.bar h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.scroll { flex: 1; overflow-y: auto; padding: 4px 16px 24px; }

/* ---------- botones / campos ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 14px; font-weight: 550; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; color: var(--muted); display: grid; place-items: center; padding: 6px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: var(--surface); }
.icon-btn:disabled { opacity: .3; pointer-events: none; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.err { color: var(--bad); min-height: 1.5em; margin: 0; font-size: 14px; }
.status { font-size: 13px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

/* ---------- chat ---------- */
.msgs { flex: 1; overflow-y: auto; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 18px; }
.empty { margin: auto 0; display: grid; justify-items: center; gap: 22px; padding: 24px 0; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-size: 14px; color: var(--text); }
.chip:hover { border-color: var(--accent); }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; max-width: 85%; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 9px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.msg.bot { display: grid; grid-template-columns: 22px 1fr; gap: 12px; }
.msg.bot .mark { margin-top: 2px; }
.msg.bot .body > :first-child { margin-top: 0; }
.msg.bot .body > :last-child { margin-bottom: 0; }
.msg.bot.error .body { color: var(--bad); }
.body p, .body ul, .body ol { margin: 0 0 10px; }
.body ul, .body ol { padding-left: 20px; }
.body h1, .body h2, .body h3 { font-size: 16px; margin: 14px 0 6px; }
.body code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.body pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }
.body pre code { background: none; padding: 0; }
.scroll-x { overflow-x: auto; margin: 0 0 10px; }
.body table { border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.body th, .body td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; white-space: nowrap; }
.body th { color: var(--muted); font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.aviso { border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; }
.aviso .t { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.aviso svg { width: 15px; height: 15px; }
.typing { display: flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .3; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .7; } }

.composer { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px 12px; padding: 6px 6px 6px 14px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 22px; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.composer textarea { border: 0; background: none; padding: 8px 0; resize: none; max-height: 160px; line-height: 1.45; }
.send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.send:disabled { opacity: .4; }
.send svg { width: 20px; height: 20px; stroke-width: 2.2; }

/* ---------- gastos ---------- */
.month { display: flex; align-items: center; gap: 2px; font-size: 14px; }
.month span { min-width: 120px; text-align: center; }
.totals { display: flex; justify-content: space-between; align-items: end; gap: 16px; padding: 8px 0 18px; }
.totals div { display: grid; }
.totals div:last-child { text-align: right; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.totals strong { font-size: 18px; font-weight: 600; }
.totals .big-num { font-size: 34px; letter-spacing: -.02em; }
.cats { display: grid; gap: 10px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.cat { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; font-size: 14px; text-transform: capitalize; }
.cat .track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cat .fill { height: 100%; background: var(--accent); border-radius: 99px; }
.list { display: grid; align-content: start; }
.day { font-size: 12px; color: var(--muted); padding: 18px 0 6px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.item .who { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .amt { font-weight: 600; text-align: right; }
.item .amt.in { color: var(--ok); }
.item .sub { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); grid-column: 1 / -1; }
.item select { width: auto; padding: 2px 6px; font-size: 12.5px; border-radius: 7px; text-transform: capitalize; background: var(--surface); }
.item .raw { font-size: 12.5px; color: var(--muted); grid-column: 1 / -1; }
.item .del { margin-left: auto; padding: 2px; }
.item .del svg { width: 17px; height: 17px; }
.none { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- tareas ---------- */
.task { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; display: grid; gap: 6px; }
.task.off { opacity: .55; }
.task .top { display: flex; align-items: center; gap: 8px; }
.task .top strong { flex: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.task .info { font-size: 13px; color: var(--muted); }
.task .last { font-size: 14px; white-space: pre-wrap; }
.task .error { font-size: 13px; color: var(--bad); }

/* ---------- ajustes ---------- */
.settings { display: grid; gap: 14px; align-content: start; }
.card { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; }
.card h3 { margin: 0; font-size: 15px; }
.stack { display: grid; gap: 12px; }
.accounts { display: grid; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.prov { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; margin-bottom: 10px; background: var(--surface-2); }
.prov input { background: var(--surface); }
.prov .head { display: flex; align-items: center; gap: 8px; }
.prov .head strong { flex: 1; }
.prov .order { font-size: 12px; color: var(--muted); width: 18px; text-align: center; }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 10; max-width: calc(100% - 32px); }
