:root {
  --bg: #f4f6f3; --card: #ffffff; --text: #17201b; --muted: #5e6b63; --line: #dde3de;
  --accent: #0f7a5a; --accent-soft: #e2f2ea; --warn: #9a5b00; --warn-soft: #fdf0d9;
  --stale: #7a3e9a; --stale-soft: #f1e5f7; --good: #0f7a5a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1411; --card: #17201b; --text: #e7efe9; --muted: #9aaba1; --line: #2a362f;
    --accent: #39c48f; --accent-soft: #163327; --warn: #f0b04d; --warn-soft: #3a2b12;
    --stale: #cf9be9; --stale-soft: #2f2038; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1411; --card: #17201b; --text: #e7efe9; --muted: #9aaba1; --line: #2a362f;
  --accent: #39c48f; --accent-soft: #163327; --warn: #f0b04d; --warn-soft: #3a2b12;
  --stale: #cf9be9; --stale-soft: #2f2038; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; }
.brand img { border-radius: 8px; }
.brand h1 { font-size: 20px; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }
.icon-btn { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 50%; width: 38px; height: 38px; font-size: 18px; }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px; }
input, select, button { font: inherit; color: inherit; }
input[type=search], input[type=number], input[type=text], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.row-between select { width: auto; padding: 6px 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line); background: var(--card); padding: 6px 12px; border-radius: 999px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.small { font-size: 13px; color: var(--muted); }
.cat-title { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.inst-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.inst-head h3 { font-size: 16px; }
.inst-notes { font-size: 13px; color: var(--muted); margin: 4px 0 6px; }
.offer { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 9px 0; cursor: pointer; }
.offer:first-of-type { border-top: 0; }
.offer .name { font-weight: 600; }
.offer .meta { font-size: 12.5px; color: var(--muted); }
.rate { font-size: 19px; font-weight: 700; color: var(--accent); white-space: nowrap; text-align: right; }
.rate small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 4px; vertical-align: 1px; background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.stale { background: var(--stale-soft); color: var(--stale); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.tabs button { flex: 1; background: none; border: 0; padding: 14px 4px; color: var(--muted); font-weight: 600; }
.tabs button.on { color: var(--accent); }
.btn { border: 1px solid var(--line); background: var(--card); padding: 10px 14px; border-radius: 10px; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.wide { width: 100%; margin-bottom: 12px; }
.btn.danger { color: #c0392b; }
dialog { border: 0; padding: 0; width: min(560px, 100%); max-height: 92vh; border-radius: 18px 18px 0 0; margin: auto auto 0; background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
#sheetBody { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
#sheetBody h2 { font-size: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 700; }
.stat.net .v { color: var(--accent); }
.note { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); }
.note.warn { background: var(--warn-soft); }
.prose p { margin: 8px 0; }
.prose h2 { font-size: 18px; }
.totals h2 { font-size: 15px; color: var(--muted); font-weight: 600; }
.totals .big { font-size: 26px; font-weight: 800; margin: 2px 0 8px; }
.dep { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding: 8px 0; }
.dep:first-of-type { border-top: 0; }
.dep button { background: none; border: 0; color: var(--muted); padding: 0 4px; cursor: pointer; }
a { color: var(--accent); word-break: break-all; }
label.chk { display: flex; gap: 8px; align-items: center; }
.install { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--accent-soft); }
.install p { margin: 0; font-size: 13.5px; }
.install .x { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 0 4px; }
.top, main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
