/* Rindea · diseño B (panel oscuro) */
:root {
  --bg: #121413;
  --bg-elev: #161817;
  --surface: #1d1f1e;
  --surface-2: #242725;
  --border: #2c2f2d;
  --border-input: #5d625f;
  --text: #f1efea;
  --text-muted: #b0aba2;
  --text-faint: #8f8a82;
  --accent: #6fd39b;
  --accent-soft: #24302a;
  --on-accent: #0f2418;
  --danger: #ff8a80; --danger-soft: #3a1d1b;
  --warning: #f0b54a; --warning-soft: #3a2e14;
  --success: #6fd39b; --success-soft: #1f3327;
  --info: #9d97ff; --info-soft: #25233f;
  --radius: 16px; --radius-lg: 20px;
  --font: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'Space Grotesk', Inter, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.pos { color: var(--success); }
.neg { color: var(--text); }
.warn { color: var(--warning); }
.danger { color: var(--danger); }

/* ---------- estructura ---------- */
.app { min-height: 100dvh; display: flex; }
.main { flex: 1; min-width: 0; padding: calc(16px + var(--safe-t)) 20px calc(110px + var(--safe-b)); max-width: 640px; margin: 0 auto; width: 100%; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 8px 8px calc(8px + var(--safe-b)); background: rgba(22,24,23,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
.tab { min-height: 48px; border: 0; background: transparent; color: var(--text-muted); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; font-weight: 600; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.brand { display: none; }
.fab { position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 21; width: 58px; height: 58px; border-radius: 999px; border: 0; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 28px rgba(0,0,0,.45); }
.fab svg { width: 26px; height: 26px; }

@media (min-width: 900px) {
  .tabbar { position: sticky; top: 0; align-self: flex-start; height: 100dvh; width: 248px; display: flex; flex-direction: column; justify-content: flex-start; gap: 4px; padding: 24px 14px; border-top: 0; border-right: 1px solid var(--border); background: var(--bg-elev); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; padding: 0 10px 18px; }
  .brand img { width: 30px; height: 30px; border-radius: 8px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; font-size: 15px; min-height: 46px; }
  .tab svg { width: 20px; height: 20px; }
  .main { padding: 32px 40px 60px; max-width: 760px; }
  .fab { right: 32px; bottom: 32px; }
}

/* ---------- cabeceras y secciones ---------- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.top .grow { flex: 1; min-width: 0; }
.hello { margin: 0; font-size: 14px; color: var(--text-muted); }
h1.title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 650; }
.iconbtn { position: relative; width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn .dot { position: absolute; top: 8px; right: 9px; min-width: 9px; height: 9px; border-radius: 999px; background: var(--accent); }
.iconbtn.ghost { border-color: transparent; background: transparent; }
.syncline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-faint); margin: -6px 0 14px; }
.syncline .led { width: 7px; height: 7px; border-radius: 999px; background: var(--text-faint); }
.syncline .led.ok { background: var(--success); }
.syncline .led.busy { background: var(--warning); }
.syncline .led.err { background: var(--danger); }
.section { margin-top: 22px; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.section-h h2 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px; padding: 8px 4px; min-height: 36px; }
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; }

/* ---------- saldo ---------- */
.balance-label { margin: 0; font-size: 13px; color: var(--text-muted); }
.balance { margin: 2px 0; font-family: var(--font-num); font-size: 44px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; overflow-wrap: anywhere; }
.balance-sub { margin: 0; font-size: 14px; }
.accounts-row { display: flex; gap: 8px; overflow-x: auto; margin: 14px -20px 0; padding: 0 20px 2px; scrollbar-width: none; }
.accounts-row::-webkit-scrollbar { display: none; }
.acc-chip { flex-shrink: 0; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 14px 8px 10px; font-size: 14px; min-height: 40px; color: var(--text); }
.acc-chip .sw { width: 10px; height: 10px; border-radius: 999px; }
.acc-chip b { font-weight: 600; }
.acc-chip.add { color: var(--accent); border-style: dashed; }

/* ---------- donut ---------- */
.donut-card { display: flex; gap: 18px; align-items: center; }
.donut-card svg { flex-shrink: 0; }
.legend { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.legend button { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 0; min-height: 30px; text-align: left; font-size: 14px; color: var(--text); width: 100%; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend .nm { flex: 1; min-width: 0; color: #d9d5ce; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-weight: 600; }
.empty { color: var(--text-muted); font-size: 14px; padding: 6px 0; margin: 0; }

/* ---------- avisos ---------- */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert { background: var(--surface); border-radius: var(--radius); padding: 12px 6px 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.alert .ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.alert .ico svg { width: 18px; height: 18px; }
.alert.warning .ico { background: var(--warning-soft); color: var(--warning); }
.alert.danger .ico { background: var(--danger-soft); color: var(--danger); }
.alert.success .ico { background: var(--success-soft); color: var(--success); }
.alert .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding-top: 1px; }
.alert .txt b { font-size: 15px; font-weight: 600; }
.alert .txt span { font-size: 13px; color: var(--text-muted); }
.alert .iconbtn { width: 36px; height: 36px; border: 0; background: transparent; color: var(--text-faint); }
.alert .iconbtn svg { width: 16px; height: 16px; }

/* ---------- próximos cargos ---------- */
.upcoming { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.up { background: var(--surface); border-radius: 14px; padding: 12px; min-width: 0; }
.up p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up .d { font-size: 12px; color: var(--text-muted); }
.up .n { font-size: 15px; font-weight: 600; margin-top: 2px; white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
.up .a { font-size: 14px; }

/* ---------- movimientos ---------- */
.tx-group { margin-top: 18px; }
.tx-group-h { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text-muted); padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.tx { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 2px; border: 0; border-bottom: 1px solid #1f2220; background: none; text-align: left; color: var(--text); min-height: 60px; }
.tx .av { width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.tx .bd { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx .bd b { font-weight: 550; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .bd span { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .am { font-weight: 600; font-size: 15.5px; white-space: nowrap; }
.tx .tag { font-size: 11px; font-weight: 600; color: var(--text-faint); border: 1px solid var(--border); border-radius: 6px; padding: 0 5px; margin-left: 6px; }

.monthnav { display: flex; align-items: center; gap: 4px; }
.monthnav h1 { flex: 1; text-align: center; margin: 0; font-size: 20px; font-weight: 650; }
.stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stat { background: var(--surface); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.stat p { margin: 0; }
.stat .l { font-size: 12px; color: var(--text-muted); }
.stat .v { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.searchrow { display: flex; gap: 8px; margin-top: 14px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; min-height: 44px; }
.search svg { width: 18px; height: 18px; color: var(--text-faint); flex-shrink: 0; }
.search input { flex: 1; border: 0; outline: none; background: transparent; min-width: 0; font-size: 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 10px -20px 0; padding: 0 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip .sw { width: 8px; height: 8px; border-radius: 999px; }

/* ---------- presupuestos ---------- */
.budget { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-bottom: 1px solid #1f2220; width: 100%; border-left: 0; border-right: 0; border-top: 0; background: none; text-align: left; color: var(--text); }
.budget .row { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.budget .row .nm { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.budget .row .sw { width: 10px; height: 10px; border-radius: 3px; }
.bar { height: 8px; border-radius: 999px; background: #2c2f2d; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; }
.cmp { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #1f2220; font-size: 15px; }
.cmp .nm { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.cmp .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.cmp .delta { font-size: 13px; min-width: 64px; text-align: right; }
.chart-legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- ajustes ---------- */
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 54px; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; color: var(--text); font-size: 15px; }
.list > .item:last-child { border-bottom: 0; }
.item .sw { width: 12px; height: 12px; border-radius: 999px; flex-shrink: 0; }
.item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item .grow span { font-size: 13px; color: var(--text-muted); }
.item svg { width: 18px; height: 18px; color: var(--text-faint); flex-shrink: 0; }
.item.accent { color: var(--accent); font-weight: 600; }
.item.accent svg { color: var(--accent); }
.note { font-size: 13px; color: var(--text-muted); margin: 8px 2px 0; }
.code { font-family: ui-monospace, 'Cascadia Mono', Menlo, monospace; font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; overflow-wrap: anywhere; user-select: all; }

/* ---------- formularios y hojas ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--bg-elev); border-radius: 22px 22px 0 0; padding: 10px 20px calc(20px + var(--safe-b)); border-top: 1px solid var(--border); animation: rise .2s cubic-bezier(.2,.8,.2,1); }
@media (min-width: 900px) { .scrim { align-items: center; } .sheet { border-radius: 22px; border: 1px solid var(--border); } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.grabber { width: 40px; height: 5px; border-radius: 999px; background: var(--border-input); margin: 0 auto 10px; opacity: .6; }
.sheet-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheet-h h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 650; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .lbl { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border-input); background: var(--surface); color: var(--text); font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 72px; resize: vertical; }
.input.big { font-family: var(--font-num); font-size: 30px; font-weight: 600; min-height: 60px; }
.quick { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--accent); border-radius: 16px; background: var(--surface); padding: 4px 4px 4px 14px; margin-bottom: 6px; }
.quick input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 17px; min-height: 48px; }
.hint { font-size: 13px; color: var(--text-faint); margin: 0 2px 16px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; background: var(--surface); border-radius: 12px; padding: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 42px; border-radius: 9px; font-weight: 600; font-size: 15px; color: var(--text-muted); }
.seg input:checked + span { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; inset: 0; }
.swatches span { display: block; width: 36px; height: 36px; border-radius: 999px; border: 3px solid transparent; }
.swatches input:checked + span { border-color: var(--text); }
.swatches input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text-muted); margin: -2px 0 16px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 1px 0 0; flex-shrink: 0; }
.btns { display: flex; gap: 10px; margin-top: 6px; }
.btn { flex: 1; min-height: 50px; border-radius: 14px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; }
.btn.sec { background: var(--surface-2); color: var(--text); }
.btn.del { background: var(--danger-soft); color: var(--danger); flex: 0 0 auto; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.err { color: var(--danger); font-size: 14px; margin: 0 0 12px; }
.ok-msg { color: var(--success); font-size: 14px; margin: 0 0 12px; }
.preview { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 14px; }
.preview td, .preview th { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.preview th { color: var(--text-muted); font-weight: 600; }
.preview td.r { text-align: right; white-space: nowrap; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.pill.new { background: var(--success-soft); color: var(--success); }
.pill.skip { background: var(--surface-2); color: var(--text-faint); }
.pill.link { background: var(--info-soft); color: var(--info); }

/* ---------- bienvenida ---------- */
.welcome { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 32px 22px; }
.welcome-box { width: 100%; max-width: 400px; }
.welcome-box img { width: 64px; height: 64px; border-radius: 16px; }
.welcome-box h1 { margin: 18px 0 4px; font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.welcome-box .lead { margin: 0 0 26px; color: var(--text-muted); font-size: 16px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: 13px; margin: 18px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---------- aviso flotante ---------- */
.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; padding: 12px 16px; border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.4); display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); animation: rise .2s ease; }
.toast button { border: 0; background: none; color: #1d6b47; font-weight: 700; padding: 4px; }
@media (min-width: 900px) { .toast { bottom: 40px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
