/* =============================================================================
 * Shop Ledger: visual design
 * -----------------------------------------------------------------------------
 * A plain, professional business dashboard. Neutral surfaces, one accent color,
 * and color used only where it carries meaning (status, money in/out, cost
 * categories, due dates).
 *
 * Type: IBM Plex Sans throughout (open, very legible at small sizes), with
 *       tabular figures so money columns line up.
 *
 * Everything is driven by CSS variables set on <html> by app.js / theme.js:
 *   data-theme   light | dark
 *   data-accent  blue | indigo | teal | green | orange | red | slate
 *   data-density comfortable | compact
 *   data-text    standard | large
 * ========================================================================== */

/* ---------- 1. Tokens: light theme (default) ---------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;          /* table heads, subtle fills */
  --surface-3: #eef0f3;          /* hover */
  --border: #e2e5e9;
  --border-strong: #cdd2d8;
  --text: #17202b;
  --text-2: #475262;
  --text-3: #6b7685;
  --good: #15803d;
  --bad: #c62828;
  --warn: #b45309;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 16px -4px rgba(16, 24, 40, 0.10), 0 1px 2px rgba(16, 24, 40, 0.05);
  --accent: #2563eb;
  --on-accent: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 35%, var(--surface));
  --focus: color-mix(in srgb, var(--accent) 28%, transparent);

  --font: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
  --pad: 20px;                   /* panel padding */
  --gap: 16px;                   /* grid gaps */
  --row-y: 10px;                 /* table row padding */
  --ctl-y: 7px;                  /* input padding */
  --sidebar-w: 236px;
  color-scheme: light;
  font-size: 15px;
}
html[data-text="large"] { font-size: 17px; }
html[data-density="compact"] { --pad: 14px; --gap: 12px; --row-y: 6px; --ctl-y: 5px; }

/* ---------- 1b. Tokens: dark theme ---------- */
html[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1b2028;
  --surface-3: #222833;
  --border: #2a313c;
  --border-strong: #3a4350;
  --text: #e7eaee;
  --text-2: #b3bbc6;
  --text-3: #8a94a2;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  --accent: #5b8def;
  --on-accent: #0b1220;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color-scheme: dark;
}

/* ---------- 1c. Accent choices (light value, then dark value) ---------- */
html[data-accent="indigo"] { --accent: #4f46e5; }
html[data-accent="teal"]   { --accent: #0f766e; }
html[data-accent="green"]  { --accent: #15803d; }
html[data-accent="orange"] { --accent: #c2410c; }
html[data-accent="red"]    { --accent: #b91c1c; }
html[data-accent="slate"]  { --accent: #475569; }
html[data-theme="dark"][data-accent="indigo"] { --accent: #8b87f7; }
html[data-theme="dark"][data-accent="teal"]   { --accent: #2fb5a5; }
html[data-theme="dark"][data-accent="green"]  { --accent: #43b86f; }
html[data-theme="dark"][data-accent="orange"] { --accent: #f28c4f; }
html[data-theme="dark"][data-accent="red"]    { --accent: #ef6b6b; }
html[data-theme="dark"][data-accent="slate"]  { --accent: #9aa8bb; }

/* ---------- 1d. Color-coding tones (statuses, cost categories, KPIs) ---------- */
.tone-gray   { --tone: #6b7280; } .tone-blue  { --tone: #2563eb; }
.tone-teal   { --tone: #0d9488; } .tone-green { --tone: #16a34a; }
.tone-amber  { --tone: #b45309; } .tone-orange{ --tone: #ea580c; }
.tone-red    { --tone: #dc2626; } .tone-purple{ --tone: #7c3aed; }
html[data-theme="dark"] .tone-gray   { --tone: #9ca3af; } html[data-theme="dark"] .tone-blue  { --tone: #60a5fa; }
html[data-theme="dark"] .tone-teal   { --tone: #2dd4bf; } html[data-theme="dark"] .tone-green { --tone: #4ade80; }
html[data-theme="dark"] .tone-amber  { --tone: #fbbf24; } html[data-theme="dark"] .tone-orange{ --tone: #fb923c; }
html[data-theme="dark"] .tone-red    { --tone: #f87171; } html[data-theme="dark"] .tone-purple{ --tone: #a78bfa; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--tone, var(--text-3)); flex: none; }

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 400 1rem/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; color: var(--text); letter-spacing: -0.005em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; margin: 18px 0 8px; }
.num, input[type=number] { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 0.87rem; }
.eyebrow { font-size: 0.8rem; font-weight: 500; color: var(--text-3); }
.pre { white-space: pre-wrap; }
small { display: block; color: var(--text-3); font-size: 0.82rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.nowrap { white-space: nowrap; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* A short, quiet fade-in; no movement. */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.view > * { animation: fade 0.18s ease-out both; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- 3. Boot + sign-in ---------- */
.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-mark { font-size: 1.1rem; font-weight: 600; color: var(--text-3); }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.02em; flex: none; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-panel { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand b { display: block; font-size: 1.1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 28px; display: grid; gap: 14px; }
.auth-card h2 { font-size: 1.25rem; }
.auth-card p { margin: 0; }
.auth-card label { display: grid; gap: 6px; font-size: 0.87rem; font-weight: 500; color: var(--text-2); }
.err { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 0.9rem; }

/* ---------- 4. App shell: sidebar + content ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand b { display: block; font-size: 0.98rem; font-weight: 600; line-height: 1.2; }
.brand small { font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.sidenav { display: grid; gap: 2px; }
.sidenav a, .side-btn { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; font-size: 0.93rem; border: 0; background: none; cursor: pointer; font-family: inherit; width: 100%; text-align: left; }
.sidenav a:hover, .side-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.sidenav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidenav a.on .ico { stroke: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--border); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px 2px; font-size: 0.85rem; color: var(--text-3); min-width: 0; }
.side-user span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-weight: 600; font-size: 0.78rem; flex: none; }

.view { width: 100%; max-width: 1480px; padding: 28px 32px 80px; }
.loading { padding: 60px; text-align: center; color: var(--text-3); }

/* ---------- 5. Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 14px; min-height: 36px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 0.9rem/1.2 var(--font); box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s; white-space: nowrap; }
.btn:hover { text-decoration: none; background: var(--surface-3); }
.btn:focus-visible, .x:focus-visible, .side-btn:focus-visible, .sidenav a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.accent { background: var(--good); border-color: var(--good); color: #fff; }
html[data-theme="dark"] .btn.accent { color: #0b1a10; }
.btn.accent:hover { background: color-mix(in srgb, var(--good) 88%, #000); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--bad); }
.btn.danger:not(.ghost) { border-color: color-mix(in srgb, var(--bad) 50%, var(--surface)); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 0.85rem; }
.btn.big { padding: 10px 18px; font-size: 1rem; }
.btn.wide { width: 100%; }
.btn.add { background: transparent; box-shadow: none; border: 1px dashed var(--border-strong); color: var(--text-2); margin-top: 10px; }
.btn.add:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn[disabled], .x[disabled] { opacity: .4; cursor: default; }
.x { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none; color: var(--text-3); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0; }
.x:hover:not([disabled]) { color: var(--bad); background: var(--surface-3); }
.x.mv:hover:not([disabled]) { color: var(--accent); }
.x .ico { width: 16px; height: 16px; }
.link { font-size: 0.87rem; font-weight: 500; }

/* ---------- 6. Inputs ---------- */
input, select, textarea { width: 100%; font: 400 0.93rem/1.4 var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: var(--ctl-y) 10px; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--text-3) 60%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--text-3) 75%, var(--surface)); }
input[disabled] { opacity: .5; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; margin: 0; flex: none; }
textarea { resize: vertical; }
.tick { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.87rem; color: var(--text-2); white-space: nowrap; }
.tick.big { font-size: 0.93rem; color: var(--text); padding-top: 26px; white-space: normal; }

/* ---------- 7. Panels and page heads ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow-sm); margin-bottom: var(--gap); }
.panel > h2 { margin-bottom: 2px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; }
.panel-head p { margin: 3px 0 0; }
.sec-total { font-size: 1rem; font-weight: 600; color: var(--text); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.save-state { font-weight: 500; }
.save-state.warn { color: var(--warn); }
.title-input { font: 600 1.5rem/1.3 var(--font); background: transparent; border: 1px solid transparent; padding: 4px 8px; margin-left: -9px; min-width: min(760px, 80vw); }
.title-input:hover { border-color: var(--border); }
.notice { border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--surface)); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); padding: 12px 16px; border-radius: var(--radius); margin: 0 0 var(--gap); color: var(--text); }
.ph { display: inline-block; font-size: 0.72rem; font-weight: 600; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); padding: 1px 7px; border-radius: 10px; white-space: nowrap; }
.empty { color: var(--text-3); padding: 8px 0; margin: 0; }

/* ---------- 8. Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid > h2 { grid-column: 1 / -1; }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .span4 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; align-content: start; }
.field > span { font-size: 0.84rem; color: var(--text-2); font-weight: 500; }
.field em { font-style: normal; font-size: 0.8rem; color: var(--text-3); }
.field.inline { display: inline-grid; width: 190px; margin-left: 12px; vertical-align: bottom; }
.inline-fields { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.big-num { font-size: 1.6rem; font-weight: 600; color: var(--text); }

/* ---------- 9. Status chips + due dates ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.5;
  color: var(--tone, #6b7280); background: color-mix(in srgb, var(--tone, #6b7280) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone, #6b7280) 28%, var(--surface)); }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--tone, #6b7280); }
.st-cancelled, .st-void { text-decoration: line-through; }
.due { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.due.soon { color: var(--warn); font-weight: 600; }
.due.late { color: var(--bad); font-weight: 600; }
.due.soon::before, .due.late::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- 10. Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.dash-cell.full { grid-column: 1 / -1; }
.dash-cell > .panel, .dash-cell > .notice, .dash-cell > .stats { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); }
.stat { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); border-top: 3px solid var(--tone, var(--accent)); }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 0.87rem; font-weight: 500; color: var(--text-2); }
.stat strong { display: block; font-size: 1.75rem; font-weight: 600; margin: 6px 0 2px; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid2.wide-left { grid-template-columns: 1.4fr 1fr; align-items: start; }
.rows { list-style: none; margin: 0 calc(var(--pad) * -1); padding: 0; }
.rows li a { display: grid; grid-template-columns: minmax(0, 1fr) auto auto 96px; gap: 14px; align-items: center; padding: var(--row-y) var(--pad); border-top: 1px solid var(--border); color: var(--text); }
.rows.compact li a, .rows.inv li a { grid-template-columns: minmax(0, 1fr) auto 96px; }
.rows li a:hover { background: var(--surface-2); text-decoration: none; }
.rows li:last-child a { padding-bottom: calc(var(--row-y) - 4px); }
.r-main { min-width: 0; }
.r-main b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .num { text-align: right; font-weight: 500; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: 130px minmax(0, 1fr) 150px; gap: 12px; align-items: center; font-size: 0.9rem; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 3px; background: var(--tone); border-radius: 999px; }
.bars .num { text-align: right; color: var(--text-2); }

/* ---------- 11. Tables ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; } .filters input { max-width: 360px; } .filters select { max-width: 220px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table th { text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--text-3); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: var(--row-y) 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; } .table tbody tr:hover td { background: var(--surface-2); }
.table td b { font-weight: 500; }
.r { text-align: right; }
.table th.r { text-align: right; }
.linetable { width: 100%; border-collapse: collapse; }
.linetable th { text-align: left; font-size: 0.78rem; font-weight: 600; color: var(--text-3); padding: 4px 6px 6px; border-bottom: 1px solid var(--border); }
.linetable td { padding: 6px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.linetable tbody tr:last-child td { border-bottom: 0; }
.linetable td input[type=number] { min-width: 78px; }
.linetable .c-wide { width: 38%; } .linetable .c-cost { width: 100px; font-weight: 500; } .linetable .c-x { width: 36px; } .linetable .c-check { width: 1%; }
.linetable .custom-name { margin-top: 4px; }
.numwrap { position: relative; } .numwrap i { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); font-size: 0.75rem; color: var(--text-3); pointer-events: none; font-style: normal; }
.settable td input { min-width: 90px; }

/* ---------- 12. Job + invoice editor ---------- */
.job-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.job-side { position: sticky; top: 20px; }
.hidden-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 4px 0 12px; }
.hidden-bar:empty { display: none; }
.pricebox { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); overflow: hidden; }
.pb-hero { padding: 18px 20px 16px; border-bottom: 1px solid var(--border); }
.pb-hero strong { display: block; font-size: 2.2rem; font-weight: 600; line-height: 1.15; color: var(--text); letter-spacing: -0.015em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.pb-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 12px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.9rem; color: var(--text-2); }
.pb-total b { color: var(--text); font-size: 1.05rem; font-weight: 600; margin-left: auto; }
.pb-total small { flex-basis: 100%; }
.pb-keep { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
.pb-keep > div { padding: 14px 20px; } .pb-keep > div + div { border-left: 1px solid var(--border); }
.pb-keep strong { display: block; font-size: 1.3rem; font-weight: 600; color: var(--good); font-variant-numeric: tabular-nums; }
.pb-keep .bad strong { color: var(--bad); } .pb-keep .good strong { color: var(--good); }
.pb-comp { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.pb-comp-head { display: flex; justify-content: space-between; font-size: 0.84rem; color: var(--text-2); margin-bottom: 8px; }
.pb-comp-head b { color: var(--text); font-weight: 600; }
.comp-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.comp-bar span { display: block; height: 100%; background: var(--tone); min-width: 2px; }
.pricebox details { border-bottom: 1px solid var(--border); }
.pricebox summary { cursor: pointer; padding: 12px 20px; font-size: 0.9rem; font-weight: 600; color: var(--text); list-style: none; display: flex; justify-content: space-between; align-items: center; }
.pricebox summary::-webkit-details-marker { display: none; }
.pricebox summary::after { content: ''; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(-45deg); transition: transform .15s; }
details[open] > summary::after { transform: rotate(45deg); }
.pb-break { padding: 0 20px 12px; }
.pb-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 4px 0; font-size: 0.9rem; color: var(--text-2); }
.pb-row > span { display: inline-flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.pb-row > span .dot { align-self: center; }
.pb-row small { display: inline; font-size: 0.78rem; }
.pb-row b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pb-row.sum { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; color: var(--text); font-weight: 600; }
.pb-row.sum b { font-weight: 600; }
.pb-row.big b { font-size: 1.05rem; }
.pb-row.plus b { color: var(--good); } .pb-row.minus b { color: var(--bad); }
.pb-cmp table { width: calc(100% - 40px); margin: 0 20px; border-collapse: collapse; font-size: 0.87rem; }
.pb-cmp th { font-size: 0.76rem; font-weight: 600; color: var(--text-3); text-align: left; padding: 4px 2px; }
.pb-cmp td { padding: 7px 2px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.pb-cmp td small { font-size: 0.76rem; }
.pb-cmp tr[data-apply-profile] { cursor: pointer; } .pb-cmp tr[data-apply-profile]:hover td { background: var(--surface-2); }
.pb-cmp tr.on td { color: var(--accent); font-weight: 600; }
.pb-cmp p { padding: 4px 20px 12px; margin: 0; }
.pb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 16px 20px; }
.pb-actions .wide { grid-column: 1 / -1; }
.pb-inv { padding: 0 20px 16px; display: grid; gap: 4px; font-size: 0.87rem; }

.dropzone { display: grid; place-items: center; gap: 4px; padding: 24px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); cursor: pointer; text-align: center; background: var(--surface-2); transition: border-color .12s, background .12s; }
.dropzone strong { font-weight: 600; }
.dropzone span { font-size: 0.82rem; color: var(--text-3); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.thumbs figure { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.thumbs figcaption { display: flex; gap: 4px; padding: 6px; }
.thumbs figcaption input { padding: 4px 6px; font-size: 0.8rem; }
.filelist, .linklist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.filelist li { display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: center; }
.linklist li { display: grid; grid-template-columns: 1fr 2fr auto auto; gap: 8px; align-items: center; }

/* ---------- 13. Settings ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.setnav { position: sticky; top: 20px; display: grid; gap: 1px; }
.setnav .grp { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); padding: 14px 10px 4px; }
.setnav .grp:first-child { padding-top: 0; }
.setnav a { color: var(--text-2); padding: 6px 10px; border-radius: var(--radius-sm); font-weight: 500; font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.setnav a:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.setnav a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.setnav i { font-size: 0.72rem; font-style: normal; font-weight: 600; color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-radius: 10px; padding: 0 7px; }
.machine .panel-head { align-items: center; }
.mname { display: flex; align-items: center; gap: 10px; flex: 1; } .mname input { font-size: 1.05rem; font-weight: 600; max-width: 460px; }
.mrate { text-align: right; } .mrate strong { font-size: 1.35rem; font-weight: 600; color: var(--text); display: block; font-variant-numeric: tabular-nums; }
.rate-split { display: flex; gap: 28px; padding: 14px 0 0; flex-wrap: wrap; }
.rate-split span small { text-transform: capitalize; font-size: 0.78rem; }
.rate-split b { font-weight: 600; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 40%, var(--surface)); }
.danger-zone h2 { color: var(--bad); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 3px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--sw); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--text); }
.swatch input:focus-visible + span { box-shadow: 0 0 0 2px var(--text), 0 0 0 5px var(--focus); }
.acc-blue { --sw: #2563eb; } .acc-indigo { --sw: #4f46e5; } .acc-teal { --sw: #0f766e; } .acc-green { --sw: #15803d; }
.acc-orange { --sw: #c2410c; } .acc-red { --sw: #b91c1c; } .acc-slate { --sw: #475569; }
.order-table td { padding-top: 5px; padding-bottom: 5px; }
.order-table select { max-width: 160px; }
.tone-row { display: flex; align-items: center; gap: 12px; }
.tone-row select { max-width: 160px; }
.ui-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.ui-cols > .panel { margin-bottom: 0; }
.kpi-ticks { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 12px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 500; font-size: 0.93rem; transition: .2s; z-index: 50; box-shadow: var(--shadow-md); }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.bad { background: var(--bad); color: #fff; }

/* ---------- 14. Responsive ---------- */
@media (max-width: 1180px) {
  .job-layout { grid-template-columns: 1fr; } .job-side { position: static; order: -1; }
  .grid2, .grid2.wide-left, .ui-cols { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 4px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .brand { padding: 0 6px 0 0; } .brand-text { display: none; }
  .sidenav { display: flex; gap: 2px; }
  .sidenav a, .side-btn { width: auto; white-space: nowrap; padding: 7px 9px; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; }
  .side-user { display: none; }
  .side-btn span { display: none; }
  .view { padding: 20px 14px 60px; }
  .dash-grid { grid-template-columns: 1fr; }
  .settings { grid-template-columns: 1fr; } .setnav { position: static; grid-template-columns: 1fr 1fr; }
  .setnav .grp { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .form-grid, .form-grid.cols3, .form-grid.cols4 { grid-template-columns: 1fr 1fr; } .span3, .span4 { grid-column: 1 / -1; }
  .rows li a { grid-template-columns: minmax(0, 1fr) auto; } .rows li a .chip { display: none; }
  .bars li { grid-template-columns: 1fr 1.4fr; } .bars .num { grid-column: 1 / -1; text-align: left; }
  .sidenav a span { display: none; }
  /* line tables become stacked cards */
  .linetable thead { display: none; } .linetable tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .linetable td { width: auto !important; border: 0; } .linetable td.c-wide { grid-column: 1 / -1; }
  .linetable td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--text-3); }
  .title-input { min-width: 0; width: 100%; }
  .table { display: block; overflow-x: auto; }
}

/* =============================================================================
 * 15. Printouts: always on white paper, whatever the screen theme.
 * ========================================================================== */
.print-mode { min-height: 100vh; padding: 20px 0 60px; background: var(--bg); }
.print-bar { max-width: 8.5in; margin: 0 auto 14px; display: flex; justify-content: space-between; gap: 10px; }
.paper { --ink: #17202b; --ink-2: #4b5563; --rule: #e3e6ea; --paper-accent: #2563eb;
  width: 8.5in; min-height: 11in; margin: 0 auto; background: #fff; color: var(--ink); padding: 0.6in 0.65in; box-shadow: var(--shadow-md); border-radius: 4px; font-size: 13px; line-height: 1.45; position: relative; color-scheme: light; }
html[data-accent="indigo"] .paper { --paper-accent: #4f46e5; } html[data-accent="teal"] .paper { --paper-accent: #0f766e; }
html[data-accent="green"] .paper { --paper-accent: #15803d; } html[data-accent="orange"] .paper { --paper-accent: #c2410c; }
html[data-accent="red"] .paper { --paper-accent: #b91c1c; } html[data-accent="slate"] .paper { --paper-accent: #475569; }
.paper::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--paper-accent); border-radius: 4px 4px 0 0; }
.paper h2, .paper h3 { color: var(--ink); }
.paper h3 { font-size: 13px; border-bottom: 1px solid var(--rule); padding-bottom: 4px; margin: 20px 0 8px; }
.paper .muted, .paper small { color: #6b7280; }
.lh { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 18px; border-bottom: 1px solid var(--ink); margin-bottom: 22px; }
.lh-name { font-size: 24px; font-weight: 700; line-height: 1.1; }
.lh-tag { color: var(--ink-2); margin: 4px 0 8px; }
.lh-contact { font-size: 12px; color: var(--ink-2); max-width: 4in; }
.lh-doc { text-align: right; min-width: 2.4in; }
.lh-type { font-size: 22px; font-weight: 700; line-height: 1.1; color: var(--paper-accent); text-transform: uppercase; letter-spacing: 0.06em; }
.lh-num { font-size: 14px; font-weight: 600; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.lh-meta { display: flex; justify-content: space-between; gap: 18px; font-size: 12px; } .lh-meta span { color: #6b7280; }
.billto { margin-bottom: 18px; line-height: 1.45; } .billto .eyebrow { display: block; color: #6b7280; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.doc-title { font-size: 18px; margin: 6px 0 8px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.doc-table th { font-size: 11px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; text-align: left; border-bottom: 1px solid var(--ink); padding: 6px 4px; }
.doc-table th.r { text-align: right; }
.doc-table td { padding: 7px 4px; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.doc-table.small td { padding: 4px; font-size: 12px; } .doc-table tr.tot td { font-weight: 700; border-top: 1px solid var(--ink); }
.doc-totals { margin-left: auto; width: 3.4in; display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.doc-totals div { display: flex; justify-content: space-between; } .doc-totals b { font-weight: 500; }
.doc-totals .grand { border-top: 1px solid var(--ink); padding-top: 6px; margin-top: 4px; font-size: 15px; } .doc-totals .grand b { font-weight: 700; }
.doc-totals .due b { color: var(--paper-accent); }
.doc-steps { padding-left: 18px; } .doc-steps li.done { color: #6b7280; }
.doc-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; } .doc-photos figure { margin: 0; break-inside: avoid; }
.doc-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid var(--rule); } .doc-photos figcaption { font-size: 11px; color: var(--ink-2); }
.doc-links { padding-left: 18px; word-break: break-all; }
.sum-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.kpis { display: grid; grid-template-columns: repeat(4, auto); gap: 18px; text-align: right; }
.kpis span { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280; } .kpis b { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: 1.3fr 1fr; gap: 26px; }
.terms { margin-top: 28px; font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--rule); padding-top: 10px; }
.paylink { margin-top: 18px; padding: 10px 12px; background: #f3f6fb; border-left: 3px solid var(--paper-accent); word-break: break-all; }

@media print {
  @page { size: letter; margin: 0; }
  html, body, .print-mode { background: #fff !important; padding: 0; }
  .print-bar, #toast { display: none !important; }
  .paper { box-shadow: none; width: auto; min-height: 0; margin: 0; border-radius: 0; }
  .paper::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
