:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --muted: #5e6875;
  --line: #e1e5ea;
  --accent: #c2410c;          /* oren bengkel */
  --accent-soft: #fff1e8;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101317; --surface: #181c22; --surface-2: #20252d; --text: #e7eaee; --muted: #9aa4b1;
    --line: #2b313a; --accent: #fb923c; --accent-soft: #2a1d14; --ok: #4ade80; --warn: #fbbf24;
    --bad: #f87171; --bad-soft: #2b1717; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101317; --surface: #181c22; --surface-2: #20252d; --text: #e7eaee; --muted: #9aa4b1;
  --line: #2b313a; --accent: #fb923c; --accent-soft: #2a1d14; --ok: #4ade80; --warn: #fbbf24;
  --bad: #f87171; --bad-soft: #2b1717; --shadow: none; 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(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; margin: 28px 0 10px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.1rem; color: var(--text); letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 2px 4px; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { color: var(--accent); background: var(--accent-soft); }
.search { flex: 1 1 260px; }
.search input {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
/* Telefon: topbar tak melekat (jimat skrin) & disusun: jenama + butang | nav | carian */
@media (max-width: 640px) {
  .topbar { position: static; gap: 8px 12px; }
  .topbar .brand { order: 1; }
  .topbar > .btn { order: 2; margin-left: auto; }
  .topbar .nav { order: 3; width: 100%; }
  .topbar .search { order: 4; flex-basis: 100%; }
}

/* ---------- layout ---------- */
.view { max-width: 1040px; margin: 0 auto; padding: 20px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 24px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 14px; }
.head .sub { color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile .value { font-size: 1.45rem; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .note { color: var(--muted); font-size: .82rem; }
a.tile { display: block; color: inherit; }
a.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile.alert .value { color: var(--bad); }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.card > .scroll > table th:first-child, .card > .scroll > table td:first-child { padding-left: 0; }
.card > .scroll > table th:last-child, .card > .scroll > table td:last-child { padding-right: 0; }

.plate {
  display: inline-block; padding: 1px 7px; border-radius: 5px; font-weight: 750; letter-spacing: .03em;
  background: #1b1f24; color: #fff; font-size: .9em; white-space: nowrap;
}
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 650; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.ok { color: var(--ok); }

/* ---------- vehicle ---------- */
.vhead { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.vhead .plate { font-size: 1.6rem; padding: 4px 14px; border-radius: 8px; }
.vhead .model { font-size: 1.15rem; font-weight: 650; }
.contacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.contacts a, .contacts span {
  padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: .88rem; color: var(--text);
}
.timeline { display: grid; gap: 12px; }
.visit-top { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; margin-bottom: 8px; }
.visit-top .date { font-weight: 700; }
.visit-top .total { margin-left: auto; font-weight: 750; font-variant-numeric: tabular-nums; }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: flex; gap: 10px; padding: 3px 0; border-top: 1px dashed var(--line); }
.lines li:first-child { border-top: 0; }
.lines .desc { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lines .qty { color: var(--muted); white-space: nowrap; }
.remark { margin-top: 8px; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }

/* ---------- invoice ---------- */
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; }
.meta .k { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.totals { margin-left: auto; max-width: 340px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-weight: 800; font-size: 1.1rem; border-top: 2px solid var(--text); margin-top: 4px; padding-top: 8px; }
.totals .bad { color: var(--bad); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.empty, .error, .loading { padding: 28px 0; text-align: center; color: var(--muted); }
.error { color: var(--bad); }
.remark-card { margin-top: 12px; color: var(--muted); }
.voided { opacity: .55; }
.voided .total, tr.voided td.num { text-decoration: line-through; }

/* ---------- butang ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.topbar .btn { padding: 7px 12px; }
.right { margin-left: auto; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--bad); font: inherit; font-size: .85rem; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 5; margin: 14px -16px 0; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
@media (max-width: 640px) { .sticky-actions { position: static; margin: 14px 0 0; padding: 0; background: none; border: 0; backdrop-filter: none; } }
.err { color: var(--bad); font-size: .9rem; }
.ok { color: var(--ok); }
.pill.open { background: var(--accent-soft); color: var(--accent); }
.pill.void { background: var(--surface-2); color: var(--muted); }

/* ---------- borang ---------- */
.form h3 { margin-bottom: 10px; font-size: 1rem; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 14px; }
.fgrid .full { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 650; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%; min-width: 0;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
/* butang mata 👁 kotak kata laluan (ui.js) */
.pweye { position: relative; display: block; }
.pweye input { padding-right: 44px; }
.eyebtn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 38px; height: 34px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.eyebtn:hover { color: var(--text); background: var(--surface-2); }
.eyebtn:focus-visible { outline: 2px solid var(--accent); }
.eyebtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
input::-ms-reveal, input::-ms-clear { display: none; }   /* Edge ada butang mata sendiri — elak 2 butang */
/* kod pemulihan (lupa kata laluan) */
.rcode { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 10px 0;
  padding: 12px 14px; border: 2px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); }
.rcode .mono { font-size: 1.25rem; font-weight: 700; letter-spacing: .08em; color: var(--text); word-break: break-all; }
.hint { margin-top: 12px; font-size: .9rem; color: var(--muted); min-height: 1.2em; }
.savestate { margin-left: auto; font-size: .85rem; color: var(--muted); }
.savestate.ok { color: var(--ok); }
.savestate.bad { color: var(--bad); font-weight: 650; }

/* ---------- job card terbuka (utama) ---------- */
.opencards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.jobcard { display: flex; flex-direction: column; gap: 6px; color: var(--text); border-left: 4px solid var(--accent); }
.jobcard:hover { text-decoration: none; border-color: var(--accent); }
.jc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.jc-model { font-weight: 650; }
.jc-complaint { color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.jc-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: auto; gap: 8px; }

/* ---------- editor item ---------- */
.lhead, .lrow {
  display: grid; gap: 6px 8px; align-items: center;
  grid-template-columns: minmax(0, 1fr) 72px 104px 92px 108px 34px;
  grid-template-areas: "desc qty price disc total del";
}
.lhead { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.lrow { padding: 8px 0; border-bottom: 1px solid var(--line); }
.l-desc { grid-area: desc; min-width: 0; }
.l-desc .code { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
/* lajur Item code (borang pembelian) */
.lhead.withcode, .lrow.withcode {
  grid-template-columns: 190px minmax(0, 1fr) 72px 104px 92px 108px 34px;
  grid-template-areas: "code desc qty price disc total del";
}
.l-codecell { grid-area: code; min-width: 0; }
.l-codecell .l-code { width: 100%; text-transform: uppercase; font-weight: 600; }
.l-codecell .l-code::placeholder { text-transform: none; font-weight: 400; }
.l-codefix { display: block; font-weight: 650; overflow-wrap: anywhere; }
.l-codecell .stk { display: block; font-size: .72rem; color: var(--muted); }
.newtag { display: inline-block; margin-top: 3px; font-size: .68rem; font-weight: 650; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.l-qty { grid-area: qty; } .l-price { grid-area: price; } .l-disc { grid-area: disc; }
.l-total { grid-area: total; font-weight: 650; }
.l-total.neg { color: var(--bad); }
.l-del { grid-area: del; justify-self: end; width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line); background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.l-del:hover { color: var(--bad); border-color: var(--bad); }
@media (max-width: 640px) {
  .lhead { display: none; }
  .lrow { grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-areas: "desc desc desc del" "qty price disc total"; }
  .lrow.withcode { grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-areas: "code code code del" "desc desc desc desc" "qty price disc total"; }
  .l-del { width: 34px; height: 34px; }
}
.adder { position: relative; margin-top: 10px; }
.adder input { padding: 10px 12px; border-style: dashed; }
.sugg {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
  max-height: 340px; overflow-y: auto;
}
.sugg li { display: flex; gap: 10px; align-items: baseline; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.sugg li.hi, .sugg li:hover { background: var(--accent-soft); }
.sugg li.sugg-head, .sugg li.sugg-head:hover { cursor: default; background: none; font-size: .78rem; font-weight: 650; color: var(--warn); padding-bottom: 2px; }
/* Unsold stock: jualan free text yg mungkin barang stok */
.ftlist { display: grid; gap: 10px; }
.ftrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.ftrow:first-child { border-top: 0; padding-top: 0; }
.ftrow .ftlinks { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 1 / -1; }
.ftrow .ftlinks .btn { text-align: left; }
@media (max-width: 640px) { .ftrow { grid-template-columns: 1fr; } }
.sugg .code { font-size: .78rem; color: var(--muted); min-width: 90px; max-width: 34%; overflow-wrap: anywhere; }
.sugg .sdesc { flex: 1; min-width: 0; }
.disc-in { width: 110px; padding: 4px 8px; }
/* kotak no plat pintar (cari semasa menaip) */
.field { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 650; color: var(--muted); }
.pwrap { position: relative; }
.pwrap input { text-transform: uppercase; }
.pwrap input::placeholder { text-transform: none; font-weight: 400; }
.pwrap .sugg { min-width: min(460px, 92vw); font-size: .9rem; font-weight: 400; color: var(--text); }
.sugg li .plate { flex: none; font-size: .8rem; }
.lastvisit { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--text);
  display: flex; gap: 10px 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.lastvisit > span { min-width: 0; flex: 1 1 260px; }

/* ---------- cetak ---------- */
.paper {
  --p-line: #c9ced6;
  background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 32px 36px;
  border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); font-size: 13px;
}
.paper a { color: inherit; }
.p-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 14px; border-bottom: 2px solid #111; }
.p-co { font-size: 20px; font-weight: 800; }
.p-small { font-size: 11.5px; color: #444; }
.pre { white-space: pre-line; }
.p-title { text-align: right; font-size: 18px; font-weight: 800; letter-spacing: .06em; }
.p-no { font-size: 15px; letter-spacing: 0; }
.p-title .p-small { font-weight: 400; letter-spacing: 0; }
.p-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--p-line); }
.p-meta span { display: block; font-size: 10.5px; color: #555; text-transform: uppercase; letter-spacing: .05em; }
.p-box { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--p-line); border-radius: 4px; min-height: 60px; }
.p-items { margin-top: 14px; }
.p-items th { color: #333; border-bottom: 1.5px solid #111; font-size: 10.5px; }
.p-items td { border-bottom: 1px solid var(--p-line); padding: 6px 8px; }
.p-items tr.blank td { height: 26px; }
.p-items .tick { width: 50px; text-align: center; }
.p-items th:first-child, .p-items td:first-child { width: 28px; color: #555; }
.p-code { font-size: 10.5px; color: #666; }
.p-totals { margin: 14px 0 0 auto; max-width: 320px; }
.p-totals div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.p-grand { font-weight: 800; font-size: 15px; border-top: 1.5px solid #111; margin-top: 4px; padding-top: 6px !important; }
.p-bal { font-weight: 700; border-top: 1px solid var(--p-line); margin-top: 4px; }
.p-foot { margin-top: 28px; text-align: center; color: #444; font-size: 12px; }
.p-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 56px; }
.p-sign div { border-top: 1px solid #111; padding-top: 6px; font-size: 11.5px; color: #444; }
@media (max-width: 640px) {
  .paper { padding: 18px 16px; }
  .p-meta { grid-template-columns: 1fr 1fr; }
}
@page { size: A4; margin: 12mm; }
@media print {
  .topbar, .foot, .noprint { display: none !important; }
  body { background: #fff; }
  .view { max-width: none; padding: 0; }
  .paper { border: 0; box-shadow: none; padding: 0; max-width: none; }
}

/* ---------- pembelian / belanja ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .filters input[type=search] { width: auto; flex: 1 1 160px; max-width: 280px; }
.filters input[type=search] { max-width: 320px; }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.radios { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.radios label { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: .95rem; font-weight: 500; color: var(--text); cursor: pointer; }
.radios input { width: auto; margin: 0; accent-color: var(--accent); }
.vrow {
  display: grid; gap: 6px 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line);
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) 120px 34px;
  grid-template-areas: "desc acct amt del";
}
.v-desc { grid-area: desc; } .v-acct { grid-area: acct; } .v-amt { grid-area: amt; }
.vrow .l-del { grid-area: del; }
@media (max-width: 640px) {
  .vrow { grid-template-columns: 1fr 1fr 34px; grid-template-areas: "desc desc del" "acct amt amt"; }
}
tfoot th { border-top: 2px solid var(--text); border-bottom: 0; font-size: .95rem; color: var(--text); text-transform: none; letter-spacing: 0; }

/* ---------- laporan ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; color: var(--muted); font-weight: 650; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.filters .custom { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filters .custom input { width: auto; }
.filters label.check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--text); white-space: nowrap; }
.filters label.check input { width: auto; accent-color: var(--accent); }
.rep-title { margin: 16px 0 12px; }
.rep-title h2 { margin: 0 0 2px; font-size: 1.2rem; }
.rep-title .muted { font-weight: 400; }
.rep-co { display: none; font-weight: 800; }
.stmt th, .stmt td { padding: 5px 10px; border-bottom: 0; }
.stmt thead th { border-bottom: 1.5px solid var(--text); }
.stmt th:first-child { width: 55%; }
.stmt .s-h td { padding-top: 14px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; font-size: .8rem; color: var(--muted); }
.stmt .l1 td:first-child { padding-left: 14px; }
.stmt .l2 td:first-child { padding-left: 30px; font-size: .9rem; }
.stmt .l2 td.num { font-size: .9rem; color: var(--muted); }
.stmt .s-grp td { font-weight: 600; }
.stmt .s-sub td { font-weight: 650; border-top: 1px solid var(--line); }
.stmt .s-total td { font-weight: 800; border-top: 1.5px solid var(--text); border-bottom: 3px double var(--text); }
.stmt .s-gap td { height: 10px; }
.stmt td.neg, td.neg, .neg { color: var(--bad); }
.stmt .s-note { color: var(--muted); font-size: .8rem; font-weight: 400; }
.stmt a { color: inherit; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.balance-check { margin-top: 12px; font-weight: 650; font-size: .9rem; }
.balance-check.ok { color: var(--ok); }
.balance-check.bad { color: var(--bad); }
.notes { margin-top: 10px; }
.notes p { margin: 4px 0; }
.callout { padding: 10px 14px; border-radius: 8px; margin: 0 0 10px; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); }
.callout.warn { border-left: 4px solid var(--warn); }
.callout.info { border-left: 4px solid var(--accent); }
.signals { display: grid; gap: 8px; }
.signal { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.signal .dot { font-size: .9rem; line-height: 1.5; }
.signal.bad { border-left: 4px solid var(--bad); } .signal.bad .dot { color: var(--bad); }
.signal.warn { border-left: 4px solid var(--warn); } .signal.warn .dot { color: var(--warn); }
.signal.info { border-left: 4px solid var(--muted); } .signal.info .dot { color: var(--muted); }
.signal.ok { border-left: 4px solid var(--ok); } .signal.ok .dot { color: var(--ok); }
.signal .right { white-space: nowrap; }
.bar { position: relative; min-width: 150px; }
.bar span { position: absolute; inset: 2px auto 2px 0; background: var(--accent-soft); border-radius: 3px; }
.bar b { position: relative; font-weight: 600; font-variant-numeric: tabular-nums; }
.card h3 { margin-bottom: 8px; font-size: 1rem; }
.nowrap { white-space: nowrap; }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.linkbtn.plain { color: var(--accent); }
.flash { padding: 10px 14px; margin: 0 0 12px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
tr.payrow td { background: var(--surface-2); padding: 12px; }
.newcat { padding: 12px; margin-bottom: 12px; border: 1px dashed var(--accent); border-radius: 8px; background: var(--accent-soft); }
select.saved { outline: 2px solid var(--ok); }
@media print {
  .tabs, .filters, .callout, .signal .right, .btn { display: none !important; }
  .rep-co { display: block; }
  .stmt { font-size: 12px; }
  .card { box-shadow: none; border: 0; padding: 0; }
  a { color: inherit !important; text-decoration: none !important; }
}
/* stok semasa dlm carian item & baris */
.stk { font-size: .78rem; white-space: nowrap; font-weight: 600; }
.stk.ok { color: var(--ok); }
.stk.bad { color: var(--bad); }
.stk.muted { color: var(--muted); font-weight: 400; }
.l-desc .code .stk { display: inline; }
/* ---------- login & peranan ---------- */
body.locked .topbar, body.locked .foot { display: none; }
.is-staff [data-admin] { display: none !important; }
.authbox { max-width: 400px; margin: 8vh auto 0; display: grid; gap: 14px; }
.auth-brand { font-weight: 800; font-size: 1.15rem; text-align: center; }
.authbox .form { display: grid; gap: 12px; padding: 22px; }
.authbox h1 { margin: 0 0 4px; font-size: 1.35rem; }
.authbox input { font-size: 1rem; padding: 10px 12px; font-weight: 400; }
.authbox .btn.primary { padding: 10px 18px; font-size: 1rem; }
.narrow { max-width: 460px; }
.narrow .form { display: grid; gap: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .03em; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px;
  border-radius: 999px; border: 1px solid var(--line); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu .avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px; display: grid; gap: 2px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(0, 0, 0, .18); }
.usermenu .menu > div { padding: 4px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.usermenu .menu a, .usermenu .menu button { text-align: left; padding: 8px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--surface-2); text-decoration: none; }
@media (max-width: 640px) { .usermenu #whoami { display: none; } }
@media (max-width: 640px) { .topbar .usermenu { order: 2; } .usermenu .menu { right: -8px; } }
.usermenu { margin-left: auto; }   /* kalau topbar berbalut ke baris baru, menu kekal di kanan */
/* ---------- logo kedai ---------- */
.brand-logo { height: 34px; max-width: 180px; display: block; border-radius: 6px; object-fit: contain; }
.logo-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.logo-box { width: 240px; max-width: 100%; min-height: 80px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 10px; padding: 8px; background: var(--surface-2); }
.logo-box img { max-width: 100%; max-height: 90px; display: block; border-radius: 6px; }
.logo-box.big { width: 420px; }
.logo-box.big img { max-height: 140px; }
.logo-row .btn { display: inline-flex; cursor: pointer; }
.icon-choices { display: flex; gap: 12px; flex-wrap: wrap; }
.icon-choices label { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; }
.icon-choices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.icon-choices img { width: 72px; height: 72px; border-radius: 16px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.p-logo { max-height: 60px; max-width: 280px; display: block; margin-bottom: 6px; border-radius: 4px; }
.auth-logo { max-width: 300px; max-height: 110px; display: block; margin: 0 auto; border-radius: 10px; }
.search { flex: 1 1 180px; min-width: 150px; }   /* topbar muat satu baris di skrin 1280px */
/* butang Log out terus di bar atas (owner tak jumpa dlm menu) */
.logout-btn { padding: 7px 12px; }
.usermenu summary::after { content: '▾'; margin-left: 2px; color: var(--muted); font-size: .8rem; }
@media (max-width: 640px) { .topbar .logout-btn { order: 2; } .logout-btn span { display: none; } }

/* ---------- progress kerja (job card / quotation) ---------- */
.pill.stage { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill.stage.big { font-size: .9rem; padding: 3px 12px; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.stage-btn { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.stage-btn:hover { border-color: var(--muted); }
.stage-btn.on { border-color: var(--ok); color: var(--ok); }
.stage-btn.pick { background: var(--accent); border-color: var(--accent); color: #fff; }
.plog { list-style: none; margin: 12px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 8px; }
.plog li { position: relative; }
.plog li::before { content: ''; position: absolute; left: -20px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.plog li:first-child::before { background: var(--ok); }

/* ---------- quotation ---------- */
#qff { margin: 0 0 12px; }
.aline { margin-bottom: 10px; display: grid; gap: 10px; }
.aline-top { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; justify-content: space-between; }
.achoices { display: flex; flex-wrap: wrap; gap: 8px; }
.achoices label { flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; color: var(--text); font-size: .9rem; }
.achoices label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.achoices input { width: auto; accent-color: var(--accent); }
.aline .adder { position: relative; }

/* ---------- portal customer: skrin admin ---------- */
.linkbox { padding: 6px 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: .9rem; overflow-wrap: anywhere; }
.preq { margin-bottom: 10px; }
.preq-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.pcar { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-bottom: 4px; }

/* ---------- portal customer (/my) ---------- */
.pt-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.pt-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; color: var(--text); }
.pt-brand:hover { text-decoration: none; }
.pt-brand img { max-height: 40px; max-width: 200px; border-radius: 6px; }
.pt-view { max-width: 640px; }
.portal .authbox { margin-top: 4vh; }
.portal .form input { font-size: 1rem; padding: 10px 12px; }
.plates { display: grid; gap: 8px; }
.center { text-align: center; }
.plate.big { font-size: 1.15rem; padding: 3px 10px; border-radius: 7px; }
.pcards { display: grid; gap: 10px; }
.pcard { display: flex; align-items: center; gap: 14px; color: inherit; }
.pcard:hover { text-decoration: none; border-color: var(--accent); }
.pcard-body { flex: 1; min-width: 0; }
.pcard.waiting { opacity: .85; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chev { font-size: 1.6rem; color: var(--muted); line-height: 1; }
.job { margin-bottom: 12px; display: grid; gap: 10px; }
.job-top { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.stepper li { flex: 1; min-width: 0; text-align: center; font-size: .72rem; color: var(--muted); }
.stepper li::before { content: ''; display: block; height: 6px; border-radius: 3px; background: var(--line); margin-bottom: 5px; }
.stepper li.done::before { background: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.stepper li.now { color: var(--ok); font-weight: 700; }
.stepper li.now::before { background: var(--ok); }
.stepper span { display: block; overflow-wrap: anywhere; line-height: 1.25; }
.quote { margin-bottom: 12px; }
.visit { margin-bottom: 10px; }
.visit summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; cursor: pointer; list-style: none; }
.visit summary::-webkit-details-marker { display: none; }
.visit summary .date { font-weight: 700; }
.visit summary .total { margin-left: auto; font-weight: 750; font-variant-numeric: tabular-nums; }
.visit[open] summary { margin-bottom: 4px; }
.receipts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
details > summary.small { cursor: pointer; color: var(--accent); font-weight: 600; }
@media (max-width: 420px) { .stepper li { font-size: .66rem; } }

/* ---------- staff biasa (mekanik): tiada harga ---------- */
.lhead.noprice, .lrow.noprice { grid-template-columns: minmax(0, 1fr) 90px 34px; grid-template-areas: "desc qty del"; }
@media (max-width: 640px) { .lrow.noprice { grid-template-columns: minmax(0, 1fr) 80px 34px; grid-template-areas: "desc qty del"; } }
.is-mech [data-manager] { display: none !important; }

/* Manager sahaja (admin buka melalui Settings) */
body:not(.is-manager) [data-mgr-only] { display: none !important; }

/* ---------- medan kereta: jenama / model / varian ---------- */
.carfield { grid-column: span 2; gap: 6px; }
@media (max-width: 640px) { .carfield { grid-column: auto; } }
.carrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.carfield input, .carfield select { font-weight: 400; color: var(--text); }

/* ---------- mata ganjaran (kaunter) ---------- */
.ptsbox { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line)); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.ptsbox .ptsuse { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.ptsbox select { width: auto; }
.points-card { display: flex; align-items: center; gap: 14px; }
.points-card .big { font-size: 1.6rem; font-weight: 800; color: var(--warn); }

/* ---------- kategori / laporan / customer ---------- */
.bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.barcell { width: 28%; }
.cat-pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text); }
.cat-pill.sugg { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.bulkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.bulkbar select { width: auto; }
td.chk, th.chk { width: 28px; }
td.chk input, th.chk input { width: auto; }
.rule-row { display: grid; gap: 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; }
.rule-top { display: grid; grid-template-columns: minmax(140px, 1fr) 110px 60px 34px; gap: 8px; align-items: end; }
.rule-row .l-del { grid-area: auto; }
.rule-row .adder { margin-top: 2px; }
.rule-row .sugg li.on { color: var(--muted); }
.rule-row .sugg li.on .sdesc::before { content: '✓ '; color: var(--ok); font-weight: 700; }
.ihint { font-weight: 400; }
.ichips { display: flex; flex-wrap: wrap; gap: 6px; }
.ichips:empty { display: none; }
.ichip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--accent-soft);
  color: var(--text); font-size: .82rem; font-weight: 500; max-width: 100%; }
.ichip .code { color: var(--muted); font-size: .72rem; }
.ichip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 4px; }
.ichip button:hover { color: var(--bad); }
@media (max-width: 760px) { .rule-top { grid-template-columns: 1fr 90px 34px; } .rule-top .field.small { order: 1; grid-column: 1 / -1; flex-direction: row; gap: 8px; } }
.pt-bday { padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); font-weight: 700; margin-bottom: 12px; }

/* ---------- gaji / slip gaji ---------- */
.ps-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 16px; }
@media (min-width: 1000px) { .ps-grid { grid-template-columns: minmax(0, 1fr) 340px; } }
.ps-line { display: grid; gap: 6px 10px; align-items: end; padding: 8px 0; border-bottom: 1px solid var(--line);
  grid-template-columns: minmax(0, 1fr) 84px 110px 100px 34px; grid-template-areas: "desc q r amt del" "flags flags flags flags flags"; }
.ps-desc { grid-area: desc; min-width: 0; }
.ps-type { display: block; font-size: .72rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.ps-q { grid-area: q; } .ps-r { grid-area: r; }
.ps-q, .ps-r { display: flex; flex-direction: column; font-size: .72rem; color: var(--muted); font-weight: 650; }
.ps-amt { grid-area: amt; font-weight: 650; padding-bottom: 8px; }
.ps-line .l-del { grid-area: del; margin-bottom: 4px; }
.ps-flags { grid-area: flags; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); }
.ps-flags label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.ps-flags input { width: auto; margin: 0; }
.ps-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
@media (max-width: 640px) {
  .ps-line { grid-template-columns: 1fr 1fr 1fr 34px; grid-template-areas: "desc desc desc del" "q r amt amt" "flags flags flags flags"; }
}
.ps-stat { width: 100%; }
.ps-stat td { vertical-align: top; padding: 4px 4px 4px 0; }
.ps-stat input { width: 100%; text-align: right; }
.ps-stat input.edited { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.ps-totals { margin-top: 12px; }
.ps-totals .row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.ps-totals .row.big { font-size: 1.25rem; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.ps-totals .neg { color: var(--bad); }
.ps-net { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 14px 18px;
  border: 1px solid var(--accent); background: var(--accent-soft); font-weight: 700; }
.ps-net b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
tr.total td { border-top: 1.5px solid var(--text); }
.remit .tile .value { font-size: 1.25rem; }
.monthnav { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.monthnav select { width: auto; min-width: 120px; }

/* ---------- log keluar automatik (tiada aktiviti) ---------- */
.form label.idlerow { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9rem; font-weight: 400; color: var(--text); }
.form label.idlerow input { width: 80px; }
.idlewarn { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .4); }
.idlewarn .card { max-width: 380px; text-align: center; }
.idlewarn p { margin: 8px 0 14px; }
.idlewarn .idle-left { font-variant-numeric: tabular-nums; }

/* Return (credit note / pulang ke supplier) */
.retlines input.rq, .retlines input.ra { width: 96px; padding: 6px 8px; }
.retlines input.bad { border-color: var(--bad); color: var(--bad); }
.retlines input.warn { border-color: var(--warn); }
.retlines .rcheck { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.retlines .rcheck input { width: auto; accent-color: var(--accent); }
.retlines .ramax, .retlines .rsn { white-space: nowrap; }
tr.muted td { color: var(--muted); }
