/* Layout: one ledger column — summary, filters, category sections of marker rows; sheets slide up for detail, entry and import */
:root{
  --bg:#f3f5f7; --surface:#ffffff; --sunk:#e9edf1; --ink:#18212d; --muted:#5b6676; --line:#d9dee5;
  --accent:#0d6b70; --accent-ink:#ffffff; --accent-soft:#d8eeee;
  --high:#b5400c; --high-soft:#fbe6dc; --low:#2a5bb0; --low-soft:#e1e9f8; --band:#d9efe6; --ok:#1f7a4d;
  --f-display:"Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --f-body:"Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-data:"IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r:10px;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#0f141a; --surface:#161c24; --sunk:#1d242e; --ink:#e5e9ee; --muted:#97a2b1; --line:#29313c;
  --accent:#55bcc0; --accent-ink:#06282a; --accent-soft:#163a3d;
  --high:#f2915f; --high-soft:#3d2418; --low:#86a9f0; --low-soft:#1c2a45; --band:#173329; --ok:#5fcf95; color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0f141a; --surface:#161c24; --sunk:#1d242e; --ink:#e5e9ee; --muted:#97a2b1; --line:#29313c;
  --accent:#55bcc0; --accent-ink:#06282a; --accent-soft:#163a3d;
  --high:#f2915f; --high-soft:#3d2418; --low:#86a9f0; --low-soft:#1c2a45; --band:#173329; --ok:#5fcf95; color-scheme:dark}
*{box-sizing:border-box}
body{background:var(--bg);color:var(--ink);font:15px/1.5 var(--f-body);-webkit-font-smoothing:antialiased}
.wrap{max-width:980px;margin:0 auto;padding-inline:16px;padding-block:20px 80px}
h1,h2,h3{font-family:var(--f-display);margin:0;text-wrap:balance;letter-spacing:-.01em}
h1{font-size:clamp(26px,5vw,34px);font-weight:700}
h2{font-size:18px;font-weight:700}
.num{font-family:var(--f-data);font-variant-numeric:tabular-nums}
.muted{color:var(--muted)}
.eyebrow{font-size:11px;letter-spacing:.09em;text-transform:uppercase;color:var(--muted);font-weight:600}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.btn{border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:8px 14px;font-weight:600;font-size:14px;display:inline-flex;align-items:center;gap:6px;min-height:38px}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.ghost{background:transparent;border-color:transparent;color:var(--accent);padding-inline:8px}
.btn.danger{color:var(--high)}
.btn.danger.armed{background:var(--high);border-color:var(--high);color:var(--surface)}
.btn:disabled{opacity:.5;cursor:default}

header.top{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:14px;margin-bottom:18px}
.actions{display:flex;flex-wrap:wrap;gap:8px}

.summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1px;background:var(--line);border:1px solid var(--line);border-radius:var(--r);overflow:hidden;margin-bottom:16px}
.summary>div{background:var(--surface);padding:12px 14px;min-width:0}
.summary b{display:block;font-family:var(--f-display);font-size:24px;font-weight:700;line-height:1.2}
.summary b.alert{color:var(--high)}

.filters{display:flex;flex-direction:column;gap:10px;margin-bottom:18px}
.search{width:100%;border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:9px 12px}
.chips{display:flex;gap:6px;overflow-x:auto;padding-bottom:2px;scrollbar-width:none}
.chip{flex:none;border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:5px 12px;font-size:13px;font-weight:500;white-space:nowrap}
.chip[aria-pressed="true"]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.chip.flagchip[aria-pressed="true"]{background:var(--high);border-color:var(--high);color:var(--surface)}

section.cat{margin-bottom:22px}
.cat-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:0 2px 8px;border-bottom:2px solid var(--ink)}
.list{background:var(--surface);border:1px solid var(--line);border-top:0;border-radius:0 0 var(--r) var(--r)}
.row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 12px;padding:11px 14px;border-top:1px solid var(--line);width:100%;text-align:left;background:none;border-left:0;border-right:0;border-bottom:0}
.row:first-child{border-top:0}
.row:hover{background:var(--sunk)}
.row .name{font-weight:600;min-width:0;overflow-wrap:anywhere}
.row .sub{font-size:12px;color:var(--muted)}
.row .val{text-align:right;white-space:nowrap}
.row .val .v{font-family:var(--f-data);font-size:16px;font-weight:500}
.row .val .u{font-size:12px;color:var(--muted);margin-left:4px}
.row .viz{grid-column:1 / -1;display:flex;align-items:center;gap:14px;min-width:0}
.rangebar{position:relative;height:6px;flex:1;max-width:260px;background:var(--sunk);border-radius:3px}
.rangebar .ok{position:absolute;top:0;bottom:0;background:var(--band);border-radius:3px}
.rangebar .dot{position:absolute;top:50%;width:11px;height:11px;margin:-5.5px 0 0 -5.5px;border-radius:50%;background:var(--ink);border:2px solid var(--surface)}
.rangebar .dot.high{background:var(--high)} .rangebar .dot.low{background:var(--low)}
.spark{flex:none}
.pill{display:inline-block;font-size:11px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;border-radius:4px;padding:1px 6px;margin-left:6px;vertical-align:2px}
.pill.high{background:var(--high-soft);color:var(--high)} .pill.low{background:var(--low-soft);color:var(--low)}
.v.high{color:var(--high)} .v.low{color:var(--low)}
@media (min-width:720px){
  .row{grid-template-columns:minmax(0,1.4fr) minmax(0,1.2fr) 150px;align-items:center}
  .row .viz{grid-column:auto;grid-row:1}
  .row .val{grid-column:3}
}

.empty{background:var(--surface);border:1px dashed var(--line);border-radius:var(--r);padding:28px 20px;text-align:center}
.empty p{margin:6px auto 14px;max-width:46ch}

/* sheets */
dialog{border:0;padding:0;background:var(--surface);color:var(--ink);width:min(760px,100vw);max-width:100vw;max-height:92vh;border-radius:14px 14px 0 0;margin:auto auto 0;box-shadow:0 -10px 40px rgba(0,0,0,.25)}
@media (min-width:760px){dialog{border-radius:14px;margin:auto}}
dialog::backdrop{background:rgba(10,15,22,.5)}
.sheet{display:flex;flex-direction:column;max-height:92vh}
.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px;padding:16px 16px 10px;border-bottom:1px solid var(--line)}
.sheet-body{overflow:auto;padding:14px 16px 18px;display:flex;flex-direction:column;gap:14px}
.sheet-foot{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;padding:12px 16px calc(12px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--line)}
.x{border:0;background:var(--sunk);width:34px;height:34px;border-radius:50%;font-size:18px;line-height:1;flex:none}
label.f{display:flex;flex-direction:column;gap:4px;font-size:12px;font-weight:600;color:var(--muted);min-width:0}
.in{border:1px solid var(--line);background:var(--bg);border-radius:7px;padding:7px 9px;width:100%;min-width:0;font-size:14px;color:var(--ink)}
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
.tablewrap{overflow-x:auto;border:1px solid var(--line);border-radius:8px}
table.ed{border-collapse:collapse;width:100%;min-width:620px;font-size:13px}
table.ed th{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);text-align:left;padding:7px 6px;background:var(--sunk);font-weight:600}
table.ed td{padding:4px 4px;border-top:1px solid var(--line);vertical-align:middle}
table.ed .in{padding:5px 6px;font-size:13px;background:transparent;border-color:transparent}
table.ed .in:hover,table.ed .in:focus{border-color:var(--line);background:var(--bg)}
table.ed input.numin{font-family:var(--f-data);width:84px}
table.ed tr.dirty td{background:var(--accent-soft)}
table.ed tr.dup td{opacity:.6}
.chart{width:100%;height:auto;display:block}
.chart text{fill:var(--muted);font:11px var(--f-data)}
.note{font-size:13px;background:var(--sunk);border-radius:8px;padding:10px 12px}
.drop{border:2px dashed var(--line);border-radius:10px;padding:22px 16px;text-align:center;background:var(--bg)}
.drop.over{border-color:var(--accent);background:var(--accent-soft)}
.drop strong{display:block;font-family:var(--f-display);font-size:17px}
.formats{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;margin-top:8px}
.formats span{font:11px var(--f-data);border:1px solid var(--line);border-radius:4px;padding:1px 6px;color:var(--muted)}
textarea.in{min-height:110px;resize:vertical;font-family:var(--f-data);font-size:12.5px}
.status{display:flex;align-items:center;gap:10px;font-size:14px}
.spin{width:16px;height:16px;border:2px solid var(--line);border-top-color:var(--accent);border-radius:50%;animation:sp 0.8s linear infinite;flex:none}
@keyframes sp{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.spin{animation-duration:3s}}
.toast{position:fixed;left:50%;bottom:calc(20px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);background:var(--ink);color:var(--bg);padding:10px 16px;border-radius:8px;font-size:14px;font-weight:500;z-index:50;max-width:calc(100vw - 32px)}
.legend{display:flex;gap:14px;flex-wrap:wrap;font-size:12px;color:var(--muted)}
.legend i{display:inline-block;width:14px;height:8px;border-radius:2px;background:var(--band);margin-right:5px;vertical-align:0}

/* ---------- app shell additions ---------- */
[hidden]{display:none!important}
html{-webkit-text-size-adjust:100%}
body{margin:0;min-height:100vh;min-height:100dvh}
.wrap{padding-top:calc(20px + env(safe-area-inset-top,0px));padding-bottom:calc(80px + env(safe-area-inset-bottom,0px));padding-left:max(16px, env(safe-area-inset-left,0px));padding-right:max(16px, env(safe-area-inset-right,0px))}
.brand{display:flex;align-items:center;gap:12px;min-width:0}
.brand img{width:40px;height:40px;border-radius:10px;flex:none}
.btn.install{border-color:var(--accent);color:var(--accent)}
.btn.icon{width:38px;padding:0;justify-content:center;font-size:20px;line-height:1}
.menuwrap{position:relative}
.menu{position:absolute;right:0;top:calc(100% + 6px);z-index:20;background:var(--surface);border:1px solid var(--line);border-radius:10px;box-shadow:0 12px 30px rgba(0,0,0,.18);padding:6px;min-width:230px;display:flex;flex-direction:column}
.menu button{border:0;background:none;text-align:left;padding:10px 12px;border-radius:7px;font-size:14px;font-weight:500}
.menu button:hover{background:var(--sunk)}
.menu hr{border:0;border-top:1px solid var(--line);margin:4px 0}
.banner{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;background:var(--accent-soft);border:1px solid var(--accent);border-radius:var(--r);padding:12px 14px;margin-bottom:16px;font-size:14px}
.banner p{margin:0;min-width:0;flex:1 1 240px}
.banner.warn{background:var(--high-soft);border-color:var(--high)}
.steps{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:12px;counter-reset:s}
.steps li{display:flex;gap:12px;align-items:flex-start;counter-increment:s}
.steps li::before{content:counter(s);flex:none;width:26px;height:26px;border-radius:50%;background:var(--accent);color:var(--accent-ink);font-weight:700;font-size:13px;display:grid;place-items:center}
.steps svg{vertical-align:-4px}
.kbd{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--line);background:var(--sunk);border-radius:6px;padding:1px 7px;font-weight:600;font-size:13px;white-space:nowrap}
.prose p{margin:0 0 10px;max-width:62ch}
.prose p:last-child{margin-bottom:0}
.empty .actions{justify-content:center}
.fine{font-size:12px;color:var(--muted)}

/* connect */
.connectcta{display:flex;flex-direction:column;gap:2px;text-align:left;border:1px solid var(--accent);background:var(--accent-soft);color:var(--ink);border-radius:10px;padding:12px 14px}
.connectcta b{font-family:var(--f-display);font-size:16px;color:var(--accent)}
.connectcta span{font-size:13px;color:var(--muted)}
.orglist{display:flex;flex-direction:column;border:1px solid var(--line);border-radius:10px;overflow:hidden;max-height:46vh;overflow-y:auto}
.orglist:empty{display:none}
.orglist button{border:0;border-top:1px solid var(--line);background:var(--surface);text-align:left;padding:12px 14px;font-size:14px;font-weight:500}
.orglist button:first-child{border-top:0}
.orglist button:hover{background:var(--sunk)}
.orglist button small{display:block;font-weight:400;color:var(--muted);font-size:12px}
