/* TechPumps — fast, plain, readable. No framework. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #16191f;
  --ink-2: #4a5160;
  --muted: #7a8291;
  --line: #e0e3e8;
  --line-2: #cfd4db;
  --brand: #0b5cad;
  --brand-ink: #ffffff;
  --brand-soft: #e6f0fa;
  --bar: #3d7cc9;
  --good: #1f7a3f; --good-bg: #e5f4ea;
  --warn: #8a5a00; --warn-bg: #fdf1d8;
  --bad: #b3261e;  --bad-bg: #fbe6e4;
  --info: #0b5cad; --info-bg: #e6f0fa;
  --neutral-bg: #eceef1;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #1a1e24; --surface-2: #20252c; --ink: #e8eaed; --ink-2: #b8bec8; --muted: #8b93a1;
    --line: #2c323b; --line-2: #3a414c; --brand: #4b9be8; --brand-ink: #0b1220; --brand-soft: #1b2b3d; --bar: #5b9be0;
    --good: #6fcf8f; --good-bg: #183324; --warn: #f0c060; --warn-bg: #3a2e14; --bad: #f2867e; --bad-bg: #3e1d1b;
    --info: #7ab6f0; --info-bg: #1b2b3d; --neutral-bg: #2a3038; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
small, .muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; max-width: 1400px; margin: 0 auto; }
.logo { font-weight: 800; color: var(--ink); font-size: 1.05rem; white-space: nowrap; }
.logo span { color: var(--brand); }
.gsearch { flex: 1; max-width: 560px; position: relative; }
.gsearch input { width: 100%; padding: .55rem .75rem .55rem 2rem; border-radius: 999px; background: var(--surface-2); }
.gsearch::before { content: "⌕"; position: absolute; left: .7rem; top: .35rem; color: var(--muted); font-size: 1.1rem; }
.gsearch kbd { position: absolute; right: .6rem; top: .55rem; }
.userbox { margin-left: auto; display: flex; gap: .5rem; align-items: center; white-space: nowrap; font-size: .9rem; }
.nav { display: flex; gap: .15rem; padding: 0 1rem; max-width: 1400px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: .5rem .75rem; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.nav a:hover { text-decoration: none; color: var(--ink); }
.nav a.on { color: var(--brand); border-bottom-color: var(--brand); }
.nav .sep { width: 1px; background: var(--line); margin: .5rem .35rem; }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3rem; color: var(--muted); background: var(--surface); }

main { max-width: 1400px; margin: 0 auto; padding: 1rem; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }

/* ---------- cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 960px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } main { padding: .75rem; } .gsearch kbd, .hide-sm { display: none; } }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; display: block; color: var(--ink); }
a.tile:hover { text-decoration: none; border-color: var(--brand); }
.tile .k { font-size: .8rem; color: var(--ink-2); }
.tile .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .s { font-size: .78rem; color: var(--muted); }
.tile.alert { border-color: var(--bad); }
.tile.alert .v { color: var(--bad); }
.tile.warn .v { color: var(--warn); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 38px; }
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: .25rem .6rem; min-height: 30px; font-size: .85rem; }
.btn.big { padding: .8rem 1.2rem; font-size: 1.02rem; }
.btn kbd { margin-left: .2rem; }
.btn.primary kbd { color: inherit; border-color: rgba(255,255,255,.5); background: transparent; }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.quick { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- forms ---------- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; padding: .5rem .6rem; width: 100%; min-height: 38px; }
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field label, .field > .lbl { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .25rem; }
.field .req { color: var(--bad); margin-left: .15rem; }
.field .opt { color: var(--muted); font-weight: 400; font-size: .78rem; margin-left: .25rem; }
.field .help { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.field .err, .errorlist { color: var(--bad); font-size: .82rem; margin: .2rem 0 0; padding: 0; list-style: none; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--bad); }
.form-actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; align-items: center; }
.radios { display: flex; flex-wrap: wrap; gap: .4rem; }
.radios label, .radios > div > label { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .7rem; border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; font-weight: 500; font-size: .92rem; margin: 0; }
.radios label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.radios div { display: contents; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .4rem; color: var(--ink-2); font-size: .9rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.filters input, .filters select { width: auto; min-width: 140px; }
.filters input[type=search] { min-width: 220px; flex: 1; max-width: 360px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg a { padding: .4rem .75rem; color: var(--ink-2); border-right: 1px solid var(--line-2); font-size: .9rem; white-space: nowrap; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--brand); color: var(--brand-ink); }
.seg a:hover { text-decoration: none; }

/* ---------- picker (autocomplete) ---------- */
.picker { position: relative; }
.picker .chosen { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--brand); background: var(--brand-soft); border-radius: 6px; padding: .45rem .6rem; min-height: 38px; }
.picker .chosen .t { flex: 1; font-weight: 600; }
.picker .chosen .t small { font-weight: 400; margin-left: .35rem; }
.picker .chosen button { background: none; border: 0; color: var(--ink-2); cursor: pointer; font-size: .85rem; }
.ac-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 2px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.14); max-height: 340px; overflow: auto; }
.ac-item { padding: .5rem .7rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-item:last-child { border-bottom: 0; }
.ac-item .l { font-weight: 600; }
.ac-item .s { font-size: .82rem; color: var(--muted); }
.ac-item.on, .ac-item:hover { background: var(--brand-soft); }
.ac-item.add { color: var(--brand); font-weight: 700; }
.ac-empty { padding: .5rem .7rem; color: var(--muted); font-size: .9rem; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tr.inactive td { color: var(--muted); }
tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
td.actions { white-space: nowrap; text-align: right; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line-2); }
.empty { padding: 1.25rem; text-align: center; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .r { margin-left: auto; text-align: right; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; text-transform: capitalize; white-space: nowrap; background: var(--neutral-bg); color: var(--ink-2); }
.s-open, .s-received, .s-pending, .s-in_progress { background: var(--info-bg); color: var(--info); }
.s-estimated { background: var(--warn-bg); color: var(--warn); }
.s-in_repair, .s-approved { background: var(--warn-bg); color: var(--warn); }
.s-ready, .s-converted, .s-closed, .s-delivered, .s-finished, .s-active { background: var(--good-bg); color: var(--good); }
.s-lost, .s-cancelled, .s-returned, .s-inactive, .s-overdue { background: var(--bad-bg); color: var(--bad); }
.tag { display: inline-block; padding: .05rem .4rem; border-radius: 4px; font-size: .75rem; background: var(--neutral-bg); color: var(--ink-2); }
.code { font-family: ui-monospace, monospace; font-weight: 700; color: var(--ink); }
a .code { color: var(--brand); }

/* ---------- messages ---------- */
.msgs { list-style: none; padding: 0; margin: 0 0 1rem; }
.msgs li { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .4rem; border: 1px solid; }
.msgs .success { background: var(--good-bg); color: var(--good); border-color: transparent; }
.msgs .error { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.msgs .info, .msgs .warning { background: var(--info-bg); color: var(--info); border-color: transparent; }
.note { padding: .6rem .8rem; border-radius: 6px; background: var(--surface-2); border: 1px dashed var(--line-2); font-size: .9rem; }
.note.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

/* ---------- definition lists ---------- */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; font-weight: 500; white-space: pre-line; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { border-left: 3px solid var(--line-2); padding: .25rem 0 .9rem 1rem; position: relative; }
.tl-item::before { content: ""; position: absolute; left: -7px; top: .55rem; width: 11px; height: 11px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }
.tl-item.k-enquiry::before { border-color: var(--good); }
.tl-item.k-ic::before { border-color: var(--warn); }
.tl-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tl-sub { margin: .35rem 0 0 .25rem; padding-left: .9rem; border-left: 2px dotted var(--line-2); }
.tl-body { font-size: .9rem; color: var(--ink-2); margin-top: .2rem; }

/* ---------- bars (single-hue magnitude) ---------- */
.bar { height: 8px; background: var(--neutral-bg); border-radius: 4px; min-width: 60px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }
td.barcell { width: 30%; min-width: 90px; vertical-align: middle; }
.small-n { color: var(--warn); font-size: .75rem; cursor: help; }
.trend { display: flex; gap: 4px; align-items: flex-end; height: 90px; padding-top: .5rem; }
.trend .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 2px; }
.trend .col i { display: block; width: 100%; max-width: 34px; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 2px; }
.trend .col span { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.trend .col b { font-size: .75rem; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem .8rem; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; }

/* ---------- modal ---------- */
dialog.modal { border: 0; border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.modal::backdrop { background: rgba(10, 15, 25, .45); }
.modal-head { display: flex; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-head button { margin-left: auto; }
.modal-body { padding: 1rem; max-height: 70vh; overflow: auto; }

/* ---------- estimate table ---------- */
.est td { padding: .3rem .35rem; vertical-align: middle; }
.est input { min-height: 34px; padding: .35rem .45rem; }
.est .c-tn { width: 150px; } .est .c-qty { width: 80px; } .est .c-rate { width: 110px; } .est .c-amt { width: 110px; } .est .c-rm { width: 170px; } .est .c-x { width: 34px; }
.est .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.est-total { font-size: 1.3rem; font-weight: 800; }
.est .ac-list { min-width: 360px; }
@media (max-width: 760px) {
  .est thead { display: none; }
  .est tr { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
  .est td { border: 0; padding: 0; width: auto !important; }
  .est td.c-desc, .est td.c-rm { grid-column: 1 / -1; }
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); }
.print-only { display: none; }
@media print {
  .topbar, .no-print, .msgs { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; }
  main { padding: 0; }
}
