:root {
  --night: #1B2640; --night-2: #27355A; --sky: #5BB8D4; --sky-soft: #D9F2FA;
  --pink: #E0499A; --pink-soft: #FCE6F2; --ink: #1E2533; --muted: #667085; --line: #E4E8EF;
  --bg: #F4F6FA; --card: #fff; --good: #1B8A5A; --good-soft: #E1F5EC; --bad: #C8323C; --bad-soft: #FCE8E9;
  --head: "Montserrat", system-ui, sans-serif; --body: "Inter", system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); }
body { min-height: 100dvh; }
h1, h2, h3 { font-family: var(--head); margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { background: var(--night); color: #fff; padding: calc(14px + var(--safe-t)) 16px 22px; }
.brand { display: flex; align-items: center; gap: 10px; font: 800 19px var(--head); }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.top .label { color: #B9C4DC; font-size: 13px; margin-top: 16px; }
.top .big { font: 800 36px var(--head); font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -.5px; }
.top .sub { color: #B9C4DC; font-size: 14px; margin-top: 4px; }
.backrow { display: flex; align-items: center; gap: 8px; }
.back { color: #fff; min-height: 44px; min-width: 44px; font-size: 26px; text-align: left; }
.top h1 { font-size: 20px; flex: 1; }
.linkbtn { color: var(--sky); font-weight: 600; font-size: 14px; min-height: 44px; }

main { padding: 14px 16px calc(104px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
h2 { font-size: 15px; margin: 22px 2px 8px; }
.card { background: var(--card); border-radius: 14px; border: 1px solid var(--line); padding: 14px; margin-bottom: 10px; }
button.card { display: block; width: 100%; text-align: left; }
.jobhead { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.jobname { font: 700 16px var(--head); }
.jobleft { font: 800 18px var(--head); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ellip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info span:first-child { color: var(--muted); flex: none; }
.info span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.info a { color: #1F7B98; font-weight: 500; }
.docs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.bar { height: 8px; border-radius: 6px; background: #E9EDF4; overflow: hidden; margin: 10px 0 8px; }
.bar i { display: block; height: 100%; background: var(--sky); border-radius: 6px; }
.bar i.over { background: var(--bad); }
.minis { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.minis b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat b { display: block; font: 700 18px var(--head); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.good b { color: var(--good); } .stat.bad b { color: var(--bad); }
.stat.wide { grid-column: 1 / -1; }
.stat.wide:first-child b { font-size: 24px; }
.splitline { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.closedtotal { padding: 0 2px 8px; font-size: 14px; }
.profit { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.profit .minis { align-items: baseline; font-size: 14px; }
.profit b { font: 700 16px var(--head); font-variant-numeric: tabular-nums; }
.profit b.pos { color: var(--good); } .profit b.neg { color: var(--bad); }
.profit .splitline { text-align: right; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.act { background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-height: 48px; font-weight: 600; font-size: 14px; }

.row { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; padding: 11px 2px; border-bottom: 1px solid var(--line); min-height: 56px; }
.row:last-child { border-bottom: 0; }
.dot { flex: 0 0 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.dot.deposit { background: var(--good-soft); color: var(--good); }
.dot.expense { background: var(--pink-soft); color: var(--pink); }
.dot.draw { background: var(--sky-soft); color: #1F7B98; }
.rowmain { flex: 1; min-width: 0; }
.rowmain b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowmain span { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.deposit { color: var(--good); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 0 14px; min-height: 38px; font-size: 14px; font-weight: 500; }
.chip.on { background: var(--night); border-color: var(--night); color: #fff; }

.note { background: #FFF6DF; border: 1px solid #F2DFA8; color: #6B5310; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }
.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 17px; margin-bottom: 6px; }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr 68px 1fr 1fr; padding: 6px 6px calc(6px + var(--safe-b)); align-items: center; }
.tab { min-height: 48px; font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--pink); }
.fab { width: 56px; height: 56px; border-radius: 50%; background: var(--pink); color: #fff; font-size: 30px; font-weight: 500; justify-self: center; margin-top: -22px; box-shadow: 0 6px 16px rgba(224,73,154,.4); }

#sheet:empty { display: none; }
.scrim { position: fixed; inset: 0; z-index: 10; background: rgba(15,22,40,.5); display: flex; align-items: flex-end; justify-content: center; }
.panel { background: #fff; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); }
.panelhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panelhead h2 { margin: 0; font-size: 18px; }
.x { min-width: 44px; min-height: 44px; font-size: 24px; color: var(--muted); text-align: right; }
.pick { display: grid; gap: 10px; }
.pickbtn { display: flex; gap: 12px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-height: 64px; width: 100%; }
.pickbtn b { display: block; font-weight: 600; } .pickbtn span.d { font-size: 13px; color: var(--muted); }

label.f { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.f input, label.f select, label.f textarea { display: block; width: 100%; margin-top: 4px; min-height: 46px; padding: 10px 12px; border: 1px solid #CBD2DE; border-radius: 10px; background: #fff; font-size: 16px; font-weight: 400; color: var(--ink); }
label.f input:focus, label.f select:focus, label.f textarea:focus, .lineedit input:focus { outline: 2px solid var(--sky); outline-offset: 0; border-color: var(--sky); }
.check { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; margin-bottom: 12px; border: 1px solid #CBD2DE; border-radius: 10px; }
.check input { width: 24px; height: 24px; accent-color: var(--pink); flex: none; }
.check b { display: block; font-weight: 600; } .check small { color: var(--muted); font-size: 13px; }
.tag { font-style: normal; font-size: 12px; font-weight: 600; color: #A42A6E; background: var(--pink-soft); border-radius: 6px; padding: 1px 6px; margin-right: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: var(--bad); font-size: 14px; margin: 0 0 10px; min-height: 0; }
.primary { display: block; width: 100%; min-height: 52px; background: var(--pink); color: #fff; font-weight: 700; border-radius: 12px; }
.primary[disabled] { opacity: .6; }
.secondary { display: block; width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; font-weight: 600; margin-top: 8px; background: #fff; }
.danger { color: var(--bad); }
.photobtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.photobtn { position: relative; display: flex; align-items: center; justify-content: center; min-height: 52px; border: 1.5px dashed var(--sky); border-radius: 12px; color: #1F7B98; background: #F1FAFD; font-weight: 600; font-size: 14px; overflow: hidden; }
.photobtn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }
.preview { width: 100%; max-height: 220px; object-fit: contain; background: #F0F2F6; border-radius: 12px; margin-bottom: 8px; display: block; }
.status { font-size: 14px; color: #1F7B98; margin-bottom: 10px; }
.status.warn { color: #6B5310; }
.lineedit { display: grid; grid-template-columns: 1fr 86px 86px 32px; gap: 6px; align-items: center; margin-bottom: 6px; }
.lineedit input { width: 100%; min-width: 0; min-height: 42px; border: 1px solid #CBD2DE; border-radius: 8px; padding: 6px 8px; font-size: 16px; }
.lineedit.h { font-size: 12px; font-weight: 600; color: var(--muted); }
.lineedit button { min-height: 42px; color: var(--muted); font-size: 20px; }

.login { min-height: 100dvh; background: var(--night); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; }
.login > div { max-width: 380px; width: 100%; margin: 0 auto; }
.login img { width: 92px; height: 92px; border-radius: 22px; display: block; margin: 0 auto 14px; }
.login h1 { text-align: center; font-size: 28px; font-weight: 800; margin-bottom: 22px; }
.login label.f { color: #B9C4DC; }
.login .err { color: #FFB4BC; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + var(--safe-b)); z-index: 20; background: var(--night); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; }
.demo { background: var(--sky-soft); color: #14586E; font-size: 13px; text-align: center; padding: 6px 12px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.showpw { display: flex; align-items: center; gap: 8px; color: #B9C4DC; font-size: 14px; margin: -4px 0 12px; min-height: 32px; }
.showpw input { width: 20px; height: 20px; }
