/* Style: achromatic ledger (seed 2090031062) with Spotless's logo as the palette:
   navy = ink and the one primary, logo blue = money that is still due, gold = the stars, used only as the active mark. */
:root{
  --bg:#f2f4f8; --surface:#ffffff; --surface-2:#eceff5; --line:#e2e6ee; --rule:#eef1f6; --control:#cdd3df;
  --fg:#16224a; --muted:#57617a; --navy:#203167; --accent:#1467c4; --accent-fg:#ffffff; --accent-soft:#e6eefb; --gold:#b98a1f;
  --primary:#203167; --primary-fg:#ffffff;
  --ok:#247b50; --ok-soft:#dcfae5; --ok-ink:#04250e;
  --warn:#92400e; --warn-soft:#fffbeb;
  --bad:#c4242a; --bad-soft:#ffedea; --bad-ink:#831c1e;
  --paper:#ffffff; --paper-fg:#16224a; --float:0 12px 32px rgba(22,34,74,.18);
  --font:"Barlow", system-ui, "Segoe UI", sans-serif;
  /* the inline page code still reads these names */
  --f-display:var(--font); --f-body:var(--font); --f-mono:var(--font);
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#000000; --surface:#111111; --surface-2:#222222; --line:#2e2e2e; --rule:#1f1f1f; --control:#444444;
  --fg:#ffffff; --muted:#b4b4b4; --navy:#ffffff; --accent:#6eb2ff; --accent-fg:#000000; --accent-soft:#1a2738; --gold:#e5c063;
  --primary:#ffffff; --primary-fg:#000000;
  --ok:#3fc07a; --ok-soft:#172a1d; --ok-ink:#3fc07a; --warn:#f0b452; --warn-soft:#3a2c14;
  --bad:#e5566f; --bad-soft:#2c1a20; --bad-ink:#e5566f;
  --paper:#ffffff; --paper-fg:#16224a; --float:0 12px 32px rgba(0,0,0,.6); color-scheme:dark}}
*{box-sizing:border-box}
body{background:var(--bg);color:var(--fg);font:400 15px/1.45 var(--font);display:grid;grid-template-columns:232px minmax(0,1fr);min-height:100vh}

/* shell */
.side{position:sticky;top:0;height:100vh;background:var(--surface);border-right:1px solid var(--line);padding:20px 12px;display:flex;flex-direction:column;gap:20px}
.side img{display:block;width:172px;height:auto;margin:0 auto}
nav.tabs{display:flex;flex-direction:column;gap:2px}
nav.tabs button{display:flex;align-items:center;justify-content:flex-start;gap:10px;width:100%;height:38px;padding:0 10px;background:none;border:0;border-radius:6px;color:var(--muted);font:500 15px var(--font);cursor:pointer;text-align:left}
nav.tabs svg{width:17px;height:17px;flex:none}
nav.tabs button:hover{color:var(--fg);background:var(--surface-2)}
nav.tabs button[aria-current="true"]{background:var(--surface-2);color:var(--fg);font-weight:600}
nav.tabs button[aria-current="true"]::after{content:"";margin-left:auto;width:13px;height:13px;background:var(--gold);clip-path:polygon(50% 0,63% 35%,100% 38%,71% 60%,81% 96%,50% 76%,19% 96%,29% 60%,0 38%,37% 35%)}
.side .where{margin-top:auto;padding:0 10px;color:var(--muted);font-size:13px}
.wrap{width:100%;max-width:1600px;padding-inline:32px}
main{padding-block:28px 64px}

h1,h2,h3{margin:0;color:var(--navy);font-family:var(--font);text-wrap:balance}
h1{font-size:26px;font-weight:700;letter-spacing:-.01em}
h2{font-size:17px;font-weight:600}
.lead{margin:2px 0 0;color:var(--muted)}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.spacer{flex:1}

/* controls */
button,.btn{font:500 14px var(--font);border-radius:6px;border:1px solid var(--control);background:var(--surface);color:var(--fg);height:36px;padding:0 13px;cursor:pointer;white-space:nowrap;display:inline-flex;align-items:center;justify-content:center;transition:background-color .12s,border-color .12s,transform .06s}
button:hover,.btn:hover{border-color:var(--muted)}
button:active:not(:disabled){transform:translateY(1px)}
button.primary{background:var(--primary);border-color:var(--primary);color:var(--primary-fg);font-weight:600}
button.primary:hover{filter:brightness(1.2)}
button.danger{color:var(--bad);border-color:var(--control)}
button.ghost{border-color:transparent;background:none}
button.ghost:hover{background:var(--surface-2)}
button.sm{height:30px;padding:0 9px;font-size:13px}
button:disabled{opacity:.6;cursor:default}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
input,select,textarea{font:400 15px var(--font);color:var(--fg);background:var(--surface);border:1px solid var(--control);border-radius:6px;padding:7px 10px;min-height:38px;width:100%;min-width:0}
input[type=checkbox]{min-height:0}
input::placeholder,textarea::placeholder{color:var(--muted);opacity:1}
textarea{resize:vertical}
label.f{display:flex;flex-direction:column;gap:5px;font-size:14px;color:var(--muted);font-weight:500;min-width:0}
.lbl{font-size:13px;color:var(--muted);font-weight:500}
.mono{font-variant-numeric:tabular-nums;font-weight:600}
.num{font-variant-numeric:tabular-nums;text-align:right}

/* money strip: one divided card, each cell filters the ledger */
.summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));margin:20px 0;background:var(--surface);border:1px solid var(--line);border-radius:8px;overflow:hidden}
.sum{height:auto;display:flex;flex-direction:column;align-items:flex-start;gap:0;padding:14px 20px;border:0;border-radius:0;background:none;text-align:left}
.sum+.sum{border-left:1px solid var(--line)}
button.sum:hover{background:var(--bg)}
.sum[aria-pressed="true"]{box-shadow:inset 0 -3px 0 var(--navy)}
.sum .v{font-size:28px;font-weight:700;color:var(--fg);font-variant-numeric:tabular-nums;line-height:1.25}
.sum .c{color:var(--muted);font-size:13px}
.sum:first-child .v{color:var(--accent)}
.sum.bad.has .v{color:var(--bad)}
.sum.zero .v{color:var(--muted)}

/* filters */
.toolbar{display:grid;grid-template-columns:minmax(0,2.2fr) auto minmax(0,1fr) 150px 150px;gap:12px;align-items:end;margin-bottom:16px}
.search{position:relative}
.search input{padding-left:34px}
.search svg{position:absolute;left:11px;top:50%;transform:translateY(-50%);color:var(--muted)}
.seg-f{display:flex;flex-direction:column;gap:5px}
.seg{display:inline-flex;height:38px;border:1px solid var(--control);border-radius:6px;overflow:hidden;background:var(--surface)}
.seg button{height:auto;border:0;border-radius:0;padding:0 12px;background:none;color:var(--muted)}
.seg button+button{border-left:1px solid var(--line)}
.seg button[aria-pressed="true"]{background:var(--surface-2);color:var(--fg);font-weight:600}

/* ledger */
.card{background:var(--surface);border:1px solid var(--line);border-radius:8px}
.tablewrap{overflow-x:auto}
table.ledger{width:100%;border-collapse:collapse;min-width:720px}
.ledger th{font:500 13px var(--font);color:var(--muted);text-align:left;padding:11px 14px;white-space:nowrap;user-select:none}
.ledger th.num{text-align:right}
.ledger th.sortable{cursor:pointer}
.ledger th.sortable:hover{color:var(--fg)}
.ledger th .arr{font-size:10px;margin-left:3px}
.ledger td{padding:11px 14px;border-top:1px solid var(--rule);vertical-align:top}
.ledger td.num:nth-last-child(2){font-weight:600}
.ledger td:nth-child(4){white-space:nowrap}
.ledger tbody tr{cursor:pointer}
.ledger tbody tr:hover td{background:var(--bg)}
.ledger .desc{color:var(--muted);font-size:13.5px;max-width:340px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
/* the description takes whatever width is left and cuts itself short, so the table fits the window instead of scrolling sideways */
@media (min-width:1151px){#v-invoices .ledger td:nth-child(5){width:100%;max-width:0}#v-invoices table.ledger{min-width:0}}
/* laptop widths: the due date gives up its column so the description stays readable (Overdue still shows in Status) */
@media (min-width:1151px) and (max-width:1400px){#v-invoices .ledger :is(th,td):nth-child(3){display:none}}
mark{background:#fbeec9;color:#16224a;border-radius:3px;padding:0 1px}
.pill{display:inline-flex;flex:none;align-items:center;font-size:12.5px;font-weight:600;padding:1px 9px;border-radius:4px;white-space:nowrap}
.pill.open{background:var(--accent-soft);color:var(--accent)}
.pill.paid{background:var(--ok-soft);color:var(--ok-ink)}
.pill.overdue{background:var(--bad-soft);color:var(--bad-ink)}
.empty{padding:40px 20px;text-align:center;color:var(--muted)}
.empty h3{font-size:17px;margin-bottom:6px}
.foot{display:flex;justify-content:space-between;padding:11px 14px;color:var(--muted);font-size:13.5px;border-top:1px solid var(--line)}

.manage{display:grid;grid-template-columns:minmax(0,340px) minmax(0,1fr);gap:16px;align-items:start;margin-top:16px}
.form{padding:20px;display:flex;flex-direction:column;gap:14px}
.grid2{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px}

.settings{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px;margin-top:16px}
.hint{font-size:13px;color:var(--muted)}
code{font-size:13px;background:var(--surface-2);padding:1px 5px;border-radius:4px}

/* invoice editor */
.overlay{position:fixed;inset:0;background:rgba(22,34,74,.45);z-index:40;display:flex;justify-content:flex-end}
.panel{background:var(--bg);width:min(1160px,100%);height:100%;overflow:auto;box-shadow:var(--float)}
.panel-head{position:sticky;top:0;z-index:5;background:var(--surface);border-bottom:1px solid var(--line)}
.panel-head .in{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:12px 20px}
.editor{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr);gap:24px;padding:20px}
.items{display:flex;flex-direction:column;gap:10px}
.itemrow{display:grid;grid-template-columns:minmax(0,1fr) 64px 92px 92px 30px;gap:8px;align-items:start;padding:10px;border:1px solid var(--line);border-radius:6px;background:var(--surface)}
.itemrow .full{grid-column:1/-1}
.itemrow .amt{padding:8px 0;font-weight:600;text-align:right;font-variant-numeric:tabular-nums}
.totalbar{display:flex;justify-content:flex-end;gap:16px;align-items:baseline;padding:8px 2px}
.totalbar b{font-size:24px;font-weight:700;color:var(--navy);font-variant-numeric:tabular-nums}

/* paper: same proportions as the PDF, logo as watermark behind the text */
.paper{background:var(--paper);color:var(--paper-fg);border:1px solid var(--line);border-radius:2px;padding:30px;font-size:13px;position:relative;overflow:hidden;min-height:560px}
.paper::before{content:"";position:absolute;inset:0;background:url(logo.png) center 58%/72% no-repeat;opacity:.09;pointer-events:none}
.paper>*{position:relative}
.paper .ph{display:flex;justify-content:space-between;gap:16px;flex-wrap:wrap;border-bottom:2px solid #203167;padding-bottom:14px}
.paper .co b{font-weight:700;font-size:18px;color:#203167;display:block}
.paper .co div{color:#4c5670;white-space:pre-line}
.paper .inv{text-align:right}
.paper .inv h3{font-weight:700;font-size:28px;letter-spacing:.04em;color:#203167}
.paper .meta{display:grid;grid-template-columns:auto auto;gap:2px 12px;justify-content:end;margin-top:6px}
.paper .meta span:nth-child(odd){color:#4c5670}
.paper .billto{margin:16px 0;white-space:pre-line}
.paper .billto .lbl{color:#4c5670}
.paper table{width:100%;border-collapse:collapse}
.paper th{font-size:12px;font-weight:600;text-align:left;border-bottom:1px solid #b9c2cf;padding:6px 4px;color:#4c5670}
.paper th.num{text-align:right}
.paper td{padding:7px 4px;border-bottom:1px solid #e3e7ee;vertical-align:top}
.paper td.d{white-space:pre-line}
.paper .ptotal{display:flex;justify-content:flex-end;gap:20px;margin-top:12px;font-size:15px}
.paper .ptotal b{font-weight:700;font-size:19px;color:#203167}
.paper .notes{margin-top:18px;color:#4c5670;white-space:pre-line}
.stamp{position:absolute!important;top:84px;right:26px;transform:rotate(-12deg);border:3px solid #247b50;color:#247b50;font-weight:700;font-size:26px;padding:2px 12px;border-radius:6px;opacity:.75;letter-spacing:.08em}

/* dialogs */
.modal-bg{position:fixed;inset:0;background:rgba(22,34,74,.5);z-index:60;display:flex;align-items:center;justify-content:center;padding:16px}
.modal{background:var(--surface);border-radius:8px;box-shadow:var(--float);width:min(980px,100%);max-height:calc(100% - 20px);display:flex;flex-direction:column;overflow:hidden}
.modal.small{width:min(420px,100%)}
.modal .mh{padding:14px 18px;border-bottom:1px solid var(--line);display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.modal .mb{padding:16px 18px;overflow:auto;display:flex;flex-direction:column;gap:14px;min-height:0}
.modal .mf{padding:12px 18px;border-top:1px solid var(--line);display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;align-items:center}
.imp{border:1px solid var(--line);border-radius:6px;overflow:auto;max-height:52vh}
.imp table{border-collapse:collapse;width:100%;font-size:13.5px}
.imp th{position:sticky;top:0;background:var(--surface);text-align:left;padding:8px;font-weight:500;color:var(--muted);white-space:nowrap;z-index:1}
.imp td{padding:7px 8px;border-top:1px solid var(--rule);white-space:nowrap;max-width:260px;overflow:hidden;text-overflow:ellipsis}
.imp tr.sel td{background:var(--accent-soft)}
.imp tr.billed td{color:var(--muted)}
.tag{font-size:12px;font-weight:600;padding:1px 7px;border-radius:4px;background:var(--surface-2);color:var(--muted)}
.notice{padding:10px 12px;border-radius:6px;font-size:14px;background:var(--surface-2)}
.notice.bad{background:var(--bad-soft);color:var(--bad-ink)}
.notice.warn{background:var(--warn-soft);color:var(--warn)}

#toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:var(--navy);color:var(--surface);padding:10px 16px;border-radius:6px;z-index:90;font-weight:500;box-shadow:var(--float)}
.status-line{font-size:13px;color:var(--muted)}
@media (prefers-reduced-motion:no-preference){.panel{animation:slide .18s ease-out}@keyframes slide{from{transform:translateX(24px);opacity:.6}}}

/* narrow windows: the sidebar folds into a top bar */
@media (max-width:1150px){
  .toolbar{grid-template-columns:1fr 1fr}.toolbar .search,.toolbar .seg-f{grid-column:1/-1}
  .editor{grid-template-columns:1fr}
}
@media (max-width:820px){
  body{display:block}
  .side{position:sticky;z-index:20;height:auto;flex-direction:row;align-items:center;gap:8px;padding:6px 12px;border-right:0;border-bottom:1px solid var(--line)}
  .side img{width:52px;margin:0}
  .side .where{display:none}
  nav.tabs{flex-direction:row;overflow-x:auto;flex:1}
  nav.tabs button{width:auto;height:44px;flex:none}
  nav.tabs button[aria-current="true"]::after{content:none}
  nav.tabs svg{display:none}
  .wrap{padding-inline:16px}
  .manage,.settings{grid-template-columns:minmax(0,1fr)}
}
@media (max-width:640px){
  /* keeps the first invoices on the first screen: one line per total, filters tightened */
  .summary{grid-template-columns:1fr;margin:14px 0}
  .sum{flex-direction:row;align-items:baseline;justify-content:space-between;padding:8px 14px}
  .sum+.sum{border-left:0;border-top:1px solid var(--line)}
  .sum .v{font-size:20px}
  .sum .c{display:none}
  .toolbar{gap:8px}
  .toolbar label:has(#f-client){grid-column:1/-1}
  .seg{width:100%}.seg button{flex:1}
}
/* below this the invoice table can't fit even with the description cut short */
@media (max-width:1150px){
  /* the ledger as blocks: number, client, total / date, description, status / actions. No side scroll. */
  #v-invoices table.ledger{min-width:0}
  #v-invoices .ledger thead{display:none}
  #v-invoices .ledger tbody tr{display:grid;grid-template-columns:auto minmax(0,1fr) auto;column-gap:12px;row-gap:3px;padding:12px 14px;border-top:1px solid var(--rule)}
  #v-invoices .ledger tbody tr:first-child{border-top:0}
  #v-invoices .ledger td{padding:0;border:0;min-width:0}
  #v-invoices .ledger tbody tr:hover td{background:none}
  #v-invoices .ledger td:nth-child(1){grid-area:1/1}
  #v-invoices .ledger td:nth-child(4){grid-area:1/2;overflow:hidden;text-overflow:ellipsis;font-weight:500}
  #v-invoices .ledger td:nth-child(7){grid-area:1/3;text-align:right}
  #v-invoices .ledger td:nth-child(2){grid-area:2/1;font-size:13.5px;color:var(--muted)}
  #v-invoices .ledger td:nth-child(5){grid-area:2/2}
  #v-invoices .ledger td:nth-child(6){grid-area:2/3;text-align:right}
  #v-invoices .ledger td:nth-child(3){display:none}
  #v-invoices .ledger td:nth-child(8){grid-area:3/1/4/4;text-align:left;margin-left:-10px}
  #v-invoices .ledger .desc{max-width:none}
}
@media (max-width:560px){.itemrow{grid-template-columns:minmax(0,1fr) 60px 84px}.itemrow .amt{grid-column:2/4}.itemrow .x{grid-column:1}}
.pill.void{background:var(--line,#e3e7ee);color:var(--muted);text-decoration:line-through}
td.voided{color:var(--muted);text-decoration:line-through}
.stamp.void{border-color:#b3261e;color:#b3261e}
/* employee accounts: no business totals, expenses, reports or settings (server.js refuses those too) */
body.employee :is(nav.tabs button:is([data-view="expenses"],[data-view="reports"],[data-view="settings"]),.owner-only){display:none!important}
.emp-only{display:none!important} body.employee nav.tabs .emp-only{display:flex!important}
/* a client's name opens their page */
button.link{all:unset;cursor:pointer;font-weight:600;color:var(--fg)}
button.link:hover{text-decoration:underline}
button.link:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:2px}
#v-clients tr[data-inv]{cursor:pointer}
.titlerow{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
button.privacy{display:inline-flex;align-items:center;gap:6px}
button.privacy svg{width:16px;height:16px}
button.privacy[aria-pressed="true"]{color:var(--accent);border-color:var(--accent)}
/* "Hide values": amounts on the overview screens are blurred; the invoice editor stays readable. */
body.hide-money :is(#v-invoices,#v-clients,#v-reports) :is(.sum .v,td.num:not(:has(button)),tfoot td,.foot b),
body.hide-money #v-invoices .lead{filter:blur(7px);user-select:none}
