/* PesaPlan app styles */
:root {
  --green: #0b6b3a; --green-d: #064a28; --green-l: #e3f1e8; --gold: #d9a21b; --gold-l: #fbf1d4; --bad: #b3402a; --bad-l: #f8e3de; --warn: #b7791f;
  --bg: #f4f1e8; --card: #fffdf7; --ink: #17261e; --mute: #5d6b62; --line: #e3ddcc; --shadow: 0 1px 2px rgba(20,40,30,.06), 0 8px 24px rgba(20,40,30,.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --r: 16px;
}
:root[data-theme="dark"] { --green: #3fb577; --green-d: #2c8f5b; --green-l: #14301f; --gold: #e8b73a; --gold-l: #3a2f12; --bad: #ef7a62; --bad-l: #3a1e18; --warn: #e0a64a; --bg: #0e1612; --card: #16211b; --ink: #e8efe9; --mute: #9aaba1; --line: #26352c; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3); }
:root[data-theme="sepia"] { --green: #6b4f1d; --green-d: #4e3813; --green-l: #efe2c6; --gold: #a8741a; --gold-l: #f2e3bd; --bad: #9c3a22; --bad-l: #f0d9cd; --bg: #f1e6cf; --card: #f8eed8; --ink: #3b2f1c; --mute: #7a6a4e; --line: #dccaa3; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { margin: 0; font: 16px/1.45 var(--sans); background: var(--bg); color: var(--ink); min-height: 100vh; min-height: 100dvh; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; touch-action: manipulation; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
input, textarea, select, .sel, .sel * { -webkit-user-select: text; user-select: text; }
body.is-auth { overflow: hidden; }
body.has-modal { overflow: hidden; }
h1, h2, h3 { font-family: var(--serif); letter-spacing: -.01em; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }
.pre { white-space: pre-wrap; margin: 0; }
.mute { color: var(--mute); } .small { font-size: .85rem; } .right { text-align: right; } .center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .gap { height: 14px; }
.hidden, [hidden] { display: none !important; }

/* shell */
#shell { max-width: 760px; margin: 0 auto; padding: 0 0 calc(150px + env(safe-area-inset-bottom)); min-height: 100vh; min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.25rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 12px; cursor: pointer; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; }
.icon-btn:hover { background: var(--green-l); }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }
:root[data-theme="dark"] .chip.on { color: #06150d; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 14px 10px; scrollbar-width: none; } .chips::-webkit-scrollbar { display: none; }
main { padding: 12px 14px 0; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.card, .chips { min-width: 0; max-width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 1.05rem; margin-bottom: 10px; } .card h3 { font-size: .95rem; margin: 12px 0 6px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; } .card-head h2 { margin: 0; flex: 1; }
.hero { background: linear-gradient(135deg, var(--green-d), var(--green)); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, rgba(255,215,100,.55), rgba(255,215,100,0) 70%); }
.hero .big { font-family: var(--serif); font-size: 2.3rem; line-height: 1.1; margin: 2px 0 4px; }
.hero .mute { color: rgba(255,255,255,.78); }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--green); border-radius: 99px; } .meter.warn i { background: var(--warn); } .meter.over i { background: var(--bad); }
.hero .meter { background: rgba(255,255,255,.25); } .hero .meter i { background: var(--gold); }

/* bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
.nav-in { display: flex; width: 100%; max-width: 760px; }
.nav a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; font-size: .68rem; color: var(--mute); text-decoration: none; }
.nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a.on { color: var(--green); font-weight: 600; } .nav a.on svg { stroke-width: 2.4; }
.fab { position: fixed; right: max(18px, calc(50vw - 362px)); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 25; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--gold); color: #2a1d00; box-shadow: 0 6px 18px rgba(0,0,0,.28); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.fab svg { width: 28px; height: 28px; }

/* lists */
.day { font-size: .8rem; color: var(--mute); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .06em; }
.item { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; cursor: pointer; } .item:last-child { border-bottom: 0; }
.item .mid { flex: 1 1 0; min-width: 0; } .item .amt { flex: none; text-align: right; }
.badge { width: 40px; height: 40px; border-radius: 12px; background: var(--green-l); color: var(--green-d); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .95rem; flex: none; }
:root[data-theme="dark"] .badge { color: var(--green); }
.item .t { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; line-height: 1.3; } .item .s { font-size: .8rem; color: var(--mute); overflow-wrap: anywhere; margin-top: 2px; }
.amt { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; } .amt small { display: block; font-weight: 400; color: var(--mute); font-size: .72rem; }
.tag { display: inline-block; font-size: .7rem; padding: 1px 8px; border-radius: 99px; background: var(--gold-l); color: var(--warn); margin-left: 6px; }
.tag.bad { background: var(--bad-l); color: var(--bad); } .tag.ok { background: var(--green-l); color: var(--green-d); }
.empty { text-align: center; padding: 28px 10px; color: var(--mute); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; } @media (min-width: 560px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--green-l); border-radius: 14px; padding: 12px; } .kpi b { display: block; font-family: var(--serif); font-size: 1.25rem; } .kpi span { font-size: .75rem; color: var(--mute); }
table.t { width: 100%; border-collapse: collapse; font-size: .88rem; } table.t th, table.t td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; } table.t th:first-child, table.t td:first-child { text-align: left; } table.t th { font-size: .72rem; color: var(--mute); text-transform: uppercase; letter-spacing: .05em; }
.legend { display: grid; gap: 6px; margin-top: 8px; } .legend div { display: flex; gap: 8px; align-items: center; font-size: .88rem; } .legend i { width: 12px; height: 12px; border-radius: 4px; flex: none; } .legend span:last-child { margin-left: auto; font-variant-numeric: tabular-nums; }
.donut { width: 190px; height: 190px; display: block; margin: 0 auto; } .donut-top { font: 700 15px var(--serif); fill: var(--ink); } .donut-sub { font: 11px var(--sans); fill: var(--mute); } .ax { font: 10px var(--sans); fill: var(--mute); } .bars { width: 100%; height: auto; }
.flow-row { margin: 10px 0; } .flow-lab { font-weight: 600; font-size: .85rem; margin-bottom: 3px; } .flow-line { position: relative; height: 20px; background: var(--line); border-radius: 6px; margin-bottom: 4px; overflow: hidden; } .flow-line i { position: absolute; inset: 0 auto 0 0; opacity: .85; } .flow-line span { position: relative; font-size: .72rem; padding-left: 8px; line-height: 20px; color: var(--ink); }

/* forms */
.field { display: grid; gap: 4px; margin-bottom: 12px; } .field .lbl { font-size: .8rem; color: var(--mute); font-weight: 600; } .hint { color: var(--mute); }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--green); }
.btn { border: 1px solid var(--line); background: var(--card); padding: 11px 16px; border-radius: 12px; cursor: pointer; font-weight: 600; min-height: 44px; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; } :root[data-theme="dark"] .btn.primary { color: #06150d; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2a1d00; } .btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; } .btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: wait; } .btn.block { width: 100%; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); } .seg-b { flex: 1; border: 0; background: none; padding: 10px 6px; cursor: pointer; font-size: .9rem; } .seg-b.on { background: var(--green); color: #fff; font-weight: 600; } :root[data-theme="dark"] .seg-b.on { color: #06150d; }
.form-err { background: var(--bad-l); color: var(--bad); padding: 10px 14px; margin: 0 16px 8px; border-radius: 10px; font-size: .9rem; }
.switch { display: flex; align-items: center; gap: 10px; padding: 8px 0; } .switch label { flex: 1; }

/* modal & toast */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(8,16,12,.55); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .15s; } .modal-back.show { opacity: 1; }
.modal { background: var(--card); width: 100%; max-width: 520px; max-height: 92vh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; transform: translateY(16px); transition: transform .18s; } .modal-back.show .modal { transform: none; } .modal.wide { max-width: 760px; }
@media (min-width: 640px) { .modal-back { align-items: center; } .modal { border-radius: 22px; } }
.modal-head { display: flex; align-items: center; padding: 14px 16px 6px; } .modal-head h2 { flex: 1; font-size: 1.15rem; }
.modal-body { padding: 8px 16px 8px; overflow-y: auto; } .modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 10px 16px 16px; } .modal-actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; z-index: 200; opacity: 0; pointer-events: none; transition: all .2s; max-width: 90vw; font-size: .92rem; } .toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.err { background: var(--bad); color: #fff; }

/* auth + lock: the whole screen scrolls, the panel is centred when it fits and starts at the top when the keyboard squeezes it (no jumping) */
.auth { position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; color: #fff; background: var(--wp, linear-gradient(160deg, #064a28, #0b6b3a 55%, #d9a21b)); }
.auth-in { min-height: 100%; display: flex; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.auth .panel { width: 100%; max-width: 380px; margin: auto; background: rgba(10,25,17,.62); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,.14); border-radius: 24px; padding: 14px 20px 22px; }
.auth-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-height: 36px; }
.lang { display: flex; gap: 6px; } .lang .chip { min-width: 44px; min-height: 36px; background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.3); } .lang .chip.on { background: var(--gold); color: #2a1d00; border-color: var(--gold); }
.auth h1 { font-size: 1.7rem; margin-bottom: 4px; } .auth p { margin: 0 0 14px; color: rgba(255,255,255,.8); }
.auth .logo { width: 72px; height: 72px; border-radius: 20px; display: block; margin: 0 auto 12px; box-shadow: 0 8px 24px rgba(0,0,0,.35); -webkit-user-drag: none; }
.auth input, .auth select { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; } .auth input::placeholder { color: rgba(255,255,255,.55); } .auth option { color: #111; }
.auth .field .lbl { color: rgba(255,255,255,.8); }
.auth .btn { border-color: rgba(255,255,255,.3); color: #fff; background: rgba(255,255,255,.12); } .auth .btn.primary { background: var(--gold); border-color: var(--gold); color: #2a1d00; } .auth .btn.ghost { background: transparent; border-color: rgba(255,255,255,.35); }
.btnrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; } .btnrow .btn { padding: 10px 8px; font-size: .92rem; }
.auth .form-err { margin: 0 0 12px; } .form-err.note { background: rgba(255,255,255,.14); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.1); border-radius: 14px; padding: 8px 10px; margin-bottom: 8px; } .who .badge { width: 34px; height: 34px; border-radius: 10px; background: var(--gold); color: #2a1d00; } .who .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 14px 0; min-height: 18px; } .dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); transition: background .1s; } .dots i.on { background: #ffd979; border-color: #ffd979; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 12px; } .pad button { height: 58px; border-radius: 16px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.1); color: #fff; font-size: 1.4rem; cursor: pointer; transition: transform .06s, background .1s; } .pad button:active { background: rgba(255,255,255,.28); transform: scale(.95); } .pad .sp { visibility: hidden; }
.padwrap.shake { animation: shake .32s; } @keyframes shake { 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }

/* network dot: green online, orange offline */
.net-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; background: #9aaba1; margin: 0 4px; }
.net-dot.on { background: #27c46b; box-shadow: 0 0 0 3px rgba(39,196,107,.22); }
.net-dot.off { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.28); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(245,158,11,.05); } }

/* misc */
.paywall-box { background: var(--gold-l); border: 1px solid var(--gold); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; white-space: pre-wrap; }
.pro-badge { background: var(--gold); color: #2a1d00; border-radius: 99px; font-size: .7rem; padding: 2px 9px; font-weight: 700; }
.sync-note { background: var(--gold-l); color: var(--warn); padding: 8px 14px; font-size: .85rem; text-align: center; }
.msg { padding: 10px 12px; border-radius: 12px; margin: 6px 0; font-size: .92rem; white-space: pre-wrap; } .msg.me { background: var(--green-l); margin-left: 24px; } .msg.ai { background: var(--bg); border: 1px solid var(--line); margin-right: 24px; }
.warn-box { background: var(--gold-l); color: var(--ink); border-left: 4px solid var(--gold); padding: 10px 12px; border-radius: 8px; font-size: .9rem; margin: 6px 0; } .warn-box.bad { background: var(--bad-l); border-color: var(--bad); }
.cat-row { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); } .cat-row input { min-height: 38px; padding: 7px 10px; }
@media (max-width: 400px) { .cat-row { grid-template-columns: 1fr 90px auto; } }
.install-bar { display: flex; gap: 10px; align-items: center; background: var(--green-l); border-radius: 14px; padding: 10px 12px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* app feel */
body.kbd .nav, body.kbd .fab { display: none; }
#view.page-in { animation: pagein .18s ease-out; } @keyframes pagein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.btn:active, .chip:active, .icon-btn:active, .item:active, .nav a:active, .fab:active { transform: scale(.97); transition: transform .06s; }
.item:active { background: var(--green-l); }
.nav a.on { position: relative; } .nav a.on::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--green); }
.sync-note { position: sticky; top: 0; z-index: 15; }
.tag.warn { background: #fde7c3; color: #8a5a00; }
.donut-wrap { display: grid; place-items: center; padding: 8px 0 4px; }
.donut { width: min(250px, 72vw); height: auto; filter: drop-shadow(0 6px 14px rgba(11,107,58,.18)); }
.donut path { stroke: var(--card); stroke-width: 1.5; }
.legend div { min-width: 0; } .lg-name { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .lg-val { flex: none; white-space: nowrap; margin-left: 8px; }
.sumrow { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; min-width: 0; } .sumrow span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .sumrow b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sumrow.total { border-bottom: 0; font-size: 1.05rem; } .link-row:active { background: var(--green-l); }
.card.tight { padding: 12px; } a.card { display: block; color: inherit; text-decoration: none; } .proj-card:active, .link-card:active { transform: scale(.985); }
.link-card { display: flex !important; align-items: center; gap: 12px; }
.proj-pill { display: inline-flex; align-items: center; gap: 4px; background: var(--green-l); color: var(--green-d); border-radius: 99px; padding: 4px 12px; font-size: .85rem; font-weight: 600; margin-bottom: 10px; }
.actions-row .btn { padding: 10px 14px; }
.gstep { display: flex; gap: 12px; margin: 14px 0; } .gnum { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; } .gbody { min-width: 0; flex: 1; } .gbody p { margin: 4px 0; }
textarea.code { font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; white-space: pre; overflow: auto; }
.sheet-handle { display: none; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 0; }
@media (max-width: 639px) { .sheet-handle { display: block; } }
.modal { max-height: 92vh; max-height: 92dvh; } .modal-actions { position: sticky; bottom: 0; background: var(--card); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.modal-back.show .modal { animation: sheetup .22s ease-out; } @keyframes sheetup { from { transform: translateY(40px); } to { transform: none; } }
.actions-row .btn.primary { flex: 1 1 100%; }
.actions-row .btn { white-space: nowrap; }
