/* SolveSAT */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #f0f3f2; --line: #dfe5e3; --line-2: #c9d2cf;
  --text: #14201d; --muted: #5b6b67; --faint: #8a9894;
  --brand: #0f5b4d; --brand-2: #127a66; --brand-ink: #ffffff; --brand-soft: #e3f2ee;
  --accent: #b7791f; --ok: #1f7a4d; --ok-soft: #e4f4ea; --warn: #a15c07; --warn-soft: #fdf1df; --bad: #b42318; --bad-soft: #fde8e6;
  --s1: #127a66; --s2: #c9a227;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 32, 28, .06), 0 2px 8px rgba(16, 32, 28, .04);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1513; --surface: #151f1c; --surface-2: #1b2723; --line: #26332f; --line-2: #34443f;
    --text: #e6eeeb; --muted: #9aaba6; --faint: #6f807b; --brand: #3fbf9f; --brand-2: #5fd3b4; --brand-ink: #06231c; --brand-soft: #173a31;
    --ok: #4cc38a; --ok-soft: #123526; --warn: #e3a74a; --warn-soft: #3a2a10; --bad: #f2786c; --bad-soft: #3d1714; --s1: #3fbf9f; --s2: #d9b64a;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1513; --surface: #151f1c; --surface-2: #1b2723; --line: #26332f; --line-2: #34443f;
  --text: #e6eeeb; --muted: #9aaba6; --faint: #6f807b; --brand: #3fbf9f; --brand-2: #5fd3b4; --brand-ink: #06231c; --brand-soft: #173a31;
  --ok: #4cc38a; --ok-soft: #123526; --warn: #e3a74a; --warn-soft: #3a2a10; --bad: #f2786c; --bad-soft: #3d1714; --s1: #3fbf9f; --s2: #d9b64a;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
h3 { font-size: .95rem; margin: .5rem 0 .25rem; }
p { margin: 0 0 .5rem; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .05em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: .85rem; }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); }
.clip { display: inline-block; max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.ic { display: inline-flex; vertical-align: middle; }

/* layout */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; color: var(--text); font-weight: 600; padding: 2px 6px; }
.brand b { color: var(--brand-2); }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 1.7rem; justify-content: center; }
.co-switch, .co-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; color: var(--text); font: inherit; cursor: pointer; }
.co-switch:hover, .co-item:hover { border-color: var(--line-2); }
.co-item.on { border-color: var(--brand); background: var(--brand-soft); }
.co-avatar { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.co-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.co-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.co-text small { color: var(--muted); font-size: .78rem; }
.co-list { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.on { background: var(--brand-soft); color: var(--brand-2); }
.nav-link.admin { margin-top: 6px; border-top: 1px dashed var(--line); border-radius: 0 0 8px 8px; padding-top: 12px; }
.side-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px; }
.side-user { font-size: .8rem; color: var(--faint); padding: 0 6px; display: flex; gap: 6px; align-items: center; word-break: break-all; }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.main { padding: 24px 28px 60px; max-width: 1320px; width: 100%; display: flex; flex-direction: column; gap: 16px; }
.viewas { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 500; }
.demo-banner { background: var(--brand-soft); color: var(--brand-2); padding: 6px 16px; font-size: .85rem; }
.scrim { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head p { max-width: 80ch; }
.back { font-size: .85rem; display: inline-block; margin-bottom: 4px; }
.page-head > .row .input, .page-head > .input { width: auto; }
.ob.previa { opacity: .55; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .top-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .main { padding: 16px 16px 60px; }
}

/* cards & boxes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.pad { padding: 16px 18px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; } .row.center { justify-content: center; } .row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.grid2.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
@media (max-width: 900px) { .grid2, .grid2.wide-left { grid-template-columns: 1fr; } }
.info-box, .warn-box, .ok-box, .alert-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); border: 1px solid; }
.info-box { background: var(--brand-soft); border-color: transparent; color: var(--text); }
.warn-box, .alert-box { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.warn-box .ic, .alert-box .ic { color: var(--warn); margin-top: 2px; }
.alert-box.bad { background: var(--bad-soft); } .alert-box.bad .ic { color: var(--bad); }
.alert-box ul { margin: 4px 0 0; padding-left: 18px; }
.ok-box { background: var(--ok-soft); border-color: transparent; } .ok-box .ic { color: var(--ok); }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.loading { display: flex; gap: 10px; align-items: center; color: var(--muted); padding: 20px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--bad); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpis.small { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.kpis.small .kpi { padding: 8px 12px; background: var(--surface-2); border-color: transparent; }
.kpi-label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.kpi-value { font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpis.small .kpi-value { font-size: 1.1rem; }
.kpi-sub { color: var(--muted); font-size: .8rem; }
.kpi.accent { border-color: var(--brand); background: var(--brand-soft); }
.kpi.warn .kpi-value { color: var(--warn); } .kpi.good .kpi-value { color: var(--ok); }
.big-amount { text-align: right; font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand-2); line-height: 1.1; }
.big-amount small { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }

/* forms */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field-hint { font-size: .78rem; color: var(--faint); }
.input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; min-height: 36px; width: 100%; min-width: 0; }
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input.mini { min-height: 30px; padding: 3px 8px; width: auto; }
textarea.input { resize: vertical; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid-form .span2, .grid-form h2 { grid-column: 1 / -1; }
.grid-form h2 { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.grid-form h2:first-child { border: 0; margin-top: 0; padding-top: 0; }
@media (max-width: 640px) { .grid-form { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form-error { color: var(--bad); min-height: 0; margin: 0; }
.form-error:empty { display: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .input { width: auto; min-width: 150px; flex: 0 1 auto; }
.filters input[type=search] { flex: 1 1 220px; }

/* buttons */
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; justify-content: center; border-radius: 8px; padding: 7px 14px; min-height: 36px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.mini { min-height: 28px; padding: 3px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.linkish { background: none; border: 0; padding: 0; color: var(--brand-2); font: inherit; cursor: pointer; font-size: .85rem; }
.linkish:hover { text-decoration: underline; }
.linkish.center { align-self: center; }

/* badges, tabs */
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.accent { background: var(--brand-soft); color: var(--brand-2); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { font: inherit; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 8px 12px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); } .tab.on { color: var(--brand-2); border-bottom-color: var(--brand-2); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tr.void td { color: var(--faint); text-decoration: line-through; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.tbl.sheet td { padding: 7px 4px; }
.tbl.sheet tr.k-total td { font-weight: 700; border-top: 2px solid var(--line-2); }
.tbl.sheet tr.k-total td.num { color: var(--brand-2); font-size: 1.05rem; }
.tbl.sheet tr.k-info td { color: var(--muted); }
.tbl.sheet tr.k-credit td.num { color: var(--ok); }
@media (max-width: 640px) {
  .table-wrap:not(.keep) .tbl thead { display: none; }
  .table-wrap:not(.keep) .tbl tr { display: block; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  .table-wrap:not(.keep) .tbl td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 2px 0; text-align: right; }
  .table-wrap:not(.keep) .tbl td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
  .table-wrap:not(.keep) .tbl td:empty { display: none; }
}
.bulk { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--brand-soft); padding: 8px 12px; border-radius: var(--radius); position: sticky; top: 0; z-index: 5; }
.bulk .input { width: auto; }
.pager { margin-top: 8px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(8, 16, 14, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-box { background: var(--surface); border-radius: 14px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-box.wide { width: min(820px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 16px 18px 18px; }

/* toasts */
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 380px; transition: opacity .4s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card > .muted { text-align: center; margin-top: -6px; }

/* imports */
.drop { border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; text-align: center; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.steps.small { font-size: .9rem; gap: 4px; }
.tokbox { display: flex; gap: 8px; align-items: center; padding: 6px 0; }
.big-code { font-size: 1rem; padding: 6px 10px; word-break: break-all; }
.preview { border-top: 1px solid var(--line); padding-top: 12px; }
.errlist { max-height: 240px; overflow: auto; font-size: .85rem; color: var(--bad); }
details summary { cursor: pointer; }

/* dashboard */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); }
.chart .axis { fill: var(--faint); font-size: 11px; }
.chart .s1 { fill: var(--s1); } .chart .s2 { fill: var(--s2); }
.legend { display: flex; gap: 6px 14px; align-items: center; font-size: .82rem; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend .k { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: -8px; }
.legend .k.s1 { background: var(--s1); } .legend .k.s2 { background: var(--s2); }
.due-list, .plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.due-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.due-list li:last-child { border: 0; }
.due { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; flex-direction: column; }
.due.soon { color: var(--warn); font-weight: 600; }
.due small { color: var(--muted); font-weight: 500; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bars li { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: 10px; align-items: center; }
.bar { background: var(--surface-2); height: 10px; border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--s1); border-radius: 5px; }
.setup { border-color: var(--brand); }

/* obligations */
.ob-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.ob-list { list-style: none; margin: 0; padding: 0; }
.ob-list li a { display: grid; grid-template-columns: minmax(90px, 1.1fr) 1fr auto auto; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); color: var(--text); font-variant-numeric: tabular-nums; }
.ob-list li:last-child a { border: 0; }
.ob-list li a:hover { background: var(--surface-2); text-decoration: none; }
.ob-period { font-weight: 600; text-transform: capitalize; }
.ob-due { color: var(--muted); font-size: .85rem; }
.ob-amt { text-align: right; }
.ob.futura { opacity: .6; }
.notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: .88rem; display: flex; flex-direction: column; gap: 4px; }

/* savings */
.ops { display: flex; flex-direction: column; gap: 12px; }
.op { border-left: 4px solid var(--line-2); }
.op.sev-high { border-left-color: var(--bad); } .op.sev-medium { border-left-color: var(--warn); } .op.sev-info { border-left-color: var(--ok); }
.op h2 { margin: 0; }
.impact { color: var(--brand-2); font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* admin */
.mem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; }
.mem-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

@media print {
  .side, .topbar, .btn, .viewas, .demo-banner, #toasts, .tabs, .filters { display: none !important; }
  .layout { display: block; } .main { padding: 0; } .card { box-shadow: none; border: 0; }
}
