:root {
  --bg: #f6f4ef; --surface: #ffffff; --surface-2: #f0ede6; --line: #e3dfd5;
  --text: #1d1f1e; --muted: #6b6f6c; --accent: #1f6f5c; --accent-2: #e5f1ec;
  --pos: #1f7a4d; --neg: #b3412e; --warn: #a8701a;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141615; --surface: #1d201f; --surface-2: #252928; --line: #323735; --text: #ecefed;
    --muted: #9aa19d; --accent: #4fb596; --accent-2: #1d3a31; --pos: #5cc08a; --neg: #ec7a64; --warn: #e0a84a;
    --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.small { font-size: 13px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 17px; padding: 0 10px 16px; }
.brand img { width: 28px; height: 28px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--text); }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 8px; }
.nav .group { font-size: 12px; color: var(--muted); padding: 10px 12px 4px; text-transform: uppercase; letter-spacing: .04em; }
.side .foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 0 12px; }
main { padding: 24px 28px 100px; max-width: 980px; width: 100%; }
.bottom { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 16px 14px 110px; }
  .bottom { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
  .bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
  .bottom a .ic { font-size: 20px; line-height: 1; }
  .bottom a.on { color: var(--accent); font-weight: 600; }
}

/* ---------- componentes ---------- */
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.card h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .right { margin-left: auto; font-weight: 500; font-size: 13px; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .kpis { grid-template-columns: 1fr 1fr; } .kpis .kpi:first-child { grid-column: 1 / -1; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .lbl { font-size: 12.5px; color: var(--muted); }
.kpi .val { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.kpi.main { background: var(--accent); color: #fff; border-color: var(--accent); }
.kpi.main .lbl { color: rgba(255,255,255,.8); }
@media (prefers-color-scheme: dark) { .kpi.main { color: #0d1a16; } .kpi.main .lbl { color: rgba(0,0,0,.65); } }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0d1a16; } }
.btn.danger { color: var(--neg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { border: 0; background: transparent; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: var(--muted); font-size: 16px; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.monthnav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.monthnav span { min-width: 120px; text-align: center; font-weight: 600; }

.list { margin: 0; padding: 0; list-style: none; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; font-size: 17px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 12.5px; color: var(--muted); }
.item .amt { text-align: right; font-weight: 600; white-space: nowrap; }
.item .amt .sub { font-weight: 400; }
.item.click { cursor: pointer; } .item.click:hover .title { color: var(--accent); }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.over > i { background: var(--neg); }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--accent-2); color: var(--accent); }
.tag.due { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.dayhead { font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 12px 0 2px; }

.fab { position: fixed; right: 22px; bottom: 26px; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  font-size: 28px; box-shadow: 0 6px 20px rgba(31,111,92,.35); cursor: pointer; z-index: 25; }
@media (prefers-color-scheme: dark) { .fab { color: #0d1a16; } }
@media (max-width: 760px) { .fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 16px; } }

/* modal / sheet */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { background: var(--surface); border-radius: 18px; width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; padding: 18px; }
.sheet h3 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; }
.sheet h3 .iconbtn { margin-left: auto; }
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.sheet .actions .spacer { flex: 1; }
@media (max-width: 760px) { .overlay { align-items: flex-end; padding: 0; } .sheet { border-radius: 18px 18px 0 0; max-width: none; padding-bottom: calc(18px + env(safe-area-inset-bottom)); } }

.quick { display: flex; gap: 8px; }
.quick .input { flex: 1; }
.hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 12px; }
.preview { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--accent-2); color: var(--accent); margin-bottom: 12px; }
.preview.err { background: color-mix(in srgb, var(--neg) 12%, transparent); color: var(--neg); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 6px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; padding: 24px; }
.auth .brand { padding: 0 0 6px; font-size: 20px; }
.err { color: var(--neg); font-size: 13.5px; margin-bottom: 10px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 30px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 14px; }
@media (max-width: 760px) { .toast { bottom: calc(90px + env(safe-area-inset-bottom)); } }

.modules { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.modcard { display: block; color: var(--text); }
.modcard .big { font-size: 28px; }
.modcard h3 { margin: 6px 0 2px; font-size: 16px; }
.modcard.soon { opacity: .55; border-style: dashed; }

.chart { width: 100%; height: 150px; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
table.simple { width: 100%; border-collapse: collapse; }
table.simple td, table.simple th { padding: 8px 6px; border-top: 1px solid var(--line); text-align: left; }
table.simple th { font-size: 12.5px; color: var(--muted); font-weight: 500; border-top: 0; }
.kpis.two { grid-template-columns: 1fr 1fr; } .kpis.two .kpi:first-child { grid-column: auto; }
