/* ==========================================================================
   Mini Till — design system

   Self-contained: no CDN, no build step. The app runs on venue and shop wifi,
   so nothing that affects layout is allowed to depend on a network fetch.

   Everything is driven by the tokens in :root. Change a token, the whole
   product follows.
   ========================================================================== */

:root {
  /* --- Brand -------------------------------------------------------------
     A warm, slightly earthy amber. Softer than a pure signal orange, which
     goes muddy on cheap screens and shouts on a till you stare at all night. */
  --brand-50:  #FFF6EF;
  --brand-100: #FFE8D6;
  --brand-200: #FFD0AC;
  --brand-300: #FDAF77;
  --brand-400: #F98940;
  --brand-500: #F2670A;
  --brand-600: #DC5806;
  --brand-700: #B6440A;
  --brand-800: #8F370F;

  /* --- Accent: used for data, links and anything "informational" --------- */
  --accent-50:  #ECFDF8;
  --accent-100: #D0F7EC;
  --accent-500: #0D9488;
  --accent-600: #0B7C72;
  --accent-700: #0A625B;

  /* --- Neutrals ---------------------------------------------------------- */
  --ink-950: #0E0F14;
  --ink-900: #171922;
  --ink-800: #232633;
  --ink-700: #343849;
  --ink-500: #6B7189;
  --ink-400: #8D93A8;
  --ink-300: #B9BECD;
  --ink-200: #DDE0E8;
  --ink-100: #EDEFF3;
  --ink-50:  #F6F7F9;

  /* --- Semantic ---------------------------------------------------------- */
  --ok-bg: #E8F7EE;    --ok-fg: #15803D;   --ok-line: #A7E0BC;
  --warn-bg: #FFF4E0;  --warn-fg: #B45309; --warn-line: #F5D08A;
  --bad-bg: #FDECEC;   --bad-fg: #C62A2A;  --bad-line: #F3B7B7;
  --info-bg: #EAF1FE;  --info-fg: #2563EB; --info-line: #B6CDF8;

  /* --- Surfaces (light) --------------------------------------------------- */
  --bg: var(--ink-50);
  --surface: #FFFFFF;
  --surface-2: var(--ink-50);
  --surface-sunken: #F1F2F6;
  --line: var(--ink-200);
  --line-soft: var(--ink-100);
  --text: var(--ink-900);
  --text-soft: var(--ink-500);
  --text-faint: var(--ink-400);
  --topbar: var(--ink-900);
  --topbar-text: #FFFFFF;

  /* --- Shape and depth ---------------------------------------------------- */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(14, 15, 20, .06), 0 1px 3px rgba(14, 15, 20, .04);
  --shadow-2: 0 2px 4px rgba(14, 15, 20, .05), 0 6px 16px rgba(14, 15, 20, .07);
  --shadow-3: 0 10px 30px rgba(14, 15, 20, .13);
  --ring: 0 0 0 3px var(--brand-100);

  /* --- Type --------------------------------------------------------------- */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-num: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --tap: 44px; /* minimum touch target */
}

/* Dark mode: follows the OS, and can be forced with .dark-mode or
   [data-theme="dark"] so the site's own toggle still wins. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(.light-mode) {
    --bg: var(--ink-950);
    --surface: var(--ink-900);
    --surface-2: var(--ink-800);
    --surface-sunken: #101218;
    --line: #2C3040;
    --line-soft: #23262F;
    --text: #EEF0F5;
    --text-soft: var(--ink-300);
    --text-faint: var(--ink-400);
    --topbar: #000308;
    --ring: 0 0 0 3px rgba(242, 103, 10, .3);
    --ok-bg: #10291B;   --ok-line: #1F5637;
    --warn-bg: #2C2110; --warn-line: #6A4B14;
    --bad-bg: #2E1517;  --bad-line: #6D2A2C;
    --info-bg: #131F38; --info-line: #2B4780;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 2px 6px rgba(0,0,0,.45);
    --shadow-3: 0 12px 32px rgba(0,0,0,.55);
  }
}

[data-theme="dark"], body.dark-mode {
  --bg: var(--ink-950);
  --surface: var(--ink-900);
  --surface-2: var(--ink-800);
  --surface-sunken: #101218;
  --line: #2C3040;
  --line-soft: #23262F;
  --text: #EEF0F5;
  --text-soft: var(--ink-300);
  --text-faint: var(--ink-400);
  --topbar: #000308;
  --ring: 0 0 0 3px rgba(242, 103, 10, .3);
  --ok-bg: #10291B;   --ok-line: #1F5637;
  --warn-bg: #2C2110; --warn-line: #6A4B14;
  --bad-bg: #2E1517;  --bad-line: #6D2A2C;
  --info-bg: #131F38; --info-line: #2B4780;
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.011em; line-height: 1.25; }
p { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Numbers in a stock or money context must line up column to column. */
.num, .qty, td.num, .money { font-variant-numeric: tabular-nums; }

.icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.icon svg { display: block; }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

/* ==========================================================================
   Layout
   ========================================================================== */

.wrap { max-width: 960px; margin: 0 auto; padding: 0 14px; }

.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-tight { display: flex; align-items: center; gap: 6px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.wrap-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ==========================================================================
   Surfaces
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-flush { padding: 0; overflow: hidden; }

.card-title { font-size: 1.02rem; font-weight: 700; }
.card-sub { font-size: .84rem; color: var(--text-soft); margin-top: 3px; }

.section-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-faint);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); padding: 11px 16px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: .93rem; font-weight: 650; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: background .14s ease, border-color .14s ease, transform .06s ease, box-shadow .14s ease;
}
.btn:hover:not(:disabled) { background: var(--ink-100); }
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-1); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }

.btn-accent { background: var(--accent-600); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-700); }

.btn-ok { background: var(--ok-fg); color: #fff; }
.btn-ok:hover:not(:disabled) { filter: brightness(.93); }

.btn-danger { background: transparent; color: var(--bad-fg); border-color: var(--bad-line); }
.btn-danger:hover:not(:disabled) { background: var(--bad-bg); }

.btn-quiet { background: transparent; border-color: var(--line); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-2); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-sm { min-height: 34px; padding: 6px 11px; font-size: .82rem; border-radius: 7px; gap: 5px; }
.btn-icon { min-height: 38px; width: 38px; padding: 0; }
.btn-block { width: 100%; }

/* ==========================================================================
   Form controls
   ========================================================================== */

.field {
  width: 100%; min-height: var(--tap);
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 16px;              /* 16px stops iOS zooming on focus */
  color: var(--text);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.field::placeholder { color: var(--text-faint); }
.field:focus { outline: none; border-color: var(--brand-400); box-shadow: var(--ring); }
.field:disabled { background: var(--surface-sunken); color: var(--text-faint); cursor: not-allowed; }

select.field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236B7189' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 34px;
}

.label { display: block; font-size: .78rem; font-weight: 700; color: var(--text-soft); margin-bottom: 5px; }
.hint { font-size: .76rem; color: var(--text-faint); margin-top: 5px; }
.error-text { font-size: .8rem; color: var(--bad-fg); font-weight: 600; }

.field-icon { position: relative; }
.field-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.field-icon .field { padding-left: 38px; }

.code-input {
  text-transform: uppercase; letter-spacing: .22em;
  font-weight: 700; font-size: 1.05rem; text-align: center;
}

.check-row { display: flex; align-items: center; gap: 9px; font-size: .88rem; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--brand-600); flex: 0 0 auto; }

/* ==========================================================================
   Chips, badges, pills
   ========================================================================== */

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: var(--r-pill);
  border: 1.5px solid var(--line); background: var(--surface);
  font-size: .85rem; font-weight: 650; color: var(--text-soft);
  cursor: pointer; white-space: nowrap;
  transition: all .14s ease;
}
.chip:hover { border-color: var(--brand-300); color: var(--text); }
.chip.is-active { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: .69rem; font-weight: 700; letter-spacing: .01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok-fg);   border-color: var(--ok-line); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }
.badge-bad  { background: var(--bad-bg);  color: var(--bad-fg);  border-color: var(--bad-line); }
.badge-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }
.badge-neutral { background: var(--surface-2); color: var(--text-soft); border-color: var(--line); }

/* Avatar initials, used in the team list and the sign-in picker */
.avatar {
  width: 38px; height: 38px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 700; letter-spacing: .01em;
  background: var(--brand-100); color: var(--brand-700);
  flex: 0 0 auto; user-select: none;
}
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }

/* ==========================================================================
   Lists
   ========================================================================== */

.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.list-row:last-child { border-bottom: none; }
.list-title { font-weight: 650; font-size: .93rem; color: var(--text); }
.list-sub { font-size: .765rem; color: var(--text-soft); margin-top: 1px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-item {
  display: flex; width: 100%; align-items: center; gap: 12px;
  padding: 14px 16px; border: none; background: none; text-align: left;
  cursor: pointer; border-bottom: 1px solid var(--line-soft); color: var(--text);
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .icon { color: var(--text-soft); }
.menu-item:hover .icon { color: var(--brand-600); }

.empty {
  text-align: center; padding: 28px 16px; color: var(--text-soft); font-size: .88rem;
}
.empty .icon { color: var(--text-faint); margin-bottom: 8px; }

/* ==========================================================================
   Stat tiles
   ========================================================================== */

.stat {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: 11px 13px; box-shadow: var(--shadow-1);
}
.stat .stat-v {
  font-size: 1.3rem; font-weight: 800; line-height: 1.15;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.stat .stat-k {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint); margin-top: 2px;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data { border-collapse: collapse; width: 100%; font-size: .86rem; }
table.data th, table.data td {
  padding: 8px 10px; text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.data th:first-child, table.data td:first-child {
  text-align: left; position: sticky; left: 0; background: var(--surface);
  z-index: 1; min-width: 130px; font-variant-numeric: normal;
}
table.data thead th {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); border-bottom: 1.5px solid var(--line); font-weight: 700;
}
table.data tbody tr:nth-child(even) td,
table.data tbody tr:nth-child(even) td:first-child { background: var(--surface-2); }
table.data td.total { font-weight: 800; border-left: 1.5px solid var(--line); }

/* Quantity colouring, shared by lists and tables */
.q-neg { color: var(--bad-fg); font-weight: 700; }
.q-low { color: var(--warn-fg); font-weight: 650; }
.q-ok  { color: var(--ok-fg); }
.q-zero { color: var(--text-faint); }

/* ==========================================================================
   Feedback
   ========================================================================== */

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: .85rem;
}
.notice .icon { flex: 0 0 auto; margin-top: 1px; }
.notice-ok   { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok-fg); }
.notice-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }
.notice-bad  { background: var(--bad-bg);  border-color: var(--bad-line);  color: var(--bad-fg); }
.notice-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-fg); }

.toast-host {
  position: fixed; left: 0; right: 0; z-index: 300;
  bottom: calc(122px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; pointer-events: none; padding: 0 14px;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px; border-radius: var(--r-sm);
  background: var(--ink-900); color: #fff;
  font-size: .88rem; font-weight: 600; box-shadow: var(--shadow-3);
  max-width: 100%; pointer-events: auto;
  animation: toast-in .18s ease-out;
}
.toast-ok   { background: var(--ok-fg); }
.toast-warn { background: var(--warn-fg); }
.toast-bad  { background: var(--bad-fg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: currentColor;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.hidden { display: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
