/* CopperTill (Allied Surplus) — premium, touch-first retail surface.
   Design language: a calm cool-neutral work surface, a deep confident frame,
   one decisive green action color, layered depth (not flat), strong number
   hierarchy, and smooth, restrained motion. Fast and unmistakable at a counter. */
:root {
  /* Surfaces — cool, layered */
  --bg: #eaedf3;
  --bg-grad-a: #eef1f6;
  --bg-grad-b: #e6eaf1;
  --panel: #ffffff;
  --panel-tint: #f4f6fb;
  --panel-2: #fbfcff;

  /* Ink — rich, cool near-black */
  --ink: #111723;
  --ink-soft: #3a4254;
  --muted: #5d6678;
  --line: #e4e8f0;
  --line-strong: #ccd3df;

  /* Accent — Allied green, with a gradient pair + glow */
  --accent: #1c8a4e;
  --accent-bright: #1ea357;
  --accent-deep: #116637;
  --accent-soft: #e7f5ed;
  --accent-line: #a4d7b9;
  --accent-glow: rgba(28, 138, 78, 0.22);

  /* Copper — the CopperTill brand identity (used for the wordmark + brand touches,
     kept separate from the functional Allied-green accent above). */
  --copper: #b87333;
  --copper-bright: #d89b56;
  --copper-deep: #8c531f;
  --copper-soft: #f6ece0;
  --copper-line: #e3c39d;
  --copper-glow: rgba(184, 115, 51, 0.28);

  --info: #2563b8;
  --warning: #b56a0a;
  --warning-soft: #fdf2e1;
  --danger: #cf3340;
  --danger-soft: #fce9eb;
  --ok: #1c8a4e;

  /* Deep frame — premium charcoal with a hint of blue */
  --frame-a: #131a28;
  --frame-b: #0d1220;
  --frame-line: #28313f;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 20, 32, 0.05), 0 1px 3px rgba(15, 20, 32, 0.04);
  --shadow: 0 2px 6px rgba(15, 20, 32, 0.05), 0 12px 30px rgba(15, 20, 32, 0.08);
  --shadow-lg: 0 30px 70px rgba(15, 20, 32, 0.20), 0 12px 30px rgba(15, 20, 32, 0.10);
  --ring: 0 0 0 3px var(--copper-glow);
  --tap: 44px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --num: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background:
    radial-gradient(1200px 720px at 100% -8%, rgba(184, 115, 51, 0.06), transparent 60%),
    radial-gradient(1000px 620px at -8% 112%, rgba(28, 138, 78, 0.045), transparent 55%),
    linear-gradient(160deg, var(--bg-grad-a), var(--bg-grad-b));
  background-attachment: fixed;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-glow); }

/* Tabular figures for money/quantities so columns line up crisply */
.pos-due-hero, .pos-total-value, .bignum > div:last-child,
td, th, .line-total, #summary { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* Refined scrollbars on the work surfaces */
.table-wrap, .mono-block, .pos-cart-wrap, .pos-lookup-wrap { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.table-wrap::-webkit-scrollbar, .mono-block::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap::-webkit-scrollbar-thumb, .mono-block::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid var(--panel); }

/* ---- Header / utility frame ---- */
header {
  padding: 0.95rem 1.4rem 0;
  background: linear-gradient(180deg, var(--frame-a), var(--frame-b));
  color: #eef1f6;
  border-bottom: 1px solid var(--frame-line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px rgba(8, 11, 20, 0.18);
  position: relative;
}
header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--copper-bright), transparent); opacity: 0.62; }
header h1 { font-size: 1.2rem; letter-spacing: 0.02em; }
header .muted,
header .summary { color: #9aa6ba; }

h1, h2 { margin: 0 0 0.5rem; font-weight: 700; letter-spacing: -0.01em; }
h2 {
  font-family: "Oswald", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1.45rem;
  letter-spacing: 0.015em;
  color: var(--ink);
}
h3 { margin: 1.15rem 0 0.5rem; font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; }

/* ---- Grouped two-level navigation ---- */
.navbar { margin-top: 0.9rem; display: flex; flex-direction: column; gap: 0.45rem; }
.nav-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
body:not(.authed) .navbar { display: none; }

.nav-group {
  min-height: 38px; padding: 0.45rem 1.05rem;
  background: transparent; color: #aeb8c8;
  border: 1px solid transparent; border-radius: 11px;
  font-weight: 700; font-size: 0.97rem; cursor: pointer;
  box-shadow: none;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.nav-group:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.nav-group.active {
  color: #fff;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent; box-shadow: 0 4px 14px var(--accent-glow);
}

.nav-item {
  min-height: 32px; padding: 0.32rem 0.85rem;
  background: rgba(255, 255, 255, 0.05); color: #c3ccda;
  border: 1px solid transparent; border-radius: 8px;
  font-weight: 600; font-size: 0.87rem; cursor: pointer;
  box-shadow: none;
  transition: color 0.12s var(--ease), background 0.12s var(--ease);
}
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.11); }
.nav-item.active {
  background: var(--bg-grad-a); color: var(--ink);
  border-color: rgba(255, 255, 255, 0.14); box-shadow: var(--shadow-sm);
}

/* ---- Layout ---- */
main { flex: 1; min-height: 0; }
.grid {
  display: grid;
  gap: 1.05rem;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  padding: 1.2rem;
}
.view { display: block; height: 100%; animation: view-in 0.22s var(--ease); }
.view.hidden { display: none; }
.hidden { display: none !important; }
.full { grid-column: 1 / -1; }
.grow { flex: 1; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Cards ---- */
.card {
  background: linear-gradient(180deg, #ffffff, var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.22s var(--ease), transform 0.22s var(--ease), border-color 0.22s var(--ease);
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--line-strong); }
.screen-card {
  min-height: calc(100vh - 250px);
  display: flex;
  flex-direction: column;
}
.card > h2:first-child { margin-bottom: 0.15rem; }
.card > h2:first-child + .muted { margin-top: 0.1rem; }

/* ---- Forms ---- */
.row {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
  align-items: end;
  flex-wrap: wrap;
}
.filters-row { flex-wrap: wrap; }
#recvAllocFields { flex-wrap: wrap; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.62rem 0.75rem;
  min-height: var(--tap);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}
textarea { min-height: 80px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9aa3b1; }
input:hover, select:hover, textarea:hover { border-color: #b6bdca; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--copper);
  box-shadow: var(--ring);
}
input[type="checkbox"] { min-height: auto; width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
/* A label whose control is a lone checkbox reads better as "Text [x]" on one
   line (matches the .perm-check pattern) than as text stacked over a box. */
label:has(> input[type="checkbox"]) { flex-direction: row; align-items: center; gap: 0.5rem; }
select { cursor: pointer; }

/* ---- Buttons ---- */
button {
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #283041, #151c28);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), var(--shadow-sm);
  transition: transform 0.06s var(--ease), box-shadow 0.18s var(--ease), filter 0.15s var(--ease), background 0.15s var(--ease);
}
button:hover { filter: brightness(1.08); box-shadow: var(--shadow); transform: translateY(-1px); }
button:active { transform: translateY(0); box-shadow: var(--shadow-sm); filter: brightness(0.98); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; transform: none; box-shadow: none; }

button.primary, .pos-checkout-btn, button[type="submit"] {
  background: linear-gradient(180deg, var(--copper-bright), var(--copper-deep));
  border-color: rgba(0, 0, 0, 0.08);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.30), 0 4px 14px var(--copper-glow), var(--shadow-sm);
}
button.primary:hover, .pos-checkout-btn:hover, button[type="submit"]:hover {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.30), 0 9px 26px var(--copper-glow), var(--shadow);
}
button.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
button.ghost:hover { background: var(--panel-2); filter: none; border-color: #b6bdca; }
button.danger { background: linear-gradient(180deg, #d84653, #bf2b38); border-color: rgba(0, 0, 0, 0.08); }
button.ghost.ghost-danger { color: var(--danger); border-color: #e3b6bb; }
button.ghost.ghost-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.void-sale-modal { max-width: 460px; width: 100%; text-align: left; }
.void-sale-modal label { margin-bottom: 0.7rem; }
#voidSaleSummary:not(:empty) { margin: -0.2rem 0 0.7rem; }
#voidQueuedList:not(:empty) { margin: 0.4rem 0 0.5rem; line-height: 1.9; }

.mini-btn {
  padding: 0.35rem 0.6rem;
  min-height: 44px;
  min-width: 44px;
  line-height: 1;
  font-size: 0.95rem;
  background: linear-gradient(180deg, #f4f6fa, #e9edf3);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.mini-btn:hover { background: #fff; }

/* button busy/spinner state (set via JS) */
button.is-busy { position: relative; color: transparent !important; }
button.is-busy::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  top: calc(50% - 8px); left: calc(50% - 8px);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
button.ghost.is-busy::after, .mini-btn.is-busy::after { border-color: rgba(0,0,0,0.22); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Tables ---- */
.table-wrap {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.table-stretch { flex: 1; min-height: 280px; max-height: none; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.95rem;
}
th {
  position: sticky;
  top: 0;
  background: var(--panel-tint);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
  box-shadow: 0 1px 0 var(--line);
}
tbody tr { transition: background 0.1s var(--ease); }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: none; }

/* ---- Text helpers ---- */
.muted { color: var(--muted); margin-top: 0.5rem; }
.summary { font-size: 0.95rem; }
.small { font-size: 0.85rem; }
.bad { color: var(--danger); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.warn { color: var(--warning); font-weight: 600; }
.good { color: var(--ok); font-weight: 600; }

.mono-block {
  margin-top: 0.6rem;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  font-size: 0.9rem;
}
.mono-block:empty { display: none; }
.mono-block .table-wrap { border: none; box-shadow: none; margin: 0; }
/* Readable key/value rendering of API results (replaces raw JSON dumps) */
.kv-block { display: flex; flex-direction: column; }
.kv-row {
  display: flex; gap: 1rem; align-items: baseline;
  padding: 0.4rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.kv-row:last-child { border-bottom: none; }
.kv-key { flex: 0 0 38%; max-width: 38%; font-weight: 600; color: var(--ink-soft); }
.kv-val { flex: 1; font-variant-numeric: tabular-nums; word-break: break-word; }
.kv-val .table-wrap { margin-top: 0.2rem; }
.kv-val .kv-block { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.kv-nested > summary { cursor: pointer; color: var(--info); font-size: 0.82rem; }
.kv-nested[open] > summary { margin-bottom: 0.3rem; }

/* ---- Quantity / cart bits ---- */
.qty-grid { display: grid; gap: 0.6rem; margin-bottom: 0.8rem; }
.qty-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 180px);
  gap: 0.6rem;
  align-items: center;
}
.qty-controls { display: flex; align-items: center; gap: 0.4rem; }
.qty-controls input { max-width: 92px; text-align: center; font-weight: 700; }
.cart-price-input { max-width: 112px; }
.cart-reason-input { min-width: 180px; }
.line-total { font-weight: 700; }
tr.row-selected { background: var(--accent-soft) !important; box-shadow: inset 3px 0 0 var(--accent); }

/* ---- POS ---- */
.pos-view { grid-template-columns: 1fr; padding: 0.85rem; }
.pos-screen-card {
  min-height: calc(100vh - 185px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.pos-screen-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--line);
}
.pos-head-copy, .pos-head-actions, .pos-control-row { margin: 0; }
.pos-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(640px, 1.4fr) minmax(440px, 1fr);
  gap: 1rem;
  padding-top: 0.95rem;
}
.pos-pane { min-height: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.pos-pane-right {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel-tint));
  padding: 0.95rem;
  box-shadow: var(--shadow);
}
.pos-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.pos-cash-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.pos-cash-quick .mini-btn { min-width: 64px; min-height: 48px; font-weight: 700; font-size: 1.05rem; }

/* Big, obvious scan/lookup field */
#posSkuInput {
  font-size: 1.18rem;
  font-weight: 600;
  min-height: 54px;
  border: 2px solid var(--line-strong);
  background: linear-gradient(180deg, #ffffff, #fbfcff);
}
#posSkuInput:focus { border-color: var(--copper); box-shadow: var(--ring); }

.pos-lookup-block { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pos-lookup-wrap { flex: 1; min-height: 230px; max-height: none; }
.pos-cart-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.pos-cart-head h3 { margin: 0; }

/* The most important number on the screen — make it unmissable */
.pos-due-hero {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  border: 1px solid var(--accent-line);
  background: linear-gradient(180deg, #f0f9f3, var(--accent-soft));
  color: var(--accent-deep);
  border-radius: var(--radius);
  padding: 0.35rem 1.1rem;
  line-height: 1.1;
  box-shadow: 0 2px 12px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.pos-due-hero.has-alert {
  border-color: #f0c48a;
  background: linear-gradient(180deg, #fef6ea, var(--warning-soft));
  color: var(--warning);
  box-shadow: 0 2px 12px rgba(181, 106, 10, 0.18);
}

.pos-cart-wrap { flex: 1; min-height: 360px; max-height: none; }
.pos-checkout-btn {
  width: 100%;
  font-size: 1.3rem;
  padding: 1rem 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border-radius: var(--radius);
  min-height: 62px;
  margin-top: 0.55rem;
}
.pos-totals-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 0.6rem;
}
.pos-total-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.6rem 0.7rem;
  box-shadow: var(--shadow-sm);
}
.pos-total-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.pos-total-value { font-size: 1.15rem; font-weight: 700; margin-top: 0.15rem; }
.pos-total-select {
  width: 100%;
  min-height: 2.3rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.pos-total-accent { border-color: var(--accent-line); background: linear-gradient(180deg, #f0f9f3, var(--accent-soft)); }
.pos-total-accent .pos-total-label,
.pos-total-accent .pos-total-value { color: var(--accent-deep); }

.pos-accordion {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.45rem 0.85rem 0.6rem;
}
.pos-accordion summary { cursor: pointer; font-weight: 700; padding: 0.35rem 0; }
.pos-accordion .row { margin-top: 0.6rem; margin-bottom: 0; }
.pos-inline-note { font-size: 0.78rem; color: var(--muted); }
.pos-lookup-actions { display: flex; gap: 0.4rem; }

/* ---- Status banners / big numbers / report groups ---- */
.status-banner {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin: 0.6rem 0;
  font-weight: 700;
  background: var(--panel-tint);
  border: 1px solid var(--line);
}
.status-banner.good { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-deep); }
.status-banner.bad { background: var(--danger-soft); border-color: #eaa9b0; color: var(--danger); }

.bignum { display: flex; flex-direction: column; justify-content: center; min-width: 130px; }
.bignum > div:last-child { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.01em; }

.report-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem 0.75rem;
  margin: 0.6rem 0;
  background: var(--panel-2);
}
.report-group > legend {
  padding: 0 0.5rem;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

/* ---- Toasts ---- */
.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 1000;
  max-width: min(420px, 90vw);
}
.toast {
  padding: 0.8rem 1.05rem;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 14px 34px rgba(15, 20, 32, 0.28);
  border-left: 4px solid rgba(255, 255, 255, 0.6);
  animation: toast-in 0.24s var(--ease);
  backdrop-filter: saturate(1.2);
}
.toast.info { background: var(--info); }
.toast.success { background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep)); }
.toast.error { background: linear-gradient(180deg, #d84653, var(--danger)); }
.toast.warning { background: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .row { flex-wrap: wrap; }
  .screen-card { min-height: calc(100vh - 190px); }
  .table-stretch { min-height: 220px; }
  .pos-layout { grid-template-columns: 1fr; }
  .pos-screen-card { min-height: calc(100vh - 150px); }
  .pos-cart-wrap { min-height: 260px; }
  .pos-totals-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .pos-due-hero { font-size: 1.8rem; }
}

/* ---- Branded header / account ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.0; }
.brand-mark {
  font-family: "Oswald", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: 0.05em;
  line-height: 0.92;
  display: inline-flex;
  align-items: baseline;
  gap: 0.42ch;
}
/* Brushed-copper wordmark on the dark header — brighter stops than the login
   version so the metal reads against the charcoal frame. */
.bm-allied {
  background: linear-gradient(165deg, #eec99a 0%, var(--copper-bright) 48%, var(--copper) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--copper-bright);
}
.bm-surplus {
  background: linear-gradient(165deg, #f3d9b4 0%, #e7b277 45%, var(--copper-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--copper-bright);
  text-shadow: none;
  filter: drop-shadow(0 0 14px var(--copper-glow));
}
.brand-sub {
  font-family: "Oswald", system-ui, sans-serif;
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #8290a6;
  margin-top: 5px;
}
.account { display: flex; align-items: center; gap: 0.6rem; }

/* Global store switcher — pick the store once, in the header */
.store-switch {
  display: inline-flex;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 11px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}
body:not(.authed) .store-switch { display: none; }
.store-seg {
  min-height: 40px;
  min-width: 84px;
  padding: 0.35rem 1rem;
  font-weight: 700;
  font-size: 0.92rem;
  background: transparent;
  color: #aeb8c8;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.store-seg:hover { color: #fff; background: rgba(255, 255, 255, 0.07); filter: none; transform: none; }
.store-seg.active {
  background: var(--copper);
  color: #fff;
}
/* While a store is locked in the header, redundant per-screen pickers hide */
body.store-locked .store-synced { display: none; }
.auth-user { display: none; align-items: center; gap: 0.85rem; }
.auth-user #currentUserLabel { color: #cdd5e2; font-weight: 600; font-size: 0.92rem; }
body.authed .auth-user { display: flex; }
/* Status strip — calm stat chips on the dark header that light up amber/red on trouble */
#summary { display: flex; flex-wrap: wrap; gap: 6px 7px; margin-top: 0.55rem; letter-spacing: 0; }
.summary-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem; line-height: 1.55; transition: background 0.18s var(--ease);
}
.summary-chip .k { color: #8290a6; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.62rem; font-weight: 600; }
.summary-chip .v { color: #e7ecf4; font-weight: 700; }
.summary-chip.warn { background: rgba(181, 106, 10, 0.16); border-color: rgba(214, 155, 86, 0.42); }
.summary-chip.warn .v { color: #f0b667; }
.summary-chip.warn .k { color: #cf9f63; }
.summary-chip.bad { background: rgba(207, 51, 64, 0.16); border-color: rgba(207, 51, 64, 0.45); }
.summary-chip.bad .v { color: #f08a93; }
.summary-chip.bad .k { color: #d98c93; }
#authMessage:empty { display: none; }

/* Hide manager-only cart columns (price override / reason) for frontline members */
body:not(.can-override) .col-override { display: none; }

/* Roles & permissions matrix */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.35rem 0.9rem;
  margin: 0.5rem 0 0.7rem;
}
.perm-check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  transition: background 0.12s var(--ease);
}
.perm-check:hover { background: var(--panel-tint); }
.perm-check input { min-height: auto; }

/* Confirmation modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(13, 18, 30, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1100;
  backdrop-filter: blur(3px); animation: overlay-in 0.18s var(--ease);
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem; max-width: min(460px, 92vw);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-message { font-size: 1.05rem; font-weight: 500; line-height: 1.55; margin-bottom: 1.2rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

/* ---- Login screen (signed-out) ---- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(1100px 600px at 20% -10%, rgba(184, 115, 51, 0.22), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(37, 99, 184, 0.12), transparent 55%),
    linear-gradient(160deg, #161b26, #0c111c 75%);
}
body.authed .login-screen { display: none; }
.login-card {
  position: relative;
  width: min(400px, 94vw);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 2.8rem 2.4rem 2.4rem;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.45);
  animation: modal-in 0.32s var(--ease);
  overflow: hidden;
}
/* Thin copper accent across the top of the card */
.login-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--copper);
}
.login-brand { text-align: center; margin-bottom: 2rem; }
/* One word, one color — solid deep copper reads crisp at display size
   (gradient-clipped text banded and made the two words look mismatched). */
.login-brand .brand-mark { font-size: 2.45rem; justify-content: center; gap: 0.06ch; letter-spacing: 0.01em; }
.login-brand .bm-allied,
.login-brand .bm-surplus {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: #9a5d20;
  text-shadow: none;
  filter: none;
}
.login-brand .brand-sub { color: #9aa3b2; display: block; margin-top: 10px; letter-spacing: 0.3em; font-size: 0.6rem; }
.login-title {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 1.6rem;
}
.login-form { display: flex; flex-direction: column; gap: 1.05rem; }
.login-form label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #8a93a3;
  gap: 0.45rem;
}
.login-form input {
  min-height: 50px;
  font-size: 1.02rem;
  border-radius: 11px;
  border-color: #dde2eb;
  background: #fbfcfe;
}
.login-form input:hover { border-color: #c8cfdb; }
/* Flat, confident copper button — no inset sheen, no glow */
button.primary.login-submit {
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.015em;
  margin-top: 0.5rem;
  border-radius: 11px;
  background: #ad6726;
  text-shadow: none;
  box-shadow: 0 1px 2px rgba(15, 20, 32, 0.18);
}
button.primary.login-submit:hover {
  background: #b9722e;
  filter: none;
  box-shadow: 0 4px 14px rgba(173, 103, 38, 0.35);
  transform: none;
}
.login-form #authMessage { text-align: center; margin-top: 0.1rem; }

/* Store-profile editors in Settings */
.sp-editor { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 0.95rem; background: var(--panel-2); box-shadow: var(--shadow-sm); }
.sp-editor h3 { margin-top: 0.1rem; }

/* ===== Dashboard (owner command center) ===== */
/* The shared .view rule resolves to display:block, so opt this one view into a real
   grid (the :not(.hidden) keeps view switching working). */
#viewDashboard:not(.hidden) { display: grid; }
#viewDashboard.grid { grid-template-columns: repeat(3, minmax(260px, 1fr)); align-content: start; }
@media (max-width: 1040px) { #viewDashboard.grid { grid-template-columns: 1fr; } }

.dash-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dash-head-row h2 { margin: 0; }
.dash-head-controls { margin: 0; align-items: end; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; margin-top: 1.1rem; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  background: linear-gradient(180deg, #ffffff, var(--panel-tint));
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 0.3rem;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-accent {
  background: linear-gradient(150deg, var(--accent-bright), var(--accent-deep));
  border-color: transparent; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 16px 34px var(--accent-glow);
}
.kpi-accent:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 22px 44px var(--accent-glow); }
.kpi-accent .kpi-label, .kpi-accent .kpi-sub { color: rgba(255, 255, 255, 0.88); }
.kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--muted); }
.kpi-value { font-size: 2.05rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.08; }
.kpi-sub { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.dash-col h3 { margin-top: 0.1rem; margin-bottom: 0.7rem; }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.42rem 0; border-bottom: 1px dashed var(--line); font-size: 0.92rem; }
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--muted); }
.stat-row strong { font-variant-numeric: tabular-nums; font-weight: 700; }

.dash-list { display: flex; flex-direction: column; gap: 0.1rem; }
.dash-item { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.45rem 0; border-bottom: 1px dashed var(--line); }
.dash-item:last-child { border-bottom: none; }
.dash-item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-item-meta { color: var(--muted); font-size: 0.84rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-alert { padding: 0.5rem 0.65rem; border-radius: var(--radius-sm); background: var(--panel-tint); margin-top: 0.4rem; font-size: 0.88rem; border-left: 3px solid var(--line-strong); }
.dash-alert.bad { background: var(--danger-soft); border-left-color: var(--danger); color: var(--danger); }
.dash-alert.warn { background: var(--warning-soft); border-left-color: var(--warning); color: var(--warning); }

/* 7-day sparkline (bars) */
.spark-wrap { margin-top: 0.5rem; }
.spark-bars { display: flex; align-items: flex-end; gap: 0.6rem; height: 150px; }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; height: 100%; justify-content: flex-end; }
.spark-bar-track { width: 100%; max-width: 56px; height: 100%; display: flex; align-items: flex-end; }
.spark-bar { width: 100%; background: linear-gradient(180deg, var(--accent-bright), var(--accent)); border-radius: 6px 6px 0 0; min-height: 3px; transition: height 0.4s var(--ease); }
.spark-amt { font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.spark-day { font-size: 0.72rem; color: var(--muted); }

/* Product-row label button spacing */
.label-product { margin-left: 0.35rem; }

/* Quick-add at POS */
.quick-add-modal { max-width: 440px; width: 100%; text-align: left; }
.quick-add-modal h3 { margin: 0 0 0.2rem; }
.quick-add-modal label { margin-bottom: 0.7rem; }
.quick-add-modal .row { margin-bottom: 0; }
.quick-add-modal .modal-actions { margin-top: 0.5rem; }
#quickAddMsg { min-height: 1.1em; font-size: 0.85rem; }

/* ===== Tender modal — the guided checkout popup ===== */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}
.tender-modal { width: min(560px, 94vw); max-width: 560px; text-align: center; }
.tender-due-big {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.05;
}
.tender-due-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0.2rem 0 1.1rem;
}
.tender-method-btns { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.1rem; }
.tender-method-btn {
  min-width: 88px;
  min-height: 52px;
  font-size: 1rem;
  font-weight: 700;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.tender-method-btn:hover { border-color: var(--copper-line); filter: none; }
.tender-method-btn.active {
  background: var(--copper-soft);
  border-color: var(--copper);
  color: var(--copper-deep);
}
.tender-panel { text-align: left; margin-bottom: 0.6rem; }
.tender-panel .row { justify-content: center; }
#cashTenderRow label { align-items: stretch; }
#cashTenderRow input { font-size: 1.3rem; font-weight: 700; text-align: center; min-height: 56px; }
.tender-change-helper { font-size: 1.05rem; font-weight: 600; text-align: center; margin-top: 0.5rem; }
.tender-change-panel { padding: 0.8rem 0 0.4rem; }
.tender-change-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.tender-change-big {
  font-size: 4.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-deep);
  line-height: 1.05;
  margin: 0.3rem 0 0.4rem;
}
.tender-modal .modal-actions { justify-content: center; margin-top: 0.6rem; }
.tender-modal .modal-actions button { min-width: 150px; min-height: 52px; font-size: 1.05rem; }

/* ===== Product type-ahead dropdown (receiving etc.) ===== */
.type-ahead-wrap { position: relative; }
.type-ahead-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 60;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 340px;
  overflow: auto;
}
.ta-item { padding: 0.55rem 0.8rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.ta-item:last-child { border-bottom: none; }
.ta-item:hover, .ta-item.active { background: var(--copper-soft); }
.ta-name { font-weight: 600; font-size: 0.95rem; }
.ta-meta { margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.ta-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-tint);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.ta-badge-vendor { background: var(--copper-soft); border-color: var(--copper-line); color: var(--copper-deep); }
.ta-onhand { font-size: 0.74rem; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

/* ===== Practice Mode ===== */
.practice-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.6rem 1.4rem;
  background: repeating-linear-gradient(45deg, #1f6f43, #1f6f43 18px, #1a5d39 18px, #1a5d39 36px);
  color: #fff;
  font-size: 0.95rem;
  position: sticky; top: 0; z-index: 900;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.practice-banner button {
  flex: 0 0 auto;
  background: #fff; color: #1a5d39; font-weight: 800;
  border: none; min-height: 40px; padding: 0.4rem 1.1rem; border-radius: 9px;
}
.practice-banner button:hover { filter: none; background: #f0f0f0; }
/* A calm green frame around the whole app while practicing, so it's unmistakable */
body.practice-mode main { box-shadow: inset 0 0 0 3px #1f8a4c; }
body.practice-mode #practiceModeBtn { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-deep); }

/* Getting-started checklist + Needs Attention */
.setup-steps { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.6rem; }
.setup-step {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.setup-step.done { opacity: 0.55; }
.setup-step-mark {
  width: 26px; height: 26px; flex: 0 0 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 800; font-size: 0.8rem;
  background: var(--copper-soft); color: var(--copper-deep); border: 1px solid var(--copper-line);
}
.setup-step.done .setup-step-mark { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent-line); }
.setup-step-label { flex: 1; font-weight: 600; font-size: 0.92rem; }
.attention-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.danger-zone-note {
  margin: 0.5rem 0;
  padding: 0.55rem 0.8rem;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.danger-zone-label { color: var(--danger); }

/* Readable receipt card (replaces the old raw-JSON dump) */
.receipt-card { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); padding: 0.7rem 0.85rem; margin-top: 0.5rem; }
.receipt-card-head { font-size: 0.9rem; margin-bottom: 0.5rem; color: var(--ink-soft); }
.receipt-card-foot { font-size: 0.95rem; margin-top: 0.5rem; }
.receipt-card .table-wrap { max-height: 220px; }

/* Collapsed technical detail behind friendly error messages */
.msg-tech { display: inline-block; margin-left: 0.3rem; }
.msg-tech summary { cursor: pointer; font-size: 0.72rem; color: var(--muted); text-decoration: underline; }
.msg-tech code {
  display: block;
  margin-top: 0.3rem;
  padding: 0.4rem 0.6rem;
  background: var(--panel-tint);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 60ch;
}

/* Customer directory */
.sep { border: none; border-top: 1px solid var(--line); margin: 1.1rem 0; }
.cust-row { cursor: pointer; }
.cust-row:hover td { background: var(--panel-tint); }
#custDetail .kpi-grid { margin: 0.4rem 0 1rem; }

/* One-tap date-range chips on report screens */
.date-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: end; }
.date-presets .date-preset { font-size: 0.8rem; min-height: 44px; }

/* "Which report when?" guide + per-section hints */
.report-guide {
  display: flex; flex-direction: column; gap: 0.3rem;
  border: 1px solid var(--copper-line);
  background: var(--copper-soft);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  margin: 0.6rem 0 0.9rem;
  font-size: 0.9rem;
  position: relative;
}
.report-guide button { position: absolute; top: 0.5rem; right: 0.6rem; }
.report-hint { margin: 0.1rem 0 0.4rem; }
