:root { --navy:#003499; --navy2:#1a4dbb; --red:#cc0001; --bg:#f4f6fa; --card:#fff; --line:#e1e5ee; --text:#14192b; --muted:#667085; --green:#0f7b3f; --radius:12px; }
* { box-sizing:border-box; }
html,body { margin:0; background:var(--bg); color:var(--text); font:15px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; -webkit-text-size-adjust:100%; }
a { color:var(--navy2); text-decoration:none; }
.hidden { display:none !important; }
.muted { color:var(--muted); } .small { font-size:12.5px; } .error { color:var(--red); min-height:1em; }
.green { color:var(--green); } .red { color:var(--red); }

.topbar { position:sticky; top:0; z-index:20; display:flex; align-items:center; justify-content:space-between; gap:8px;
  background:var(--navy); color:#fff; padding:calc(env(safe-area-inset-top) + 8px) 14px 8px; border-bottom:3px solid var(--red); }
.brand { display:flex; align-items:center; gap:8px; color:#fff; font-weight:700; letter-spacing:.2px; }
.brand img { height:38px; background:#fff; border-radius:7px; padding:3px 5px; }
#topActions { display:flex; gap:6px; }
#topActions .btn { padding:7px 11px; font-size:13.5px; }
main { max-width:900px; margin:0 auto; padding:12px 12px calc(84px + env(safe-area-inset-bottom)); }

.tabbar { position:fixed; bottom:0; left:0; right:0; z-index:20; display:flex; background:#fff; border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom); }
.tabbar a { flex:1; display:flex; flex-direction:column; align-items:center; gap:2px; padding:7px 0 8px; font-size:11.5px; color:var(--muted); }
.tabbar svg { width:24px; height:24px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.tabbar a.active { color:var(--navy); font-weight:600; }
.tabbar a.tab-new svg { background:var(--red); color:#fff; border-radius:50%; padding:3px; }

.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; border:1px solid var(--line); background:#fff; color:var(--text);
  padding:10px 14px; border-radius:10px; font:inherit; font-weight:600; cursor:pointer; white-space:nowrap; }
.btn.primary { background:var(--navy); border-color:var(--navy); color:#fff; }
.btn.red { background:var(--red); border-color:var(--red); color:#fff; }
.btn.ghost { background:transparent; border-color:transparent; color:var(--navy2); }
.btn.light { background:rgba(255,255,255,.14); border-color:rgba(255,255,255,.3); color:#fff; }
.btn.block { width:100%; }
.btn.sm { padding:6px 10px; font-size:13px; }
.btn:disabled { opacity:.5; }

input,select,textarea { width:100%; font:inherit; font-size:16px; padding:10px 11px; border:1px solid #cfd5e1; border-radius:10px; background:#fff; color:var(--text); }
textarea { min-height:70px; resize:vertical; }
input:focus,select:focus,textarea:focus { outline:2px solid #9db4ea; border-color:var(--navy2); }
label { display:block; font-size:12.5px; font-weight:600; color:var(--muted); margin:10px 0 4px; }
.row { display:flex; gap:10px; } .row > * { flex:1; min-width:0; }
.card { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:14px; margin-bottom:12px; }
.card h3 { margin:0 0 6px; font-size:14px; color:var(--navy); text-transform:uppercase; letter-spacing:.5px; }
h2 { margin:6px 2px 10px; font-size:20px; }

.searchbar { position:sticky; top:58px; z-index:10; background:var(--bg); padding:4px 0 8px; }
.searchbar input { padding-left:38px; background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center/18px; }
.chips { display:flex; gap:6px; overflow-x:auto; padding:8px 0 2px; scrollbar-width:none; }
.chips::-webkit-scrollbar { display:none; }
.chip { flex:none; border:1px solid var(--line); background:#fff; border-radius:999px; padding:6px 12px; font-size:13.5px; cursor:pointer; color:var(--text); }
.chip.on { background:var(--navy); color:#fff; border-color:var(--navy); }
.filter-row { display:flex; gap:8px; margin-top:8px; } .filter-row select { font-size:14px; padding:8px; }

.list { background:#fff; border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; }
.item { display:flex; gap:10px; align-items:flex-start; padding:11px 12px; border-bottom:1px solid var(--line); color:var(--text); }
.item:last-child { border-bottom:0; }
.item .main { flex:1; min-width:0; }
.item .code { font:600 12.5px ui-monospace,SFMono-Regular,Menlo,monospace; color:var(--navy2); }
.item .name { font-size:14px; margin:2px 0; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.item .cat { font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.item .price { text-align:right; flex:none; }
.item .price b { display:block; font-size:15px; }
.item .price span { font-size:11.5px; color:var(--muted); display:block; }
.badge { display:inline-block; font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.4px; padding:2px 6px; border-radius:6px; background:#e8eefc; color:var(--navy); vertical-align:middle; }
.badge.part { background:#fdecef; color:var(--red); } .badge.cfp { background:#fff4d6; color:#8a5a00; }
.badge.draft { background:#eef0f4; color:#475467; } .badge.sent { background:#e8eefc; color:var(--navy); } .badge.accepted { background:#e3f6ea; color:var(--green); } .badge.declined { background:#fdecef; color:var(--red); }
.count { margin:4px 2px 8px; font-size:13px; color:var(--muted); }
.more { margin:12px 0; }

.kv { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:10px 0; }
.kv div { background:var(--bg); border-radius:10px; padding:8px 10px; } .kv b { display:block; font-size:16px; } .kv span { font-size:11.5px; color:var(--muted); }
.desc { white-space:pre-wrap; font-size:13.5px; color:#344054; }

/* Estimate builder */
.line { border:1px solid var(--line); border-radius:10px; padding:10px; margin-bottom:8px; background:#fff; }
.line-head { display:flex; gap:8px; align-items:flex-start; }
.line-head .main { flex:1; min-width:0; }
.line-title { font-weight:600; font-size:14px; }
.line-sub { font-size:12px; color:var(--muted); }
.line-amt { text-align:right; font-weight:700; }
.line-grid { display:grid; grid-template-columns:1fr 1.3fr 1fr; gap:8px; margin-top:8px; }
.line-grid label { margin:0 0 3px; }
.line-grid input { padding:8px; }
.line-foot { display:flex; justify-content:space-between; align-items:center; margin-top:8px; font-size:13px; }
.toggle { display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--text); margin:0; font-weight:500; }
.toggle input { width:18px; height:18px; }
.add-row { display:flex; gap:8px; flex-wrap:wrap; }
.add-row .btn { flex:1; }
.quick { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.totals { width:100%; border-collapse:collapse; } .totals td { padding:5px 0; } .totals td:last-child { text-align:right; font-variant-numeric:tabular-nums; }
.totals tr.grand td { border-top:2px solid var(--navy); font-size:18px; font-weight:800; color:var(--navy); padding-top:8px; }
.owner { background:#fffaf0; border:1px dashed #e0b45a; }
.owner h3 { color:#8a5a00; }
.sticky-save { position:sticky; bottom:calc(64px + env(safe-area-inset-bottom)); display:flex; gap:8px; padding:8px 0; background:linear-gradient(transparent, var(--bg) 30%); }
.sticky-save .btn { flex:1; }

/* Bottom sheet */
.sheet { position:fixed; inset:0; z-index:50; background:rgba(10,20,40,.45); display:flex; align-items:flex-end; justify-content:center; }
.sheet-panel { background:var(--bg); width:100%; max-width:900px; max-height:92vh; border-radius:16px 16px 0 0; display:flex; flex-direction:column; padding-bottom:env(safe-area-inset-bottom); }
.sheet-head { display:flex; align-items:center; justify-content:space-between; padding:12px 14px 6px; }
.sheet-head h3 { margin:0; font-size:17px; }
.sheet-body { overflow-y:auto; padding:0 12px 16px; }

.toast { position:fixed; left:50%; bottom:90px; transform:translateX(-50%) translateY(20px); background:#111827; color:#fff; padding:10px 16px; border-radius:10px; opacity:0; transition:.2s; z-index:60; font-size:14px; pointer-events:none; }
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }

/* Client view (classic) */
.doc { background:#fff; border:1px solid var(--line); border-radius:6px; padding:22px 18px; font-size:13px; color:#111; }
.doc-head { display:flex; justify-content:space-between; gap:12px; border-bottom:3px solid var(--navy); padding-bottom:12px; flex-wrap:wrap; }
.doc-biz { display:flex; gap:10px; align-items:flex-start; }
.doc-biz img { width:84px; }
.doc-biz b { color:var(--navy); font-size:15px; display:block; }
.doc-biz div { font-size:11.5px; color:#555; }
.doc-title { text-align:right; } .doc-title h1 { margin:0; color:var(--red); font-size:26px; letter-spacing:1px; }
.doc-title table { margin-left:auto; font-size:12px; } .doc-title td:first-child { color:#666; padding-right:10px; text-align:right; } .doc-title td:last-child { font-weight:700; text-align:right; }
.doc-parties { display:flex; gap:16px; margin:14px 0; flex-wrap:wrap; } .doc-parties > div { flex:1; min-width:140px; white-space:pre-line; }
.doc-parties h4, .doc h4 { margin:0 0 3px; font-size:11px; color:var(--navy); letter-spacing:.6px; }
.doc table.lines { width:100%; border-collapse:collapse; }
.doc table.lines th { background:var(--navy); color:#fff; font-size:11.5px; padding:7px 6px; text-align:right; }
.doc table.lines th:first-child, .doc table.lines td:first-child { text-align:left; }
.doc table.lines td { padding:7px 6px; vertical-align:top; text-align:right; font-variant-numeric:tabular-nums; }
.doc table.lines tr:nth-child(even) td { background:#eef1f7; }
.doc table.lines td small { display:block; color:#555; font-size:11px; white-space:pre-wrap; }
.doc .doc-totals { margin:10px 0 0 auto; width:min(100%, 280px); border-collapse:collapse; }
.doc .doc-totals td { padding:4px 0; text-align:right; } .doc .doc-totals td:first-child { color:#555; padding-right:12px; }
.doc .doc-totals tr.grand td { background:var(--navy); color:#fff; font-weight:800; font-size:15px; padding:8px; }
.doc .doc-notes { margin-top:16px; white-space:pre-wrap; font-size:12px; }
.doc .sign { display:flex; gap:30px; margin-top:28px; font-size:11px; color:#666; } .doc .sign div { border-top:1px solid #888; padding-top:3px; flex:1; }

.login-body { min-height:100vh; display:flex; align-items:center; justify-content:center; background:linear-gradient(160deg,var(--navy),#001a4d 70%); padding:20px; }
.login-card { background:#fff; border-radius:16px; padding:26px 22px; width:100%; max-width:360px; text-align:center; border-top:5px solid var(--red); }
.login-logo { width:150px; } .login-card h1 { font-size:20px; margin:8px 0 0; color:var(--navy); }
.login-body:not(.pay-body) .login-card .login-logo { display:block; margin:0 auto 10px; }
.login-body:not(.pay-body) .login-card .muted { margin:0 0 2px; }
.login-card input { margin:16px 0 12px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }


@media (min-width:700px) { main { padding-top:18px; } .line-grid { grid-template-columns:repeat(3,1fr); } }
@media print {
  .topbar,.tabbar,.no-print,.toast { display:none !important; }
  body,main { background:#fff; padding:0; margin:0; max-width:none; }
  .doc { border:0; padding:0; }
}
@media (max-width:520px) { .doc { padding:16px 12px; } .doc table.lines td, .doc table.lines th { padding:6px 4px; font-size:11.5px; } .doc table.lines td small { font-size:10.5px; } }
/* step 2 */
.badge.partial { background:#fff4d6; color:#8a5a00; } .badge.paid { background:#e3f6ea; color:var(--green); }
.badge.overdue { background:var(--red); color:#fff; } .badge.invoiced { background:#e6f0ff; color:#1a4dbb; }
.badge.pending { background:#fff4d6; color:#8a5a00; }
.stats { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:12px; }
.stat { background:#fff; border:1px solid var(--line); border-radius:var(--radius); padding:12px; color:var(--text); display:block; border-left:4px solid var(--navy); }
.stat span { font-size:12px; color:var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.4px; }
.stat b { display:block; font-size:21px; margin:2px 0; font-variant-numeric:tabular-nums; }
.stat small { font-size:12px; color:var(--muted); }
.stat.bad { border-left-color:var(--red); } .stat.bad b { color:var(--red); } .stat.good { border-left-color:var(--green); } .stat.good b { color:var(--green); }
.quick-actions { display:flex; gap:8px; margin-bottom:6px; } .quick-actions .btn { flex:1; }
h3.sec { display:flex; justify-content:space-between; align-items:center; font-size:13px; text-transform:uppercase; letter-spacing:.5px; color:var(--navy); margin:16px 2px 8px; }
h3.sec a { font-size:13px; text-transform:none; letter-spacing:0; }
.paybox b.big { display:block; font-size:22px; }
.doc .doc-totals tr.balance td { border:2px solid var(--red); color:var(--red); font-weight:800; font-size:14px; padding:6px 8px; }
.btn.red.ghost { background:transparent; border-color:transparent; color:var(--red); }
.tabbar a { font-size:11px; }

/* Public pay pages */
.test-banner { position:sticky; top:0; width:100%; background:#fff4d6; color:#8a5a00; font-size:13px; font-weight:700; text-align:center; padding:8px 12px; letter-spacing:.3px; z-index:5; }
.pay-body { flex-direction:column; justify-content:flex-start; padding:0 16px 32px; }
.pay-card { margin:24px auto; text-align:left; max-width:420px; }
.pay-card .login-logo { display:block; margin:0 auto 6px; }
.pay-card h1 { text-align:center; }
.pay-card .muted.small { text-align:center; }
.pay-other { margin-top:18px; padding-top:14px; border-top:1px solid #e3e7ef; text-align:left; }
.pay-other h3 { margin:0 0 8px; font-size:11px; letter-spacing:.06em; color:#003499; }
.pay-other-body { white-space:pre-wrap; font-size:13px; color:#222; line-height:1.45; margin:0 0 10px; }
.pay-zelle { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin:0 0 10px; }
.pay-zelle-text { flex:1; white-space:pre-wrap; font-size:13px; color:#222; line-height:1.45; }
.pay-zelle-qr { margin:0; text-align:center; flex:0 0 auto; }
.pay-zelle-qr img { display:block; width:96px; height:96px; background:#fff; }
.pay-zelle-qr figcaption { font-size:10px; color:#555; margin-top:4px; max-width:96px; line-height:1.25; }

.pay-kicker { margin:18px 0 6px; color:var(--navy); font-size:13px; text-transform:uppercase; letter-spacing:.6px; font-weight:800; }
.pay-client { margin:0 0 10px; font-weight:600; }
.pay-meta, .pay-lines, .pay-totals { width:100%; border-collapse:collapse; margin:0 0 12px; font-size:13.5px; }
.pay-meta td { padding:2px 0; color:var(--muted); }
.pay-meta td:last-child { text-align:right; color:var(--text); }
.pay-lines td { padding:4px 0; border-bottom:1px solid var(--line); }
.pay-lines td.right, .pay-totals td:last-child { text-align:right; }
.pay-totals .grand td { font-weight:800; font-size:16px; color:var(--navy); border-top:2px solid var(--navy); padding-top:8px; }
.pay-paid { margin-top:16px; padding:12px; background:#e3f6ea; color:var(--green); border-radius:10px; font-weight:700; text-align:center; }
.pay-pending { margin-top:16px; padding:12px; background:#fff4d6; color:#8a5a00; border-radius:10px; }

.card.notice { background:#fff8e8; border-color:#e8c56b; }
.card.notice b { color:#6a4a00; }

.file-list { border:1px solid var(--line); border-radius:10px; overflow:hidden; margin:8px 0; background:#fff; }
.file-row { display:flex; gap:8px; align-items:center; padding:10px 12px; border-bottom:1px solid var(--line); }
.file-row:last-child { border-bottom:0; }
.file-row .main { flex:1; min-width:0; }
.file-row .main b { display:block; font-size:14px; word-break:break-word; }
.file-row .btn { flex:none; }
.file-row input[type=checkbox] { width:20px; height:20px; flex:none; }

/* Reports */
.rpt-nav { margin: 8px 0 4px; }
.rpt-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.rpt-head h2 { margin:6px 0; }
.rpt-year { margin:0; display:flex; align-items:center; gap:8px; font-size:13px; }
.rpt-year select { width:auto; padding:7px 10px; font-size:15px; }
.chart-card { padding:12px 10px 8px; }
.chart-legend { display:flex; justify-content:space-between; align-items:baseline; gap:8px; margin:0 6px 6px; font-size:13px; color:var(--muted); }
.chart-legend b { color:var(--navy); font-size:18px; font-variant-numeric:tabular-nums; }
.chart-wrap { width:100%; }
.chart { width:100%; height:auto; display:block; }
.chart-grid { stroke:var(--line); stroke-width:1; }
.chart-tick { fill:var(--muted); font-size:8px; }
.chart-x { fill:var(--muted); font-size:8px; }
.chart-hit { fill:transparent; cursor:pointer; }
.chart-fill { fill:var(--navy); }
.chart-bar.is-on .chart-fill, .chart-bar:active .chart-fill { fill:var(--red); }
.chart-bar:focus { outline:none; }
.chart-bar:focus .chart-fill { fill:var(--navy2); }
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; background:#fff; border:1px solid var(--line); border-radius:var(--radius); margin-bottom:12px; }
.rpt-table { width:100%; border-collapse:collapse; font-size:12.5px; font-variant-numeric:tabular-nums; }
.rpt-table th, .rpt-table td { padding:8px 7px; text-align:right; border-bottom:1px solid var(--line); white-space:nowrap; }
.rpt-table.wide { min-width:620px; }
.rpt-table th:first-child, .rpt-table td:first-child { text-align:left; }
.rpt-table th { font-size:11px; text-transform:uppercase; letter-spacing:.4px; color:var(--muted); background:#f7f8fb; }
.rpt-table tr.grand td { font-weight:800; color:var(--navy); border-bottom:0; background:#eef1f7; }
.rpt-table tr.muted-row { color:var(--muted); }
.rpt-table a { font-weight:600; }

.badge.legacy { background:#f1ecfb; color:#5b3b9a; text-transform:none; letter-spacing:0; }

/* Post-login logo intro */
html.intro-pending, html.intro-pending body { background:#fff; }
.intro-splash {
  position:fixed; inset:0; z-index:10000;
  display:flex; align-items:center; justify-content:center;
  background:#fff;
  opacity:1;
  transition:opacity .5s ease;
  cursor:pointer;
}
.intro-splash.is-out { opacity:0; pointer-events:none; }
.intro-splash video {
  width:100%; height:100%;
  object-fit:contain;
  background:#fff;
  pointer-events:none;
}
.intro-splash .intro-skip {
  position:absolute; bottom:calc(18px + env(safe-area-inset-bottom)); left:0; right:0;
  text-align:center; font-size:13px; font-weight:600; color:#667085;
  letter-spacing:.02em; opacity:0; transition:opacity .4s ease;
}
.intro-splash.is-ready .intro-skip { opacity:.85; }
html.intro-pending #introSplash { display:flex !important; }
