:root{
  --navy:#15243b; --navy2:#1d3150; --gold:#c6a06a; --gold2:#b8892f;
  --cream:#f3eadc; --paper:#fbfaf7; --card:#ffffff; --ink:#23252a; --muted:#7a756b;
  --line:#e7e1d5; --line2:#efeae0;
  --green:#2f7d5b; --green-bg:#e7f1eb; --amber:#b07d1f; --amber-bg:#f6edd8; --red:#b23b2b; --red-bg:#f6e2dd;
  --shadow:0 1px 2px rgba(21,36,59,.06),0 6px 20px rgba(21,36,59,.06);
  --r:14px; --r2:10px;
  --tap:46px;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:'Inter',system-ui,-apple-system,sans-serif;
  background:var(--paper); color:var(--ink);
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
  padding-bottom:calc(72px + env(safe-area-inset-bottom));
  font-size:16px; line-height:1.45;
}
h1,h2,h3,.brandmark,.big{font-family:'Space Grotesk',system-ui,sans-serif; letter-spacing:-.01em}
button,input,select,textarea{font:inherit; color:inherit}
a{color:var(--navy)}

/* Layout */
.topbar{position:sticky; top:0; z-index:20; background:var(--navy); color:#fff; display:flex; align-items:center; gap:10px; padding:14px 16px; padding-top:calc(14px + env(safe-area-inset-top));}
.topbar .brandmark{font-weight:700; font-size:19px; color:#fff}
.topbar .brandmark .dot{color:var(--gold)}
.topbar .sub{margin-left:auto; font-size:12px; color:#a9b4c6; font-family:'Inter'}
.topbar .back{background:rgba(255,255,255,.1); border:0; color:#fff; width:38px; height:38px; border-radius:10px; font-size:20px; line-height:1; cursor:pointer}
.wrap{max-width:680px; margin:0 auto; padding:16px}
.viewtitle{font-size:22px; font-weight:700; margin:2px 0 2px}
.viewsub{color:var(--muted); font-size:13.5px; margin:0 0 16px}

/* Bottom tab bar */
#tabbar{position:fixed; left:0; right:0; bottom:0; z-index:30; display:flex; background:rgba(255,255,255,.96);
  backdrop-filter:saturate(1.4) blur(8px); border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom);}
#tabbar button{flex:1; background:none; border:0; padding:9px 4px; display:flex; flex-direction:column; align-items:center; gap:3px;
  color:var(--muted); cursor:pointer; min-height:var(--tap); font-size:11px; font-weight:600}
#tabbar button .ico{font-size:19px; line-height:1}
#tabbar button.active{color:var(--navy)}
#tabbar button.active .ico{transform:translateY(-1px)}

/* Cards */
.card{background:var(--card); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--shadow); padding:14px 15px; margin-bottom:12px}
.card.tight{padding:12px 13px}
.section-h{font-size:12px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--muted); margin:22px 2px 8px}

/* Client list cards */
.clientcard{display:grid; grid-template-columns:1fr auto; gap:4px 12px; align-items:center; cursor:pointer}
.clientcard .nm{font-family:'Space Grotesk'; font-weight:600; font-size:17px; display:flex; align-items:center; gap:8px}
.clientcard .meta{grid-column:1; color:var(--muted); font-size:12.5px; display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.clientcard .fig{grid-column:2; grid-row:1/3; text-align:right}
.clientcard .fig .net{font-family:'Space Grotesk'; font-weight:700; font-size:18px}
.clientcard .fig .hr{font-size:12px; color:var(--muted)}

/* Badges + dots */
.badge{display:inline-flex; align-items:center; font-size:11px; font-weight:700; letter-spacing:.02em; padding:2px 8px; border-radius:999px; text-transform:capitalize}
.badge.buyer{background:#e8eef6; color:#2c4a75}
.badge.seller{background:var(--cream); color:#8a6a2f}
.status{font-size:11.5px; font-weight:600; color:var(--muted)}
.dot{width:11px; height:11px; border-radius:50%; display:inline-block; flex:0 0 auto}
.dot.green{background:var(--green)} .dot.amber{background:var(--amber)} .dot.red{background:var(--red)} .dot.none{background:#c8c2b5}
.vpill{display:inline-flex; align-items:center; gap:6px; font-weight:700; font-size:12px; padding:3px 10px; border-radius:999px}
.vpill.green{background:var(--green-bg); color:var(--green)} .vpill.amber{background:var(--amber-bg); color:var(--amber)}
.vpill.red{background:var(--red-bg); color:var(--red)} .vpill.none{background:#efece5; color:var(--muted)}

/* Buttons */
.btn{display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:var(--tap); padding:0 18px;
  border-radius:12px; border:1px solid transparent; font-weight:600; font-size:15px; cursor:pointer; background:var(--cream); color:var(--navy)}
.btn.primary{background:var(--navy); color:#fff}
.btn.gold{background:var(--gold); color:#20160a}
.btn.ghost{background:transparent; border-color:var(--line); color:var(--navy)}
.btn.sm{min-height:38px; padding:0 13px; font-size:13.5px; border-radius:10px}
.btn.block{width:100%}
.btn.danger{background:var(--red-bg); color:var(--red)}
.fab{position:fixed; right:16px; bottom:calc(84px + env(safe-area-inset-bottom)); z-index:25; background:var(--navy); color:#fff; border:0;
  height:54px; padding:0 22px; border-radius:999px; font-weight:700; font-size:16px; box-shadow:0 8px 24px rgba(21,36,59,.28); cursor:pointer}

/* Forms */
label.fld{display:block; margin-bottom:12px}
label.fld .lbl{display:block; font-size:12px; font-weight:600; color:var(--muted); margin-bottom:5px}
.inp,select.inp,textarea.inp{width:100%; min-height:var(--tap); padding:10px 12px; border:1px solid var(--line); border-radius:11px; background:#fff; font-size:16px}
.inp:focus{outline:2px solid var(--gold); outline-offset:0; border-color:var(--gold)}
textarea.inp{min-height:70px; resize:vertical}
.row{display:flex; gap:10px} .row > *{flex:1}
.inline-inp{border:1px dashed var(--line); background:#fff; border-radius:9px; padding:6px 9px; min-height:38px; font-size:15px; width:120px; text-align:right}
.inline-inp:focus{outline:2px solid var(--gold); border-color:var(--gold); border-style:solid}

/* Toggle */
.toggle{display:inline-flex; align-items:center; gap:9px; cursor:pointer; user-select:none}
.toggle input{position:absolute; opacity:0; pointer-events:none}
.track{width:44px; height:26px; border-radius:999px; background:#d8d2c6; position:relative; transition:.15s}
.track::after{content:''; position:absolute; top:3px; left:3px; width:20px; height:20px; border-radius:50%; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.2); transition:.15s}
.toggle input:checked + .track{background:var(--green)}
.toggle input:checked + .track::after{transform:translateX(18px)}

/* Segmented */
.seg{display:inline-flex; background:var(--cream); border-radius:11px; padding:3px; gap:2px}
.seg button{border:0; background:none; padding:8px 16px; border-radius:9px; font-weight:600; font-size:14px; color:var(--muted); cursor:pointer; min-height:40px}
.seg button.on{background:#fff; color:var(--navy); box-shadow:var(--shadow)}

/* Ledger */
.ledger{margin:4px 0}
.ledger .ln{display:flex; justify-content:space-between; align-items:baseline; padding:8px 0; border-bottom:1px solid var(--line2); gap:12px}
.ledger .ln .lab{color:var(--ink)}
.ledger .ln .amt{font-family:'Space Grotesk'; font-variant-numeric:tabular-nums; white-space:nowrap}
.ledger .ln.deduction .amt{color:var(--red)}
.ledger .ln.total .lab,.ledger .ln.total .amt{font-weight:600}
.ledger .ln.subtotal{border-top:1px solid var(--line); border-bottom:2px solid var(--line)}
.ledger .ln.subtotal .lab,.ledger .ln.subtotal .amt{font-weight:600}
.ledger .ln.net{border-bottom:0; padding-top:12px}
.ledger .ln.net .lab{font-weight:700; font-size:16px}
.ledger .ln.net .amt{font-weight:700; font-size:22px}
.ledger .ln.net.pos .amt{color:var(--green)} .ledger .ln.net.neg .amt{color:var(--red)}

.verdictbar{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; padding:12px 14px; border-radius:12px; background:var(--cream)}
.verdictbar .hourly{font-family:'Space Grotesk'; font-weight:700; font-size:20px}
.verdictbar .hourly small{font-weight:500; font-size:12px; color:var(--muted)}

.chips{display:flex; flex-wrap:wrap; gap:7px; margin:6px 0}
.chip{border:1px solid var(--line); background:#fff; border-radius:999px; padding:7px 12px; font-size:13px; font-weight:600; cursor:pointer; min-height:38px; color:var(--navy)}
.chip:active{background:var(--cream)}

.listrow{display:flex; justify-content:space-between; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--line2)}
.listrow:last-child{border-bottom:0}
.listrow .sub{font-size:12px; color:var(--muted)}
.iconbtn{background:none; border:0; color:var(--muted); cursor:pointer; font-size:16px; padding:6px; min-height:38px; min-width:38px}

.timer{display:flex; align-items:center; gap:12px}
.timer .clock{font-family:'Space Grotesk'; font-weight:700; font-size:30px; font-variant-numeric:tabular-nums; letter-spacing:.02em}

.saved{position:fixed; left:50%; transform:translateX(-50%); bottom:calc(86px + env(safe-area-inset-bottom)); z-index:40;
  background:var(--navy); color:#fff; padding:8px 16px; border-radius:999px; font-size:13px; font-weight:600; opacity:0; transition:opacity .2s; pointer-events:none}
.saved.show{opacity:1}

/* Sheet */
.sheet-backdrop{position:fixed; inset:0; z-index:50; background:rgba(21,36,59,.35); display:flex; align-items:flex-end; justify-content:center}
.sheet{background:var(--paper); width:100%; max-width:680px; border-radius:20px 20px 0 0; padding:18px 18px calc(20px + env(safe-area-inset-bottom)); max-height:92vh; overflow:auto}
.sheet h3{margin:2px 0 14px; font-size:19px}
.sheet .grab{width:40px; height:4px; background:var(--line); border-radius:999px; margin:0 auto 14px}

.statgrid{display:grid; grid-template-columns:1fr 1fr; gap:12px}
.stat{background:#fff; border:1px solid var(--line); border-radius:12px; padding:12px}
.stat .k{font-size:11.5px; color:var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.05em}
.stat .v{font-family:'Space Grotesk'; font-weight:700; font-size:22px; margin-top:3px}
.stat .vc{display:flex; gap:8px; font-size:12px; margin-top:6px}

table.tbl{width:100%; border-collapse:collapse; font-size:13.5px}
table.tbl th{text-align:left; color:var(--muted); font-weight:600; font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; padding:8px 6px; border-bottom:1px solid var(--line); cursor:pointer; white-space:nowrap}
table.tbl td{padding:9px 6px; border-bottom:1px solid var(--line2); font-variant-numeric:tabular-nums}
table.tbl td.num,table.tbl th.num{text-align:right}

.empty{text-align:center; color:var(--muted); padding:40px 16px}
.empty .big{font-size:18px; color:var(--ink); margin-bottom:6px}
.headline{background:var(--navy); color:#fff; border-radius:14px; padding:16px}
.headline .k{color:#a9b4c6; font-size:12px; font-weight:600; text-transform:uppercase; letter-spacing:.05em}
.headline .v{font-family:'Space Grotesk'; font-weight:700; font-size:30px; margin-top:4px}
.headline .v small{font-size:13px; color:#a9b4c6; font-weight:500}
.muted{color:var(--muted)} .small{font-size:12.5px}
.err{background:var(--red-bg); color:var(--red); padding:12px 14px; border-radius:12px; font-size:14px; margin-bottom:12px}
.hr{height:1px; background:var(--line); margin:14px 0}
