:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #1c2330; --muted: #667085; --line: #e3e6ec;
  --accent: #0f5f73; --accent-ink: #ffffff; --accent-soft: #e2f1f4;
  --ok: #1d7a4a; --ok-soft: #e1f3e8; --warn: #9a6200; --warn-soft: #fff1d6; --bad: #b3261e; --bad-soft: #fde8e6; --info-soft: #e8eefb; --info: #2a4db1;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d; --panel: #1b212b; --ink: #e8ecf3; --muted: #9aa5b6; --line: #2b3340;
    --accent: #4fb3c9; --accent-ink: #0b1a1f; --accent-soft: #17323a;
    --ok: #55c789; --ok-soft: #163325; --warn: #f0b35a; --warn-soft: #3a2c10; --bad: #ff8a80; --bad-soft: #3b1a18; --info-soft: #1b2744; --info: #8fb0ff;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 14px; }
.brand-logo { display: block; max-width: 100%; max-height: 54px; margin-bottom: 8px; background: #fff; border-radius: 4px; padding: 2px; }
.side a.nav { display: block; padding: 9px 10px; border-radius: 8px; color: var(--ink); }
.side a.nav:hover { background: var(--bg); text-decoration: none; }
.side a.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .spacer { flex: 1; }
.who { padding: 8px 10px; font-size: 13px; color: var(--muted); }
main { padding: 22px 26px 60px; max-width: 1180px; width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; }
.grid { display: grid; gap: 12px; } .g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } .g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tile .num { font-size: 24px; font-weight: 700; margin-top: 2px; } .tile .lbl { color: var(--muted); font-size: 13px; }
.tile.warn { background: var(--warn-soft); border-color: transparent; } .tile.bad { background: var(--bad-soft); border-color: transparent; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--bg); }
.scroll { overflow-x: auto; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

button, .btn { font: inherit; min-height: 38px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
button:hover { background: var(--bg); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); } button.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); min-height: 38px; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; min-height: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 15px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search { max-width: 360px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.b-received, .b-diagnosing { background: var(--info-soft); color: var(--info); }
.b-waiting_approval, .b-waiting_parts, .b-pending { background: var(--warn-soft); color: var(--warn); }
.b-in_progress { background: var(--accent-soft); color: var(--accent); }
.b-ready, .b-completed, .b-approved, .b-final { background: var(--ok-soft); color: var(--ok); }
.b-cancelled, .b-rejected, .b-void, .b-bad { background: var(--bad-soft); color: var(--bad); }
.b-tolerance { background: var(--info-soft); color: var(--info); }

.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--warn); } .notice.bad { background: var(--bad-soft); color: var(--bad); } .notice.ok { background: var(--ok-soft); color: var(--ok); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }
.money-box { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; max-width: 360px; } .money-box .tot { font-weight: 700; border-top: 1px solid var(--line); padding-top: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; } .timeline li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }

.overlay { position: fixed; inset: 0; background: rgba(10, 14, 20, .55); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; z-index: 20; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 520px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.picklist { border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; max-height: 200px; overflow-y: auto; }
.picklist button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 40; width: min(92vw, 460px); }
.toast { padding: 10px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--bad); color: #fff; }

.login { max-width: 400px; margin: 10vh auto; padding: 0 16px; }
.login .card { padding: 24px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 8px; } .side .spacer { display: none; } .who { padding: 4px 8px; }
  main { padding: 14px 12px 60px; }
  th, td { padding: 8px 6px; }
}

/* ---- printable quote: always black on white, like paper */
.paper { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 36px 40px; border: 1px solid #ddd; border-radius: 4px; position: relative; font-size: 14px; }
.paper table { color: #111; } .paper th, .paper td { border-color: #ccc; }
.paper-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.paper-logo { display: block; max-height: 72px; max-width: 240px; margin-bottom: 8px; }
.paper-biz { font-size: 20px; font-weight: 700; } .paper-sub { color: #555; }
.paper-meta { text-align: right; } .paper-title { font-size: 22px; font-weight: 700; letter-spacing: .04em; margin-bottom: 4px; }
.paper-biz-details { margin: 10px 0 18px; padding-bottom: 12px; border-bottom: 2px solid #111; color: #333; font-size: 13px; }
.paper-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 14px; }
.paper-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #666; } .paper-strong { font-weight: 700; }
.paper-job { margin-bottom: 10px; }
.paper-totals { margin: 12px 0 0 auto; min-width: 280px; } .paper-totals td { padding: 4px 8px; }
.paper-grand td { font-weight: 700; font-size: 16px; border-top: 2px solid #111; }
.paper-terms { margin-top: 22px; font-size: 12.5px; color: #333; }
.paper-sign { display: flex; justify-content: space-between; margin-top: 56px; color: #555; font-size: 12.5px; }
.paper-sign > div { border-top: 1px solid #888; padding-top: 4px; min-width: 240px; }
.paper-stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%,-50%) rotate(-18deg); font-size: 54px; font-weight: 800; color: rgba(179,38,30,.22); border: 6px solid rgba(179,38,30,.22); padding: 4px 24px; pointer-events: none; }
@media print {
  .side, .no-print, .toasts { display: none !important; }
  .shell { display: block; } main { padding: 0; max-width: none; }
  html, body { background: #fff; }
  .paper { border: none; padding: 0; max-width: none; }
}
