:root {
  /* light — clean warm paper, default */
  --bg: #FAF9F7;
  --panel: #FFFFFF;
  --panel-2: #F3F1ED;
  --line: #E6E3DD;
  --line-soft: #EDEAE4;
  --text: #1A1917;
  --muted: #6E6C66;
  --dim: #9B988F;
  --accent: #C8811F;
  --accent-2: #4E6DB0;
  --accent-soft: rgba(200,129,31,.10);
  --good: #2E7D4F;
  --bad: #C0483A;
  --navy: #FFFFFF;
  --btn-ink: #FFFFFF;
  --glass: rgba(255,255,255,.82);
  --radius: 12px;
}
html[data-theme="dark"] {
  --bg: #0F1011;
  --panel: #16171A;
  --panel-2: #1C1E22;
  --line: #26282D;
  --line-soft: #202226;
  --text: #ECEBE8;
  --muted: #93938D;
  --dim: #63635E;
  --accent: #E3A34A;
  --accent-2: #7C93C7;
  --accent-soft: rgba(227,163,74,.12);
  --good: #6DB585;
  --bad: #D47163;
  --navy: #16171A;
  --btn-ink: #1B1305;
  --glass: rgba(22,23,26,.85);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px; -webkit-text-size-adjust: 100%; letter-spacing: -0.01em; }
h2, h3 { margin: 0; font-weight: 600; }
input { font-family: inherit; }
.gc, .bc, .lc-net, .kpi .v, .big, .pl-net, .breakdown, .mg-tot, .pr-v, .dh-net { font-variant-numeric: tabular-nums; }

.btn { width: 100%; padding: 14px; border: none; border-radius: 10px; background: var(--accent);
  color: var(--btn-ink); font-weight: 600; font-size: 15px; cursor: pointer; letter-spacing: -0.01em; transition: opacity .15s, transform .05s; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.good { background: var(--good); color: #fff; }
html[data-theme="dark"] .btn.good { color: #06210F; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn.big { font-size: 17px; padding: 18px; margin-bottom: 16px; }
.btn.small { width: auto; padding: 8px 13px; font-size: 13px; border-radius: 8px; }
.btn:hover { opacity: .92; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 6px; transition: color .15s; }
.linkbtn:hover { color: var(--text); }
.linkbtn.back { display: inline-block; margin-bottom: 6px; }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px 26px; }
.brand { display: flex; align-items: center; gap: 2px; font-weight: 650; font-size: 21px; margin-bottom: 2px; letter-spacing: -0.02em; }
.brand .dot { color: var(--accent); }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.or { text-align: center; color: var(--dim); font-size: 13px; margin: 16px 0 10px; }
.auth-card .btn { margin-top: 10px; }
label { display: block; font-size: 11px; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .6px; font-weight: 500; }
input { width: 100%; padding: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; color: var(--text); font-size: 16px; transition: border-color .15s; }
input:focus { outline: none; border-color: var(--accent-2); }
.msg { margin-top: 12px; font-size: 14px; min-height: 18px; text-align: center; }
.msg.err { color: var(--bad); } .msg.ok { color: var(--muted); }

.siteheader { position: sticky; top: 0; z-index: 31; background: var(--glass); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.sh-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 640px; margin: 0 auto; padding: 13px 18px; }
.brand, .top .biz { font-weight: 650; font-size: 17px; letter-spacing: -0.02em; }
.sh-right { display: flex; align-items: center; gap: 14px; }
.sh-right .who, .top .who { font-size: 13px; color: var(--muted); }
.tabs { display: flex; max-width: 640px; margin: 0 auto; padding: 0 10px; gap: 2px; }
.tabs button { flex: 1; background: none; border: none; color: var(--muted); font-weight: 500; font-size: 14px; padding: 13px 6px; cursor: pointer; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; letter-spacing: -0.01em; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
header.top { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; background: var(--navy); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
main { max-width: 640px; margin: 0 auto; padding: 20px 18px 56px; }
.screen { display: none; } .screen.active { display: block; }
.sec { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 500; margin: 26px 0 12px; }
.bottomnav { display: none; }
.sec-row { display: flex; align-items: center; justify-content: space-between; }

.actions2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.action-card { display: flex; flex-direction: column; align-items: flex-start; padding: 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); color: var(--text); cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.action-card:hover { border-color: #34363C; }
.action-card.go { background: var(--accent); color: #fff; border-color: transparent; }
.action-card.go:hover { opacity: .94; }
.ac-ico { color: var(--accent); margin-bottom: 12px; }
.ac-ico svg { display: block; }
.action-card.go .ac-ico { color: #fff; }
.ac-title { font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.ac-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.action-card.go .ac-sub { color: rgba(255,255,255,.8); }
.action-card:active { transform: translateY(1px); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 500; margin-bottom: 14px; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.kpi { background: var(--panel); padding: 12px 6px; text-align: center; }
.kpi .v { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; } .kpi .l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 3px; }
.gc { color: var(--good); } .bc { color: var(--bad); }

.loadcard { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; transition: border-color .15s; }
.loadcard:hover { border-color: #34363C; }
.lc-main { flex: 1; min-width: 0; }
.lc-title { font-weight: 550; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.lc-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.lc-actions { display: flex; align-items: center; gap: 10px; }
.lc-net { font-weight: 600; font-size: 16px; }
.pill { font-size: 10px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; vertical-align: middle; font-weight: 500; letter-spacing: .2px; text-transform: uppercase; }
.pill.amber { background: var(--accent-soft); color: var(--accent); border-color: rgba(227,163,74,.3); }
.del { background: none; border: none; color: var(--dim); font-size: 16px; cursor: pointer; padding: 4px; transition: color .15s; }
.del:hover { color: var(--bad); }
.empty { color: var(--muted); text-align: center; padding: 22px; font-size: 14px; }
.code { font-size: 28px; font-weight: 650; letter-spacing: 6px; text-align: center; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-top: 10px; color: var(--accent); }

.month-group { margin-bottom: 22px; }
.mg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 2px 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.mg-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.mg-tot { font-size: 12px; color: var(--muted); }
.mg-tot b { font-size: 12px; font-weight: 600; }
.mg-btns { display: inline-flex; gap: 6px; margin-left: auto; }
.mg-btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer; transition: color .15s, border-color .15s; }
.mg-btn:hover { color: var(--text); }
.mg-btn.danger { color: var(--bad); }
.lc-check { width: 18px; height: 18px; margin-right: 8px; accent-color: var(--accent); flex: none; align-self: center; }

.selbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--glass); backdrop-filter: blur(12px); border-top: 1px solid var(--line); z-index: 40; max-width: 640px; margin: 0 auto; }
.selbar[hidden] { display: none; }
.selbar .btn { margin: 0; flex: 1; }

.lc-main[data-detail] { cursor: pointer; }
.detail-head { margin-bottom: 18px; }
.dh-title { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.dh-meta { font-size: 13px; color: var(--muted); margin-top: 6px; }
.dh-ids { font-size: 12px; color: var(--muted); margin-top: 8px; word-break: break-all; line-height: 1.6; }
.dh-ids b { color: var(--text); font-weight: 600; }

.flow[hidden] { display: none; }
.flow { position: fixed; inset: 0; background: var(--bg); z-index: 50; display: flex; flex-direction: column; }
.flow-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.progress { display: flex; gap: 6px; flex: 1; }
.dot { height: 3px; flex: 1; background: var(--line); border-radius: 3px; transition: background .2s; }
.dot.on { background: var(--accent); }
.flow-body { flex: 1; overflow-y: auto; padding: 26px 20px; max-width: 640px; margin: 0 auto; width: 100%; }
.flow-foot { display: flex; gap: 10px; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); max-width: 640px; margin: 0 auto; width: 100%; }

.q { margin-bottom: 24px; }
.q-label { font-size: 23px; font-weight: 650; line-height: 1.3; letter-spacing: -0.02em; }
.q-hint { color: var(--muted); font-size: 14px; margin-top: 8px; line-height: 1.5; }
.q-input { position: relative; margin-top: 22px; display: flex; align-items: center; }
.q-input .pre { position: absolute; left: 18px; font-size: 24px; color: var(--muted); }
.q-input input { font-size: 28px; font-weight: 600; padding: 18px; text-align: center; }
.q-input.money input { padding-left: 40px; }

.pick { display: flex; flex-direction: column; gap: 10px; }
.pickbtn { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--text);
  font-size: 17px; font-weight: 550; cursor: pointer; transition: border-color .15s; letter-spacing: -0.01em; }
.pickbtn small { color: var(--muted); font-size: 13px; font-weight: 400; }
.pickbtn:hover { border-color: #34363C; }
.pickbtn:active { border-color: var(--accent); }

.shot { border: 1px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; }
.shot.drag { border-color: var(--accent); }
.rcount { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--accent); }

.headline { text-align: center; padding: 24px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); margin-bottom: 14px; }
.headline .big { font-size: 44px; font-weight: 650; line-height: 1.1; letter-spacing: -0.03em; }
.headline .big.good { color: var(--good); } .headline .big.bad { color: var(--bad); }
.headline .cap { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-bottom: 14px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.kpis .kpi { background: var(--panel); }
.breakdown { list-style: none; margin: 0; padding: 2px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.breakdown li { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: 14.5px; }
.breakdown li:last-child { border-bottom: none; }
.breakdown li span:first-child { color: var(--muted); }
.breakdown li.total { font-weight: 650; } .breakdown li.total span:first-child { color: var(--text); }
.breakdown li.sub { color: var(--good); font-weight: 550; }
.breakdown li.sub span:first-child { color: var(--good); }
.warn { color: var(--accent); font-size: 13px; margin-top: 10px; text-align: center; line-height: 1.5; }
.delivered-hero { text-align: center; margin-bottom: 8px; }
.delivered-hero .dh-net { font-size: 42px; font-weight: 650; letter-spacing: -0.03em; }
.delivered-hero .dh-net.good { color: var(--good); } .delivered-hero .dh-net.bad { color: var(--bad); }
.delivered-hero .cap { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; margin-top: 4px; }
.delivered-hero + .headline { display: none; }
.verdict { border-radius: var(--radius); padding: 16px; margin-bottom: 12px; text-align: center; border: 1px solid var(--line); }
.verdict.yes { background: rgba(109,181,133,.09); border-color: rgba(109,181,133,.28); }
.verdict.no { background: rgba(212,113,99,.09); border-color: rgba(212,113,99,.28); }
.verdict .v-title { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.verdict.yes .v-title { color: var(--good); }
.verdict.no .v-title { color: var(--bad); }
.verdict .v-sub { color: var(--text); font-size: 14px; margin-top: 4px; }
.note { color: var(--muted); font-size: 13px; margin: -2px 0 12px; text-align: center; line-height: 1.5; }
.assumptions { color: var(--dim); font-size: 12px; margin-top: 12px; text-align: center; line-height: 1.5; }
.sub-cap { font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; }
.setaside { margin-top: 12px; text-align: center; font-size: 14px; color: var(--muted); }
.setaside b { color: var(--text); font-weight: 600; }

.card.proj { background: var(--panel); }
.proj-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.proj-row:last-child { border-bottom: none; }
.pr-n { font-size: 16px; font-weight: 550; }
.pr-n small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; margin-top: 2px; }
.pr-v { font-size: 21px; font-weight: 650; letter-spacing: -0.02em; }
.pr-v small { font-size: 12px; color: var(--muted); font-weight: 500; }

.card.pl h3 { color: var(--muted); }
.pl-net { font-size: 32px; font-weight: 650; text-align: center; margin: 4px 0 16px; letter-spacing: -0.03em; }
.pl-net span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; font-weight: 500; margin-top: 3px; }

.fg { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 500; margin: 20px 0 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid .full { grid-column: 1 / -1; }
.grid label { margin-top: 0; }
.grid input { font-size: 15px; padding: 11px; }
.field label { margin-bottom: 6px; }

#toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px); background: var(--text);
  border: none; color: var(--bg); padding: 12px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.row2 { display: flex; gap: 10px; margin-bottom: 12px; }
.row2 .btn { margin: 0; }

#map { height: 62vh; min-height: 340px; border-radius: var(--radius); border: 1px solid var(--line); }
.leaflet-container { background: var(--panel-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel-2); color: var(--text); }
.map-legend { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.lg-line { display: inline-block; width: 16px; height: 3px; border-radius: 2px; margin-left: 8px; }
.lg-line.prog { background: var(--accent); } .lg-line.done { background: var(--accent-2); }

@media (max-width: 380px) { .sh-right .who { display: none; } .tabs button { font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.theme-toggle { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; display: inline-flex; align-items: center; border-radius: 8px; transition: color .15s, background .15s; }
.theme-toggle:hover { color: var(--text); background: var(--panel-2); }
.theme-toggle svg { display: block; }

html[data-theme="dark"] .action-card.go { color: #1B1305; }
html[data-theme="dark"] .action-card.go .ac-ico { color: #1B1305; }
html[data-theme="dark"] .action-card.go .ac-sub { color: rgba(27,19,5,.66); }
