/* Wangaride Moto Spares Hub: one stylesheet for every page. */
:root {
  --charcoal: #1c1f24; --charcoal-2: #2a2e35; --charcoal-text: #c9ced6; --charcoal-muted: #8d95a2;
  --red: #b92532; --red-dark: #9c1d29; --red-soft: #fbeaec;
  --paper: #f2f3f5; --panel: #ffffff; --ink: #1f2430; --muted: #646d7a;
  --rule: #e1e4e9; --rule-strong: #c8cdd5; --steel: #a3abb8;
  --good: #1f7a45; --good-soft: #e6f3eb; --warn: #94560a; --warn-soft: #fcefd6;
  --alert: #b42318; --alert-soft: #fdecea; --info: #1f5fa8; --info-soft: #e9f1fb;
  --font-ui: "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-panel: 12px; --r-control: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font-ui); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 27px; line-height: 1.15; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
a { color: var(--red-dark); }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid rgba(185, 37, 50, .4); outline-offset: 2px; }

/* ---------- shell: sidebar on wide screens, top bar and menu on phones ---------- */
.app { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--charcoal); color: #fff; }
.topbar .brand-name { font: 600 16px var(--font-display); flex: 1; }
.menu-button { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid var(--charcoal-2); border-radius: 10px; background: var(--charcoal-2); color: #fff; cursor: pointer; }
.sidebar { display: none; background: var(--charcoal); color: var(--charcoal-text); }
.menu-open .sidebar { display: flex; position: fixed; inset: 62px 0 0 0; z-index: 25; overflow-y: auto; }
.sidebar { flex-direction: column; padding: 16px 14px 20px; gap: 6px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; }
.brand img { width: 42px; height: 42px; border-radius: 10px; background: #fff; object-fit: contain; }
.brand strong { display: block; color: #fff; font: 600 16px/1.2 var(--font-display); }
.brand span { font-size: 12px; color: var(--charcoal-muted); }
.sidebar .brand { display: none; }
.nav-group { margin-top: 10px; }
.nav-group > p { margin: 0 0 4px; padding: 0 10px; font-size: 12px; font-weight: 600; color: var(--charcoal-muted); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 8px; color: var(--charcoal-text); text-decoration: none; font-weight: 500; position: relative; }
.nav a:hover { background: var(--charcoal-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--charcoal-2); color: #fff; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--red); }
.who { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--charcoal-2); }
.who strong { color: #fff; display: block; }
.who .role { font-size: 13px; color: var(--charcoal-muted); margin-bottom: 10px; display: block; }
.who .btn { width: 100%; justify-content: center; background: transparent; color: var(--charcoal-text); border-color: #444a54; }
.who .btn:hover { background: var(--charcoal-2); color: #fff; }
.main { padding: 20px 16px 56px; max-width: 1220px; width: 100%; margin: 0 auto; }
@media (min-width: 1000px) {
  .app { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .topbar { display: none; }
  .sidebar { display: flex; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .sidebar .brand { display: flex; }
  .main { padding: 32px 36px 64px; }
}

/* ---------- page header and panels ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-panel); margin-bottom: 20px; overflow: hidden; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.panel-body { padding: 18px; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--rule); }
.cols { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.cols > .panel { margin-bottom: 0; }
@media (min-width: 900px) { .cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-wide-left { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); } }
.stack > * + * { margin-top: 20px; }

/* ---------- figures: a ruled strip of numbers, not a wall of cards ---------- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-panel); overflow: hidden; margin-bottom: 20px; }
.figures > div { padding: 14px 18px; box-shadow: 1px 1px 0 var(--rule); }
.figures span { display: block; font-size: 13px; color: var(--muted); }
.figures b { display: block; margin-top: 2px; font: 600 23px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.figures b.good { color: var(--good); } .figures b.bad { color: var(--alert); }

/* ---------- the till roll: the dashboard's signature panel ---------- */
.till { display: grid; gap: 0; }
@media (min-width: 760px) { .till { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .till-right { border-left: 1px dashed var(--rule-strong); } }
.till-left, .till-right { padding: 20px 22px; }
.till-total { font: 700 40px/1.1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.till-total small { font-size: 16px; font-weight: 600; color: var(--muted); margin-right: 6px; }
.till-note { color: var(--muted); margin: 4px 0 14px; }
.ledger { margin: 0; padding: 0; }
.ledger > div { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; }
.ledger dt { display: flex; flex: 1; align-items: baseline; gap: 8px; color: var(--muted); }
.ledger dt::after { content: ""; flex: 1; border-bottom: 2px dotted var(--rule-strong); transform: translateY(-3px); }
.ledger dd { margin: 0; font: 600 16px var(--font-display); font-variant-numeric: tabular-nums; }
.ledger .total { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--rule-strong); }
.ledger .total dt, .ledger .total dd { color: var(--ink); font-weight: 700; }
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; height: 150px; margin-top: 12px; }
.bar { display: flex; flex-direction: column; min-width: 0; }
.bar-track { flex: 1; display: flex; align-items: flex-end; }
.bar-track i { display: block; width: 100%; height: var(--h); min-height: 3px; background: var(--steel); border-radius: 6px 6px 0 0; }
.bar.today .bar-track i { background: var(--red); }
.bar span { margin-top: 6px; font-size: 12px; text-align: center; color: var(--muted); }
.bar.today span { color: var(--ink); font-weight: 600; }

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 1px solid var(--rule-strong); border-radius: var(--r-control); background: #fff; color: var(--ink); font: 600 14px var(--font-ui); text-decoration: none; cursor: pointer; }
.btn:hover { background: #f6f7f9; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-danger { color: var(--alert); border-color: #eec2bd; }
.btn-danger:hover { background: var(--alert-soft); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label { font-weight: 600; font-size: 14px; }
.input, .select { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: var(--r-control); background: #fff; color: var(--ink); font: 16px var(--font-ui); }
.input:focus, .select:focus { border-color: var(--red); outline: 3px solid rgba(185, 37, 50, .25); outline-offset: 0; }
.input-small { min-height: 36px; font-size: 14px; padding: 0 8px; }
.hint { font-size: 13px; color: var(--muted); }
.form-row { display: grid; gap: 0 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .form-row { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } }
.search { position: relative; max-width: 420px; }
.search .icon { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search .input { padding-left: 40px; }

/* ---------- messages, badges ---------- */
.alert { padding: 12px 16px; border: 1px solid; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.alert-error { background: var(--alert-soft); color: #86190f; border-color: #f0c2bd; }
.alert-success { background: var(--good-soft); color: #165c33; border-color: #bfdfcb; }
.alert-info { background: var(--info-soft); color: #174a82; border-color: #c4d8f0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eceef2; color: #414a58; white-space: nowrap; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-alert { background: var(--alert-soft); color: var(--alert); }
.badge-owner { background: var(--charcoal); color: #fff; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font: 600 17px var(--font-display); margin-bottom: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { padding: 10px 16px; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--rule-strong); white-space: nowrap; background: #fafbfc; }
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafbfc; }
table.data th.num { text-align: right; }
table.data tfoot td { font-weight: 700; background: #fafbfc; border-top: 1px solid var(--rule-strong); }
.share { display: block; height: 6px; margin-top: 6px; border-radius: 3px; background: var(--rule); min-width: 80px; }
.share i { display: block; height: 100%; border-radius: 3px; background: var(--red); width: var(--w); }
.row-form { display: contents; }
.table-input { width: 100px; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- period filters and pages ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 20px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule-strong); border-radius: 999px; overflow: hidden; background: #fff; }
.seg a { padding: 8px 15px; font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; }
.seg a + a { border-left: 1px solid var(--rule); }
.seg a:hover { background: #f3f4f6; }
.seg a[aria-current="true"] { background: var(--charcoal); color: #fff; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.range label { font-size: 13px; color: var(--muted); }
.range .input { width: auto; min-height: 38px; font-size: 14px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--rule); }
.pager nav { display: flex; flex-wrap: wrap; gap: 6px; }
.pager a, .pager span.gap { min-width: 36px; min-height: 36px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--rule-strong); border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; background: #fff; }
.pager a:hover { background: #f3f4f6; }
.pager a[aria-current="page"] { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.pager span.gap { border: 0; background: transparent; color: var(--muted); }
.pager a[aria-disabled="true"] { opacity: .4; pointer-events: none; }

/* ---------- selling screen ---------- */
.sell-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 16px; }
.sell-tools .search { flex: 1 1 260px; }
.mine { color: var(--muted); font-size: 14px; }
.mine b { color: var(--ink); font-family: var(--font-display); }
.catalog { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.product { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: center; padding: 12px 14px; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-panel); }
.product h3 { margin: 0; font: 600 16px/1.3 var(--font-ui); overflow-wrap: anywhere; }
.product .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 3px; font-size: 14px; color: var(--muted); }
.price { font: 700 16px var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.product.out { background: #f7f8fa; }
.product.out h3 { color: var(--muted); }
.buy { display: flex; align-items: center; gap: 8px; }
.stepper { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--r-control); overflow: hidden; background: #fff; }
.stepper button { width: 38px; border: 0; background: #f3f4f6; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink); }
.stepper button:hover { background: #e8eaee; }
.stepper input { width: 52px; border: 0; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); text-align: center; font: 600 16px var(--font-display); min-height: 42px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.line-total { grid-column: 1 / -1; margin: 0; font-weight: 600; color: var(--red-dark); min-height: 0; }
.line-total:empty { display: none; }
.line-total.error { color: var(--alert); }
dialog { width: calc(100% - 32px); max-width: 440px; padding: 0; border: 0; border-radius: 14px; box-shadow: 0 18px 60px rgba(0, 0, 0, .35); color: var(--ink); }
dialog::backdrop { background: rgba(20, 22, 26, .6); }
.dialog-body { padding: 22px; }
.dialog-body h2 { margin-bottom: 4px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.dialog-actions .btn { flex: 1 1 140px; }
.sale-line { margin: 10px 0 18px; padding: 12px 14px; border-radius: 10px; background: var(--paper); }
.sale-line b { font: 700 22px var(--font-display); display: block; }
.done-mark { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--good-soft); color: var(--good); margin-bottom: 12px; }
.done-mark .icon { width: 30px; height: 30px; stroke-width: 2.4; }

/* ---------- receipt ---------- */
.receipt { width: 340px; max-width: 100%; margin: 24px auto; padding: 22px 20px; background: #fff; border: 1px solid var(--rule); border-radius: 6px; font-family: "Cascadia Mono", Consolas, "Courier New", monospace; font-size: 14px; }
.receipt h1 { font: 700 18px/1.2 var(--font-display); text-align: center; }
.receipt .center { text-align: center; color: var(--muted); }
.receipt hr { border: 0; border-top: 1px dashed #8d95a2; margin: 14px 0; }
.receipt dl { margin: 0; } .receipt dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.receipt dt { color: var(--muted); } .receipt dd { margin: 0; text-align: right; }
.receipt .grand { font-size: 18px; font-weight: 700; }
.receipt-tools { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }

/* ---------- sign-in page ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--charcoal); }
.auth-card { width: min(100%, 920px); display: grid; border-radius: 20px; overflow: hidden; box-shadow: 0 24px 80px rgba(0, 0, 0, .4); }
@media (min-width: 760px) { .auth-card { grid-template-columns: 1.05fr 1fr; } }
.auth-brand { padding: 36px 32px; background: var(--charcoal-2); color: #fff; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.auth-brand img { width: 120px; height: 120px; object-fit: contain; border-radius: 16px; background: #fff; }
.auth-brand h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.12; }
.auth-brand p { color: var(--charcoal-text); margin: 0; }
.auth-form { padding: 40px 34px; background: #fff; }
.auth-form h2 { font-size: 26px; margin-bottom: 6px; }
.auth-form .lead { color: var(--muted); margin-bottom: 24px; }
.auth-form .btn-primary { width: 100%; min-height: 48px; font-size: 16px; }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 78px; }
.password-wrap .toggle { position: absolute; right: 6px; top: 6px; min-height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--red-dark); font: 600 13px var(--font-ui); cursor: pointer; }

/* ---------- print: reports and receipts without the menus ---------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .no-print, .alert, .pager nav, .filters { display: none !important; }
  .app { display: block; } .main { padding: 0; max-width: none; }
  .panel, .figures { border-color: #bbb; break-inside: avoid; }
  .receipt { border: 0; margin: 0 auto; } .receipt-tools { display: none; }
}

[hidden] { display: none !important; }

/* ---------- phones ---------- */
@media (max-width: 700px) {
  .hide-narrow { display: none; }
  .page-head h1 { font-size: 24px; }
  .till-total { font-size: 34px; }
  .figures b { font-size: 20px; }
  /* editable tables turn each row into a small card, so nothing needs sideways scrolling */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; }
  table.cards thead { display: none; }
  table.cards tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--rule); }
  table.cards tbody tr:last-child { border-bottom: 0; }
  table.cards td { padding: 0; border: 0; min-width: 0; }
  table.cards td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; font-size: 12px; color: var(--muted); }
  table.cards td.wide { grid-column: 1 / -1; }
  table.cards .table-input, table.cards .input { width: 100%; }
  table.cards .table-actions .btn { flex: 1; min-height: 40px; }
  /* selling screen: controls on their own row so part names get the full width */
  .product { grid-template-columns: minmax(0, 1fr); }
  .buy { justify-content: space-between; }
  .buy .sell-btn { flex: 1; min-height: 44px; }
  .stepper input { min-height: 44px; }
  .stepper button { width: 44px; }
}

/* ---------- refunds, customers, quick buttons ---------- */
.badge-refund { background: #fde8ea; color: #9c1d29; }
tr.refund-row td { background: #fff8f8; }
.neg { color: var(--alert); }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.chip { min-height: 34px; padding: 0 13px; border: 1px solid var(--rule-strong); border-radius: 999px; background: #fff; color: var(--ink); font: 600 13px var(--font-ui); cursor: pointer; }
.chip:hover { background: #f3f4f6; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--red); flex: none; }
.refund-amount { padding: 12px 14px; border-radius: 10px; background: var(--paper); margin-bottom: 16px; }
.refund-amount b { display: block; font: 700 24px var(--font-display); }

.show-narrow { display: none; }
@media (max-width: 700px) { .show-narrow { display: block; } }
.check .hint { font-weight: 400; }

/* period and search fields: tidy on any width */
.range { align-items: flex-end; }
.range-field { display: grid; gap: 4px; }
.range-field label { font-size: 13px; color: var(--muted); }
@media (max-width: 700px) {
  .seg { flex-wrap: nowrap; width: 100%; }
  .seg a { flex: 1; text-align: center; padding: 9px 4px; font-size: 13px; white-space: nowrap; }
  .range { width: 100%; }
  .range-field { flex: 1 1 140px; }
  .range-field.wide { flex-basis: 100%; }
  .range .input { width: 100%; }
}
