:root {
  --bg: #0e2218; --panel: #14301f; --panel2: #1d4430; --line: #2f6648; --text: #eef6f0; --muted: #a3c2ad;
  --accent: #f2c744; --good: #7ddc7a; --bad: #ef7b6c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; touch-action: none; }
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.top { position: fixed; top: var(--site-bar, 0px); left: 0; right: 0; padding: 6px max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); z-index: 12; pointer-events: none; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.top > *, .row1 > *, .row2 > * { pointer-events: auto; }
.row1, .row2 { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; pointer-events: none; }
.top h1 { margin: 0 4px 0 0; font-size: 1.05rem; color: var(--accent); text-shadow: 0 1px 4px rgba(0,0,0,.7); white-space: nowrap; pointer-events: auto; }
.chip { background: rgba(14,38,26,.88); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .85rem; cursor: pointer; white-space: nowrap; min-height: 32px; }
.chip.money { font-weight: 800; color: var(--accent); cursor: default; font-variant-numeric: tabular-nums; }
.chip.money.neg { color: var(--bad); }
span.chip { cursor: default; }
.seg { display: inline-flex; }
.seg .chip { border-radius: 0; border-left-width: 0; padding: 5px 9px; }
.seg .chip:first-child { border-radius: 999px 0 0 999px; border-left-width: 1px; }
.seg .chip:last-child { border-radius: 0 999px 999px 0; }
.chip.on, .chip.active { background: var(--accent); color: #1a1a10; border-color: var(--accent); font-weight: 700; }
.ic { margin-right: 5px; }
.chip.accent { background: var(--accent); color: #1a1a10; border-color: var(--accent); font-weight: 800; min-width: 34px; }
.goalchip { background: rgba(14,38,26,.88); border: 1px solid var(--accent); border-radius: 10px; padding: 3px 10px; font-size: .78rem; color: #fff6cf; cursor: pointer; max-width: min(100%, 520px); text-align: left; }

.tools { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 5px; padding: 6px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); z-index: 12; overflow-x: auto; justify-content: center; touch-action: pan-x; scrollbar-width: none; }
.tools::-webkit-scrollbar { display: none; }
.tool { flex: 0 0 auto; width: 62px; height: 54px; border-radius: 12px; border: 1px solid var(--line); background: rgba(14,38,26,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; cursor: pointer; padding: 2px; }
.tool .ico { font-size: 1.35rem; line-height: 1.2; }
.tool .lab { font-size: .62rem; color: var(--muted); line-height: 1.1; text-align: center; }
.tool.on { background: var(--accent); border-color: var(--accent); }
.tool.on .lab { color: #1a1a10; font-weight: 700; }
.hintbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 11; background: rgba(14,38,26,.92); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; font-size: .8rem; max-width: calc(100% - 16px); text-align: center; pointer-events: none; }
.tip { position: fixed; z-index: 13; background: rgba(0,0,0,.82); color: #cfffcf; border-radius: 8px; padding: 3px 9px; font-size: .85rem; font-weight: 700; pointer-events: none; white-space: nowrap; }
.tip.bad { color: #ffc2b8; }

.info { position: fixed; left: max(8px, env(safe-area-inset-left)); bottom: calc(96px + env(safe-area-inset-bottom)); width: min(330px, calc(100% - 16px)); max-height: 46vh; overflow-y: auto; background: rgba(14,38,26,.95); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; z-index: 11; touch-action: pan-y; }
.info h3 { margin: 0 24px 4px 0; font-size: 1rem; color: var(--accent); }
.info .x { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 1.1rem; cursor: pointer; padding: 4px 8px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; padding: 1px 0; }
.k { color: var(--muted); font-size: .82rem; }
.kv b { text-align: right; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 3px 0; }
.cchip { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,255,255,.08); border-radius: 999px; padding: 1px 8px; font-size: .78rem; }
.cchip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; border: 1px solid rgba(255,255,255,.4); }
.actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.good { color: var(--good); margin: 3px 0; font-size: .85rem; }
.bad-t { color: var(--bad); }

.btn { background: var(--accent); color: #1a1a10; border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 700; cursor: pointer; }
.btn.small { padding: 6px 11px; font-size: .85rem; border-radius: 9px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.overlay { position: fixed; inset: 0; background: rgba(2,10,6,.6); z-index: 20; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: calc(var(--site-bar, 0px) + 56px) 10px 16px; touch-action: pan-y; }
.sheet { position: relative; width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px 18px; max-height: calc(100vh - var(--site-bar, 0px) - 72px); overflow-y: auto; touch-action: pan-y; }
.sheet h2 { margin: 0; font-size: 1.15rem; color: var(--accent); }
.sheet h3 { margin: 14px 0 6px; font-size: .95rem; color: var(--accent); }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sheet-head .x { margin-left: auto; background: none; border: 0; font-size: 1.1rem; cursor: pointer; padding: 4px 8px; color: var(--muted); }
.sheet-head .x.back { margin-left: 0; }
.sheet p { margin: 6px 0; }
.hint { color: var(--muted); font-size: .85rem; }
.list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.item { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.05); border-radius: 10px; padding: 8px 10px; margin-top: 4px; }
.list .item { margin-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item.cur { outline: 1px solid var(--accent); }
.item.done { opacity: .6; }
.rk { width: 22px; color: var(--accent); }
.pbar { height: 7px; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; margin: 4px 0 2px; }
.pbar i { display: block; height: 100%; background: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.fld { display: block; margin: 8px 0; font-size: .82rem; color: var(--muted); }
.fld select, .sheet input { display: block; width: 100%; margin-top: 3px; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; color: var(--text); font-size: 1rem; }
.quote { background: rgba(125,220,122,.1); border: 1px solid rgba(125,220,122,.4); border-radius: 10px; padding: 8px 12px; margin: 10px 0; font-size: .9rem; }
.quote.bad { background: rgba(239,123,108,.1); border-color: rgba(239,123,108,.45); }
.loanrow { display: flex; align-items: center; gap: 8px; }
.loanrow b { flex: 1; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 70px; }
.bcol { flex: 1; height: 100%; display: flex; align-items: flex-end; gap: 1px; }
.bcol i { flex: 1; display: block; min-height: 1px; border-radius: 2px 2px 0 0; }
.bcol .inc { background: var(--good); }
.bcol .exp { background: var(--bad); }
label { display: block; font-size: .85rem; color: var(--muted); margin: 8px 0; }
.error { color: var(--bad); min-height: 1.2em; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--site-bar, 0px) + 112px); z-index: 30; background: rgba(0,0,0,.85); border: 1px solid var(--line); border-radius: 12px; padding: 7px 14px; max-width: min(92vw, 460px); text-align: center; pointer-events: none; font-size: .9rem; }
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }

@media (max-width: 640px) {
  .row2 .tx { display: none; }
  .row2 .chip { padding: 4px 11px; }
  .ic { margin-right: 0; }
  .top h1 { display: none; }
  .chip { padding: 4px 9px; font-size: .8rem; min-height: 30px; }
  .tool { width: 56px; height: 50px; }
  .hintbar { bottom: calc(70px + env(safe-area-inset-bottom)); font-size: .75rem; }
  .info { bottom: calc(66px + env(safe-area-inset-bottom)); max-height: 38vh; }
  .tools { justify-content: flex-start; }
}

.tut { position: fixed; left: max(8px, env(safe-area-inset-left)); width: min(430px, calc(100% - 16px)); z-index: 25; background: rgba(20,48,31,.97); border: 2px solid var(--accent); border-radius: 14px; padding: 9px 12px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.55); max-height: 42vh; overflow-y: auto; touch-action: pan-y; }
.tut-head { display: flex; gap: 8px; align-items: center; }
.tut-n { background: var(--accent); color: #1a1a10; border-radius: 999px; font-size: .72rem; font-weight: 800; padding: 1px 8px; }
.tut-title { color: var(--accent); }
.tut-text { margin: 6px 0 8px; font-size: .9rem; }
.tut-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tut-arrow { position: fixed; z-index: 26; transform: translateX(-50%); color: var(--accent); font-size: 1.7rem; line-height: 1; pointer-events: none; text-shadow: 0 2px 6px #000; animation: bob .6s infinite alternate; }
@keyframes bob { to { margin-top: 8px; } }
.hl { outline: 3px solid var(--accent) !important; outline-offset: 2px; animation: hlp .8s infinite alternate; }
@keyframes hlp { to { outline-color: #fff; box-shadow: 0 0 14px var(--accent); } }
.tutnote { background: rgba(242,199,68,.15); border: 1px solid var(--accent); border-radius: 10px; padding: 8px 10px; }
body.tuton .toast { top: auto; bottom: calc(150px + env(safe-area-inset-bottom)); }
@media (max-width: 640px) { .tut { max-height: 36vh; padding: 7px 10px 8px; } .tut-text { font-size: .84rem; margin: 4px 0 6px; } }
