/* ============================================================
   CC Vision Stock — design tokens (from the Ray&Co POS, recoloured to the CC Vision logo)
   Old token names (--bg, --blue, …) are kept as aliases so page
   scripts that build inline styles keep working.
   ============================================================ */
:root {
  --ground: #F4F5F2;
  --surface: #FFFFFF;
  --surface-2: #F8F9F6;
  --surface-3: #EEF1EA;
  --line: #E3E6DE;
  --line-strong: #CDD2C5;
  --ink: #161815;
  --ink-2: #3D4239;
  --muted: #6B7066;
  --nav: #111210;
  --nav-ink: #CDD1C8;
  --nav-label: #868C80;
  --gold: #A6CE39;            /* CC Vision logo green */
  --accent: #4E7A10;          /* darker logo green: white text stays readable */
  --accent-hover: #3F650B;
  --accent-soft: #EEF6DC;
  --brand: #A6CE39;           /* main buttons and active tabs: logo green with black text */
  --brand-hover: #94BC2A;
  --brand-ink: #161815;
  --good: #1F8A55;
  --good-soft: #E3F3EA;
  --warn: #B7791F;
  --warn-soft: #FBF0DC;
  --bad: #C8372D;
  --bad-soft: #FBE6E4;
  --card-blue: #7C9A3A;
  --shadow: 0 1px 2px rgba(22, 24, 21, .06), 0 4px 16px rgba(22, 24, 21, .04);
  --radius: 10px;
  --font: "Segoe UI", "Noto Sans Thai", -apple-system, sans-serif;
  --mono: var(--font);

  /* legacy aliases */
  --bg: var(--ground);
  --bg-elev: var(--surface);
  --bg-elev-2: var(--surface-2);
  --bg-elev-2-hover: var(--surface-3);
  --border: var(--line);
  --text: var(--ink);
  --text-muted: var(--muted);
  --blue: var(--accent);
  --blue-hover: var(--accent-hover);
  --blue-bg: var(--accent-soft);
  --green: var(--good);
  --green-bg: var(--good-soft);
  --amber: var(--warn);
  --amber-bg: var(--warn-soft);
  --purple: #7A4FD6;
  --purple-bg: #F0EAFC;
  --red: var(--bad);
  --red-bg: var(--bad-soft);
  --disabled-bg: #D8DCD2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  background: var(--ground);
  color: var(--ink);
}
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; }
code, .mono { font-family: var(--mono); font-size: .92em; }
td.mono, td > .mono { white-space: nowrap; }
#sales-body td:first-child, #sales-body td:first-child .t-sub { white-space: nowrap; }
.num, td, .totals, .kpi-value { font-variant-numeric: tabular-nums; }
.icon { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   App shell: sidebar + top line + main
   ============================================================ */
.app-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--nav); color: var(--nav-ink);
  padding: 18px 12px 14px; display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-brand { display: block; padding: 4px 8px 6px; }
.side-brand img { display: block; width: 100%; max-width: 188px; height: auto; }
.side-brand small { display: block; color: var(--nav-label); font-size: 11.5px; margin-top: 4px; letter-spacing: .02em; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--nav-label); padding: 0 10px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; border-radius: 8px; padding: 8px 10px;
  color: var(--nav-ink); text-decoration: none; font-size: 14px; line-height: 1.3;
}
.nav-link svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link[aria-current="page"] { background: rgba(166, 206, 57, .16); color: #fff; font-weight: 600; }
.nav-link[aria-current="page"] svg { color: var(--gold); }
.nav-link .nav-count { margin-left: auto; font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 0 8px; background: #3B4A12; color: #C8E57A; }
.nav-link .nav-count.plain { background: transparent; border: 1px solid #3A3D36; color: #A9AEA3; }
.nav-link .nav-key { margin-left: auto; font-family: var(--mono); font-size: 10.5px; border: 1px solid #3A3D36; border-radius: 4px; padding: 0 5px; color: #8E9488; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .08); padding: 12px 6px 0; }
#user-badge { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--nav-ink); flex-wrap: wrap; }
#user-badge .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: var(--nav); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
#user-badge .who { flex: 1; min-width: 0; }
#user-badge .name { display: block; color: #fff; font-weight: 600; line-height: 1.2; }
#user-badge .role-tag { font-size: 11.5px; color: var(--nav-label); }
#user-badge button { background: transparent; border: 1px solid #3A3D36; color: var(--nav-ink); padding: 5px 9px; font-size: 12px; font-weight: 500; }
#user-badge button:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.topline {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 28px; background: rgba(243, 245, 248, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.global-search { position: relative; flex: 1; max-width: 440px; }
.global-search input {
  margin: 0; padding: 7px 64px 7px 34px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; font-size: 13.5px;
}
.global-search > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 1.8; pointer-events: none; }
.global-search .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.global-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(22, 24, 21, .16);
  max-height: 420px; overflow-y: auto; padding: 6px; color: var(--ink);
}
.global-results .gr-head { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 8px 4px; }
.global-results a { display: flex; gap: 10px; align-items: baseline; padding: 7px 8px; border-radius: 6px; text-decoration: none; }
.global-results a:hover, .global-results a.active { background: var(--accent-soft); }
.global-results a small { color: var(--muted); margin-left: auto; white-space: nowrap; }
.global-results .gr-empty { padding: 10px 8px; color: var(--muted); }
.topline-right { margin-left: auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; }
.app-clock { font-variant-numeric: tabular-nums; white-space: nowrap; }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); background: var(--surface); white-space: nowrap; }

main { padding: 24px 28px 40px; width: 100%; max-width: 1400px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; gap: 6px; align-items: center; }
  .side-brand { flex: none; width: 120px; padding: 0 4px; }
  .side-brand small, .nav-label { display: none; }
  .nav-group { flex-direction: row; }
  .nav-link { white-space: nowrap; padding: 6px 10px; }
  .side-foot { margin: 0; border: 0; padding: 0 0 0 8px; flex: none; }
  .topline { position: static; padding: 10px 16px; }
  main { padding: 18px 16px 32px; }
}

/* ============================================================
   Page header
   ============================================================ */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.page-header h2 { font-size: 24px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.page-header .subtitle { color: var(--muted); font-size: 14px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   Surfaces
   ============================================================ */
.card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.card h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }
.panel { padding: 0; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-h h2, .panel-h h3 { margin: 0; font-size: 15px; font-weight: 600; }
.panel-b { padding: 16px 18px; }
.panel-f { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.toolbar input, .toolbar select { margin: 0; width: auto; }
.toolbar input[type="search"], .toolbar .grow { flex: 1; min-width: 220px; max-width: 420px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.grid-charts { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; align-items: start; }
.grid-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-pos { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; align-items: start; }
.grid-master { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 1100px) {
  .grid-pos { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid-2, .grid-charts, .grid-master { grid-template-columns: 1fr; }
  .grid-actions { grid-template-columns: repeat(2, 1fr); }
}

/* KPI tiles */
.kpi, .stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .kpi-label, .stat-card .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .kpi-value, .stat-card .value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; margin: 0; }
.kpi .kpi-sub, .stat-card .caption { font-size: 12.5px; color: var(--muted); }
.stat-card .top { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-card .icon-box { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.stat-card .icon-box.blue { background: var(--accent-soft); color: var(--accent); }
.stat-card .icon-box.green { background: var(--good-soft); color: var(--good); }
.stat-card .icon-box.amber { background: var(--warn-soft); color: var(--warn); }
.stat-card .icon-box.purple { background: var(--purple-bg); color: var(--purple); }
.stat-card .link { color: var(--warn); font-size: 12px; text-decoration: none; font-weight: 600; }
.split-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 8px; background: var(--line); }
.split-bar i { display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--c); }
.c-card { background: var(--card-blue); } .c-transfer { background: var(--accent); } .c-cash { background: var(--good); }

/* To-do list */
.todo-list { display: flex; flex-direction: column; }
.todo-list a { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); text-decoration: none; }
.todo-list a:last-child { border-bottom: 0; }
.todo-list a:hover { background: var(--surface-2); }
.todo-list .ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.todo-list .tx { flex: 1; min-width: 0; }
.todo-list .tx b { display: block; font-weight: 600; }
.todo-list .tx span { font-size: 12.5px; color: var(--muted); }
.todo-list .chev { color: var(--muted); }

/* Quick actions (legacy dashboard) */
.action-btn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); font-weight: 600; }
.action-btn:hover { border-color: var(--accent); }
.action-btn .icon-box { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }

/* ============================================================
   Forms & buttons
   ============================================================ */
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea, button { font-size: 14px; font-family: inherit; }
input, select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  margin-bottom: 10px; background: var(--surface); color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #9AA094; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0 6px 0 0; }
textarea { font: inherit; }

button, .btn {
  cursor: pointer; border: 1px solid var(--brand); border-radius: 8px; padding: 8px 14px;
  background: var(--brand); color: var(--brand-ink); font-weight: 600; display: inline-flex; align-items: center;
  justify-content: center; gap: 7px; text-decoration: none; line-height: 1.4; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
button.secondary, .btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); font-weight: 500; }
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); }
button.danger, .btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger:hover { background: #A92D24; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
button.ghost:hover { background: var(--surface-2); color: var(--ink); }
button.big { padding: 13px 18px; font-size: 16px; width: 100%; }
button.sm, .btn.sm { padding: 4px 10px; font-size: 12.5px; }
button:disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--muted); cursor: not-allowed; }
button svg, .btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { width: 30px; height: 30px; padding: 0; background: transparent; border: 1px solid transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row > button, .row > .btn { flex: 0 0 auto; }

/* chips & segmented control */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 500; }
.chip:hover { background: var(--surface-2); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 2px; }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-2); }
.seg button { background: transparent; border: 0; color: var(--ink-2); font-weight: 500; padding: 5px 12px; border-radius: 6px; }
.seg button:hover { background: var(--surface); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 24, 21, .14); }

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--surface-2); white-space: nowrap; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.card > table, .card .table-wrap > table { margin: 0 -20px; width: calc(100% + 40px); }
.card > table th:first-child, .card > table td:first-child { padding-left: 20px; }
.card > table th:last-child, .card > table td:last-child { padding-right: 20px; }
.t-name b { display: block; font-weight: 600; }
.t-name span, .t-sub { display: block; font-size: 12.5px; color: var(--muted); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; white-space: nowrap; }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); }

/* ============================================================
   Pills, badges, status
   ============================================================ */
.pill, .badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.good, .badge.staff { background: var(--good-soft); color: var(--good); }
.pill.warn, .badge.low { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .badge.inactive { background: var(--bad-soft); color: var(--bad); }
.pill.info, .badge.admin { background: var(--accent-soft); color: var(--accent); }
.pill.plain { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.stock-low { color: var(--warn); font-weight: 700; }
.stock-out { color: var(--bad); font-weight: 700; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--bad); font-size: 14px; margin: 6px 0; }
.success { color: var(--good); font-size: 14px; margin: 6px 0; }
.empty-state { color: var(--muted); text-align: center; padding: 28px 12px; }
.staff-access-note { padding: 10px 14px; background: var(--accent-soft); color: #33520A; border-radius: 8px; font-size: 13px; margin: 0 0 16px; }
.staff-view [data-admin-write] { display: none !important; }

details summary { cursor: pointer; margin: 10px 0; color: var(--accent); font-weight: 500; }

/* search result lists */
.search-results { border: 1px solid var(--line); border-radius: 8px; max-height: 280px; overflow-y: auto; margin-bottom: 10px; background: var(--surface); }
.search-results .item { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.search-results .item:hover { background: var(--accent-soft); }
.search-results .item:last-child { border-bottom: none; }
.search-results .stock-low { color: var(--warn); font-weight: 600; }

/* totals */
.totals { font-size: 14px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.totals .line { display: flex; justify-content: space-between; padding: 3px 0; color: var(--muted); }
.totals .total { font-size: 22px; font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }

/* drawers (dialog) */
dialog.drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(520px, 100vw); border: 0; padding: 0;
  background: var(--surface); color: var(--ink); box-shadow: -12px 0 40px rgba(22, 24, 21, .18);
}
dialog.drawer::backdrop { background: rgba(22, 24, 21, .35); }
dialog.drawer .drawer-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog.drawer .drawer-h h2 { margin: 0; font-size: 18px; }
dialog.drawer .drawer-b { padding: 18px 20px; }
dialog.drawer .card { border: 0; padding: 0; margin: 0; }
dialog.drawer .card > h2 { display: none; }
dialog.drawer .row { flex-wrap: wrap; }
dialog.drawer .row > * { flex: 1 1 200px; }

/* menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; margin: 0; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > .menu-list { display: flex; }
.menu-list { display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; flex-direction: column; min-width: 180px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 28px rgba(22, 24, 21, .16); padding: 4px; }
.menu-list a, .menu-list button { background: none; border: 0; color: var(--ink); justify-content: flex-start; font-weight: 500; padding: 8px 10px; border-radius: 6px; text-decoration: none; display: flex; }
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); }
.menu-list .danger-item { color: var(--bad); }
.menu-list .danger-item:hover { background: var(--bad-soft); }

/* ============================================================
   Charts
   ============================================================ */
.chart-svg { width: 100%; height: auto; overflow: visible; }
.chart-svg .grid-line { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--muted); font-size: 11px; }
.chart-svg .line-path { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart-svg .area-path { fill: var(--accent); opacity: .12; }
.chart-svg .dot { fill: var(--accent); }
.chart-svg .bar { fill: var(--accent); }
.chart-svg .bar.today { fill: var(--ink); }
.chart-svg .bar-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.chart-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 0; }
.cat-bars { display: flex; flex-direction: column; gap: 10px; }
.cat-bars .cb { display: grid; grid-template-columns: 110px 1fr 100px; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; }
.cat-bars .track { height: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.cat-bars .fill { height: 100%; background: var(--accent); border-radius: 5px; }
.cat-bars .v { text-align: right; font-weight: 600; }

.best-sellers-list { list-style: none; margin: 0; padding: 0; }
.best-seller-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.best-seller-row:last-child { border-bottom: 0; }
.best-seller-rank { flex: 0 0 28px; height: 28px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); border-radius: 8px; font-weight: 700; font-size: 13px; }
.best-seller-details { flex: 1; min-width: 0; }
.best-seller-heading { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between; margin-bottom: 8px; }
.best-seller-name { min-width: 0; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.best-seller-qty { flex-shrink: 0; white-space: nowrap; font-size: 16px; font-weight: 700; color: var(--ink); }
.best-seller-qty small { font-size: 12px; font-weight: 400; color: var(--muted); }
.best-seller-track { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.best-seller-track span { display: block; height: 100%; background: var(--good); border-radius: 6px; }

/* ============================================================
   Checkout
   ============================================================ */
.scan-box { display: flex; gap: 10px; }
.scan-box input { margin: 0; padding: 12px 14px; font-size: 16px; border-width: 2px; }
.scan-hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.product-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; max-height: 520px; overflow-y: auto; padding: 2px; align-content: start; }
.product-cards .item { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.product-cards .item:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.product-cards .item.disabled { opacity: .5; cursor: not-allowed; }
.product-cards .p-sku { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.product-cards .p-name { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.product-cards .p-meta { font-size: 12.5px; color: var(--muted); }
.product-cards .p-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.product-cards .p-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.quick-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cart-panel { position: sticky; top: 64px; }
.cart-panel .cust-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.cart-panel #cart-table th { background: transparent; padding: 6px 4px; }
.cart-panel #cart-table td { padding: 8px 3px; }
.cart-panel #cart-table th:first-child, .cart-panel #cart-table td:first-child { width: 100%; }
.cart-panel #cart-table input[data-qty] { width: 46px !important; }
.cart-panel #cart-table input[data-price] { width: 78px !important; }
.cart-panel #cart-table input { margin: 0; padding: 4px 6px; }
.disc-box { border: 1px solid var(--line); border-radius: 9px; padding: 4px 12px; margin-top: 10px; }
.disc-box > summary { color: var(--ink); display: flex; justify-content: space-between; margin: 6px 0; }
.disc-box .row { flex-wrap: wrap; }
.disc-box .row > * { flex: 1 1 140px; }
.due-line { display: flex; justify-content: space-between; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 12px; font-weight: 600; }
.receipt-banner { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.receipt-banner strong { font-size: 15px; font-weight: 600; }
#last-receipt { font-size: 14px; font-weight: 600; color: var(--accent); }
.edit-banner { border-color: var(--warn) !important; background: var(--warn-soft) !important; }
.promo-lens-btn { background: var(--surface); color: var(--good); border-color: #9BC7A3; font-weight: 600; }
.promo-lens-btn:hover { background: var(--good-soft); border-color: var(--good); }

/* ============================================================
   Customers & prescriptions
   ============================================================ */
.cust-list { max-height: calc(100vh - 230px); overflow-y: auto; }
.cust-list .item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cust-list .item:hover { background: var(--surface-2); }
.cust-list .item[aria-current="true"] { background: var(--accent-soft); }
.cust-list .item b { display: block; font-weight: 600; line-height: 1.25; }
.cust-list .item span { font-size: 12.5px; color: var(--muted); }
.initial { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); display: grid; place-items: center; font-weight: 600; flex: none; }
[aria-current="true"] > .initial { background: var(--accent); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); font-weight: 500; padding: 10px; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.rx-table { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.rx-table th, .rx-table td { text-align: center; padding: 6px 8px; }
.rx-table th:first-child, .rx-table td:first-child { text-align: left; }
.rx-table input { min-width: 70px; margin: 0; text-align: center; }
.rx-history { border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; margin: 10px 0; background: var(--surface); line-height: 1.8; }
.rx-history .rx-actions { float: right; display: flex; gap: 6px; }
.rx-history .rx-actions button { padding: 3px 10px; font-size: 12.5px; }
.grid-4 label, .grid-2 label { margin-bottom: 0; }

/* products */
.product-filter-row { flex-wrap: wrap; }
.filter-summary { display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: baseline; padding: 10px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.filter-summary .fs-title { font-weight: 700; font-size: 15px; }
.filter-summary .fs-item { color: var(--muted); }
.filter-summary .fs-item b { color: var(--ink); font-size: 15px; }
.product-filter-row > * { min-width: 160px; }

/* ============================================================
   Login
   ============================================================ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--ground); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 8px 32px rgba(22, 24, 21, .08); }
.login-card h1 { text-align: center; margin: 0 0 4px; font-size: 20px; }
.login-card .subtitle { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-logo { display: block; width: 240px; max-width: 80%; height: auto; margin: 4px auto 18px; }
.user-select-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.user-select-btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-align: center; cursor: pointer; color: var(--ink); font-weight: 600; display: block; }
.user-select-btn:hover, .user-select-btn.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.user-select-btn .role-tag { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 20px 0; }
.pin-dots .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); }
.pin-dots .dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); padding: 14px; font-size: 18px; font-weight: 600; border-radius: 10px; }
.pin-pad button:hover { background: var(--surface-3); }
.brand-icon { width: 38px; height: 38px; }
.login-brand-icon { display: none; }

/* ============================================================
   Receipt (kept light for physical printing)
   ============================================================ */
#receipt-overlay { position: fixed; inset: 0; background: rgba(22, 24, 21, .55); display: none; align-items: center; justify-content: center; z-index: 50; }
#receipt-overlay.show { display: flex; }
.receipt-paper { background: white; color: #111; width: 320px; padding: 16px; font-family: "Courier New", monospace; font-size: 13px; font-weight: 400; max-height: 90vh; overflow-y: auto; border-radius: 4px; }
.receipt-paper, .receipt-paper * { font-weight: 400 !important; }
.receipt-paper h3 { text-align: center; margin: 4px 0; }
.receipt-paper .center { text-align: center; }
.receipt-paper hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.receipt-paper table { font-size: 12px; }
.receipt-paper th, .receipt-paper td { border: none; padding: 2px 0; background: none; color: #111; font-size: inherit; }
.receipt-paper tbody tr:hover td { background: none; }
.receipt-paper button { font-weight: 600 !important; }
.receipt-shop-head { text-align: center; display: flex; flex-direction: column; gap: 3px; margin-top: 2mm; line-height: 1.35; }
.receipt-shop-head strong { font-size: 16px; }
.receipt-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 11px; line-height: 1.35; margin: 8px 0; }
.receipt-tax { font-size: 11px; margin: 5px 0; }
.backup-card label { display: block; margin: 10px 0; }
.backup-card input { width: 100%; max-width: 520px; }
.backup-actions { display: flex; gap: 10px; margin-top: 12px; }
.receipt-items { width: 100%; min-width: 0; table-layout: fixed; }
.receipt-items th { border-bottom: 1px solid #222; font-weight: 600; }
.receipt-items th:first-child { width: 55%; text-align: left; }
.receipt-items th:nth-child(2) { width: 15%; text-align: center; }
.receipt-items th:last-child { width: 30%; text-align: right; }
.receipt-item-name { min-width: 0; white-space: normal; overflow-wrap: anywhere; word-break: break-word; padding-right: 4px !important; }
.receipt-item-qty { min-width: 0; width: 15%; text-align: center; white-space: nowrap; }
.receipt-item-total { min-width: 0; width: 30%; text-align: right; white-space: nowrap; }
.receipt-paper .receipt-group-heading td { padding-top: 8px; border-bottom: 1px solid #000; }
.receipt-paper .receipt-group-total td { padding-top: 4px; padding-bottom: 8px; font-weight: 600; }
.receipt-subtotal-note { font-size: 11px; margin-top: 4px; }
.receipt-paper img { display: block; margin: 10px auto; width: 160px; height: 160px; }
.receipt-actions { display: flex; gap: 8px; margin-top: 12px; }
.receipt-logo { display: block; width: 68%; max-width: 48mm; height: auto; margin: 5mm auto 12px; }
.receipt-line { break-inside: avoid; text-align: center; }
.receipt-line img { width: 38mm; height: 38mm; padding: 3mm; box-sizing: content-box; background: white; filter: grayscale(1) brightness(0.7) contrast(100); }
.receipt-bottom-space { height: 0; }
.receipt-paper, .receipt-paper * { overflow-wrap: anywhere; }
.receipt-shop-head span, .receipt-parties div, .receipt-paper p, .receipt-paper strong { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.sku-label img { width: 100%; height: auto; max-width: 100%; }
.sku-code { font-size: 15px; font-weight: 700; }

@media print {
  @page rayco-receipt { size: auto; margin: 0; }
  body * { visibility: hidden; }
  .receipt-paper, .receipt-paper * { visibility: visible; }
  .receipt-paper { page: rayco-receipt; position: absolute; top: 0; left: 0; width: 68mm; max-width: 100%; box-sizing: border-box; max-height: none; overflow: visible; padding: 2mm; margin: 0 auto; border-radius: 0; }
  .receipt-paper { padding-bottom: 2mm; color: #000; font-family: Tahoma, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 1.4; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .receipt-paper * { color: #000 !important; opacity: 1 !important; }
  .receipt-paper, .receipt-paper * { font-weight: 400 !important; }
  .receipt-shop-head strong { font-size: 18px; }
  .receipt-items { font-size: 13px; }
  .receipt-parties, .receipt-tax { font-size: 12px; font-weight: 400; }
  .receipt-bottom-space { height: 15mm; }
  .receipt-paper th, .receipt-paper td { color: #000; }
  .receipt-paper hr { border-top: 2px dashed #000; }
  .receipt-items th { border-bottom: 2px solid #000; }
  .receipt-actions { display: none; }
  #receipt-overlay { position: absolute; background: none; }
  body:has(#receipt-overlay.show) > :not(#receipt-overlay) { display: none !important; }
  body:has(#receipt-overlay.show) { margin: 0; padding: 0; background: white; }
  #receipt-overlay.show { display: block; position: static; }
  #receipt-overlay.show .receipt-paper { position: static; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Warranty claims (claims.html) */
.claim-picks { display: flex; flex-direction: column; gap: 4px; margin: -4px 0 10px; }
.claim-pick { justify-content: flex-start; gap: 8px; background: var(--surface); color: var(--ink); border-color: var(--line); font-weight: 500; white-space: normal; text-align: left; }
.claim-pick:hover { background: var(--surface-2); border-color: var(--line-strong); }
.claim-pick .muted { margin-left: auto; white-space: nowrap; }
.claim-picked { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.claim-modes { border: 0; padding: 0; margin: 0 0 12px; }
.claim-modes legend { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.claim-modes label { display: flex; align-items: center; font-size: 14px; color: var(--ink); margin-bottom: 6px; }
button.danger-text { color: var(--bad); }
button.danger-text:hover { background: var(--bad-soft); color: var(--bad); }

/* Customer source on the bill (checkout.html) */
.source-box { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.source-box .required-mark { color: var(--bad); }
.source-box.invalid select, .source-box.invalid input:not([hidden]) { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

/* Aging stock (products.html) */
.aging-filter-row .date-filter { display: flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
.aging-filter-row .date-filter input { margin: 0; width: auto; }
.age-warn { color: var(--warn) !important; font-weight: 600; }
.age-old { color: var(--bad) !important; font-weight: 600; }
