/* Bar Par Sheet: clean light dashboard (white cards on a cool grey-blue page, blue accent),
   with an opt-in dark theme on the same layout. Strict CSP: no inline styles; everything
   lives here. Theme is set on <html data-theme> by /js/theme.js before first paint. */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e6ebf3;
  --line: #e3e8f0;
  --line-strong: #cbd4e1;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #5f6b7d;
  --accent: #2563eb;
  --accent-press: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-text: #1d4ed8;
  --accent-soft: #eaf1ff;

  --red: #b91c1c;     --red-soft: #fdeeee;   --red-bar: #dc2626;
  --orange: #c2410c;  --orange-soft: #fff1e6;
  --purple: #6d28d9;  --purple-soft: #f3eeff;
  --green: #047857;   --green-soft: #e8f8f1;
  --blue: #1d4ed8;    --blue-soft: #eaf1ff;

  --track: #e8edf4;
  --paper: #fbfcfe;
  --paper-ink: #1e293b;
  --scrim: rgba(15, 23, 42, 0.38);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.18);
  --glass: rgba(245, 247, 251, 0.82);
  --glass-bar: rgba(255, 255, 255, 0.86);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 16px;
  --radius-sm: 12px;
  --tap: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --topbar-h: calc(var(--safe-t) + 68px);
  --bar-h: 84px;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #131b2e;
  --surface-2: #1a2338;
  --surface-3: #232e47;
  --line: #243049;
  --line-strong: #35425f;
  --ink: #e8edf5;
  --ink-2: #b6c2d4;
  --ink-3: #93a1b7;
  --accent: #2563eb;
  --accent-press: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-text: #8cb4ff;
  --accent-soft: rgba(96, 145, 255, 0.16);

  --red: #fb8a8a;     --red-soft: rgba(248, 113, 113, 0.15);  --red-bar: #f87171;
  --orange: #fdac6c;  --orange-soft: rgba(251, 146, 60, 0.15);
  --purple: #c3aefc;  --purple-soft: rgba(167, 139, 250, 0.16);
  --green: #5ee0b0;   --green-soft: rgba(52, 211, 153, 0.14);
  --blue: #8cb4ff;    --blue-soft: rgba(96, 145, 255, 0.16);

  --track: #222c43;
  --paper: #e9edf4;
  --paper-ink: #111827;
  --scrim: rgba(2, 6, 18, 0.6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
  --glass: rgba(11, 17, 32, 0.82);
  --glass-bar: rgba(19, 27, 46, 0.88);

  color-scheme: dark;
}

/* Theme switch: a short cross-fade so the brightness change isn't a jump. */
:root.theme-anim, :root.theme-anim *, :root.theme-anim *::before, :root.theme-anim *::after {
  transition: background-color 240ms ease, border-color 240ms ease, color 240ms ease, box-shadow 240ms ease !important;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.view:focus { outline: none; }

.icon { width: 22px; height: 22px; flex: none; display: block; }
.num, .tnum { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */

.app { max-width: 600px; margin: 0 auto; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--topbar-h);
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
}
.topbar__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.roundbtn {
  position: relative; width: 48px; height: 48px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  box-shadow: var(--shadow-sm); cursor: pointer; text-decoration: none; padding: 0;
  transition: transform 100ms ease-out, background-color 120ms ease-out;
  touch-action: manipulation;
}
.roundbtn:active { transform: scale(0.94); background: var(--surface-2); }
.roundbtn__dot {
  position: absolute; top: 9px; right: 10px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--red-bar); box-shadow: 0 0 0 2px var(--surface);
}
.icon--sun { display: none; }
:root[data-theme="dark"] .icon--sun { display: block; }
:root[data-theme="dark"] .icon--moon { display: none; }

.net {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 650; color: var(--orange); background: var(--orange-soft);
  padding: 6px 12px; border-radius: 99px;
}
.net .icon { width: 16px; height: 16px; }

.banner {
  margin: 4px 16px 0; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--orange-soft); color: var(--orange); font-size: 15px; font-weight: 600;
}

.view { padding-bottom: calc(var(--bar-h) + 40px + var(--safe-b)); }
body[data-chrome="bare"] .view { padding-bottom: 32px; }

/* ---------- page header ---------- */

.pad { padding: 4px 16px 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack--tight { gap: 8px; }

.page-head { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.page-title { margin: 0; font-size: 32px; line-height: 1.12; font-weight: 800; letter-spacing: -0.025em; }
.page-sub { margin: 0; color: var(--ink-2); font-size: 17px; }
.backlink {
  display: inline-flex; align-items: center; gap: 2px; align-self: flex-start;
  min-height: 44px; margin-left: -6px; padding-right: 8px;
  color: var(--accent-text); text-decoration: none; font-weight: 650; font-size: 16px;
}
.backlink .icon { width: 20px; height: 20px; }

.muted { color: var(--ink-2); margin: 0; }
.fine { color: var(--ink-3); font-size: 14px; margin: 0; }
.meta-line { color: var(--ink-3); font-size: 14px; margin: 0; }
.empty { color: var(--ink-3); margin: 0; padding: 12px 0; }

.section { display: flex; flex-direction: column; gap: 10px; }
.section__title { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -0.01em; }

/* ---------- cards ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
.card--flush { padding: 6px 0; gap: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card--flush .card__head { padding: 12px 18px 6px; }
.card__title { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -0.01em; }
.card__link {
  color: var(--accent-text); font-weight: 650; font-size: 16px; text-decoration: none;
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 2px;
}
.card__notes { margin: 0; color: var(--ink-2); font-style: italic; }

.tile {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tile--red { background: var(--red-soft); color: var(--red); }
.tile--orange { background: var(--orange-soft); color: var(--orange); }
.tile--purple { background: var(--purple-soft); color: var(--purple); }
.tile--green { background: var(--green-soft); color: var(--green); }
.tile--blue { background: var(--blue-soft); color: var(--blue); }
.tile--muted { background: var(--surface-2); color: var(--ink-3); }

/* stat cards (2 x 2) */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); color: var(--ink); text-decoration: none; min-height: 150px;
  transition: transform 100ms ease-out;
}
.stat:active { transform: scale(0.98); }
.stat .tile { margin-bottom: 10px; }
.stat__label { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.stat__value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat__value--text { font-size: 22px; line-height: 1.3; }
.stat__sub { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat--red .stat__sub { color: var(--red); }
.stat--orange .stat__sub { color: var(--orange); }
.stat--purple .stat__sub { color: var(--purple); }
.stat--blue .stat__sub { color: var(--blue); }
.stat__sub.is-calm { color: var(--ink-3); }

/* activity list */
.activity { list-style: none; margin: 0; padding: 0 6px 6px; }
.activity__item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 64px;
  border-radius: var(--radius-sm); color: var(--ink); text-decoration: none;
}
.activity__item:active { background: var(--surface-2); }
.activity__main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.activity__title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity__sub { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity__time { color: var(--ink-3); font-size: 13px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }

/* stock bars */
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.bar__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.bar__name { font-weight: 600; min-width: 0; }
.bar__nums {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink);
}
.bar__nums .icon { width: 16px; height: 16px; }
.bar__unit { color: var(--ink-3); font-weight: 500; }
.bar__track { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar__fill {
  display: block; height: 100%; width: 100%; border-radius: 99px; background: var(--accent);
  transform-origin: left center; transform: scaleX(0);
  transition: transform 500ms var(--ease-out);
}
.bar.is-low .bar__fill { background: var(--red-bar); }
.bar.is-low .bar__nums { color: var(--red); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.01em;
}
.tag--out { background: var(--red-soft); color: var(--red); }
.tag--par { background: var(--purple-soft); color: var(--purple); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 650; font-size: 17px; text-decoration: none; cursor: pointer; user-select: none;
  white-space: nowrap;
  transition: transform 100ms ease-out, background-color 120ms ease-out;
  touch-action: manipulation;
}
.btn .icon { width: 20px; height: 20px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3); }
.btn--primary:active { background: var(--accent-press); }
.btn--ghost { background: var(--surface); border-color: var(--line-strong); }
.btn--ghost:active { background: var(--surface-2); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--danger { background: var(--red-bar); border-color: var(--red-bar); color: #fff; }
.btn--small { min-height: 48px; padding: 0 16px; font-size: 16px; }
.btn--block { width: 100%; }
.btn--icon { min-height: 48px; min-width: 48px; padding: 0; }
.btn--big { min-height: 60px; font-size: 18px; border-radius: 14px; }
.btn__sub { font-weight: 500; opacity: 0.85; font-size: 15px; }

.row-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* bottom action bar: the primary action stays under the thumb */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  max-width: 600px; margin: 0 auto;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: var(--glass-bar);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid var(--line);
}
.actionbar__meta { flex: 1 1 auto; min-width: 0; color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; line-height: 1.3; }
.actionbar .btn { flex: none; min-height: var(--tap); }
.actionbar .btn--block { flex: 1 1 auto; }

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 15px; font-weight: 650; color: var(--ink); }
.field__hint { font-size: 14px; color: var(--ink-3); }
.field input, .field select, .notes {
  min-height: 52px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink);
}
.field input:focus, .field select:focus, .notes:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.notes { resize: vertical; min-height: 92px; line-height: 1.4; width: 100%; }
.form-error { color: var(--red); margin: 0; font-weight: 600; }
.form-error:empty { display: none; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ---------- auth ---------- */

.auth { display: flex; flex-direction: column; gap: 20px; padding: 8px 16px 24px; }
.auth__brand { display: flex; align-items: center; gap: 14px; }
.auth__mark { width: 56px; height: 56px; border-radius: 14px; background: url("/icons/icon-192.png") center / cover; box-shadow: var(--shadow-md); flex: none; }

/* ---------- notices & status ---------- */

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.notice__body { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; min-width: 0; flex: 1; }
.notice p { margin: 0; }
.notice--error { border-color: var(--red-soft); background: var(--red-soft); }
.notice--warn { border-color: var(--orange-soft); background: var(--orange-soft); }
.card .notice { box-shadow: none; border-color: transparent; background: var(--surface-2); }
.card .notice--warn { background: var(--orange-soft); }
.card .notice--error { background: var(--red-soft); }

.status { display: flex; gap: 14px; align-items: flex-start; }
.status__title { margin: 0; font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
.status__text { margin: 4px 0 0; color: var(--ink-2); }

/* ---------- the ticket (the team message) ---------- */

.ticket { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.ticket__paper { filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.08)) drop-shadow(0 6px 14px rgba(15, 23, 42, 0.08)); }
.ticket__body {
  margin: 0; padding: 24px 18px 26px;
  background: var(--paper); color: var(--paper-ink);
  font: 14px/1.55 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere;
  border-radius: 4px;
  /* perforated top and bottom edges, like a printed bar chit */
  -webkit-mask:
    radial-gradient(circle at 7px 0, transparent 4.5px, #000 5px) top left / 14px 51% repeat-x,
    radial-gradient(circle at 7px 100%, transparent 4.5px, #000 5px) bottom left / 14px 51% repeat-x;
  mask:
    radial-gradient(circle at 7px 0, transparent 4.5px, #000 5px) top left / 14px 51% repeat-x,
    radial-gradient(circle at 7px 100%, transparent 4.5px, #000 5px) bottom left / 14px 51% repeat-x;
}
.ticket__actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.ticket__actions--first { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ticket__caption { margin-right: auto; color: var(--ink-3); font-size: 14px; }

/* ---------- tasks ---------- */

.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task .tile { flex: none; }
.task {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.task__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.task__name { font-weight: 700; }
.task__qty { color: var(--orange); font-weight: 700; font-variant-numeric: tabular-nums; }
.task__meta { color: var(--ink-3); font-size: 14px; }
.task__actions { display: flex; gap: 8px; align-items: center; }
.task.is-done { box-shadow: none; background: transparent; }
.task.is-done .task__qty { color: var(--green); }
.assign {
  min-height: 48px; padding: 0 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line-strong); max-width: 150px;
}

/* ---------- count ---------- */

.count__head {
  position: sticky; top: var(--topbar-h); z-index: 10; padding: 12px 16px;
  background: var(--bg);
}

.segmented {
  position: relative; display: flex; padding: 4px; border-radius: 14px; background: var(--surface-3);
}
.segmented__indicator {
  position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 10px;
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: transform 280ms var(--ease-out);
  will-change: transform;
}
.segmented__tab {
  position: relative; z-index: 1; flex: 1; min-height: 52px; padding: 4px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 10px; color: var(--ink-2); cursor: pointer; text-decoration: none;
  font-weight: 650; font-size: 15px; line-height: 1.2; text-align: center;
}
.segmented__tab.is-active { color: var(--ink); }
.segmented__count { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.segmented__tab.is-active .segmented__count { color: var(--accent-text); }
.segmented--plain .segmented__tab.is-active { background: var(--surface); box-shadow: var(--shadow-sm); }
.segmented--grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.segmented--grid .segmented__tab { min-height: 48px; }

.count-list { list-style: none; margin: 0; padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.count-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 84px; padding: 12px 12px 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.count-row__name { display: flex; flex-direction: column; min-width: 0; }
.count-row__title { font-size: 17px; font-weight: 700; line-height: 1.25; }
.count-row__unit { font-size: 14px; color: var(--ink-3); }

.stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.stepper__btn {
  width: var(--tap); height: var(--tap); border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 90ms ease-out, background-color 90ms ease-out;
  touch-action: manipulation;
}
.stepper__btn .icon { width: 24px; height: 24px; stroke-width: 2.5; }
.stepper__btn:active { transform: scale(0.92); background: var(--surface-3); }
.stepper__btn--plus { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.stepper__value {
  width: 60px; height: var(--tap); text-align: center;
  background: transparent; border: 0; border-bottom: 2px solid var(--line-strong); border-radius: 0;
  font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 750; color: var(--ink-3);
}
.count-row.is-touched .stepper__value { color: var(--ink); border-bottom-color: var(--accent); }
.stepper__value:focus { outline: none; border-bottom-color: var(--accent); color: var(--ink); }
.count-next { list-style: none; padding: 10px 0 0; }

/* ---------- review ---------- */

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  min-height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 650; font-size: 15px; cursor: pointer; padding: 0; touch-action: manipulation;
}
.day.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.day__today { font-size: 10px; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; }

.review-list { list-style: none; margin: 0; padding: 0; }
.review-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.review-row:last-child { border-bottom: 0; }
.review-row__main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.review-row__name { font-weight: 700; }
.review-row__nums { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 15px; }
.review-row__by { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.badge {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; font-weight: 700; padding: 6px 10px; border-radius: 99px; font-variant-numeric: tabular-nums;
}
.badge .icon { width: 15px; height: 15px; stroke-width: 2.5; }
.badge--make { background: var(--orange-soft); color: var(--orange); }
.badge--out { background: var(--red-soft); color: var(--red); }
.badge--par { background: var(--purple-soft); color: var(--purple); }
.badge--ok { background: var(--green-soft); color: var(--green); }
.badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }

.summary { display: flex; align-items: center; gap: 12px; }
.summary__text { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -0.01em; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
tr:last-child > th, tr:last-child > td { border-bottom: 0; }
thead th { color: var(--ink-3); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
tbody th { font-weight: 600; }
.num { text-align: right; }
.strong { font-weight: 750; }
.onhand tr.is-low .strong, .onhand tr.is-low th, .onhand tr.is-out th, .onhand tr.is-out .strong { color: var(--red); }

.pargrid th[scope="row"] { position: sticky; left: 0; background: var(--surface); min-width: 140px; z-index: 1; }
.pargrid td { padding: 6px 3px; }
.par {
  width: 48px; height: 48px; text-align: center; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface);
  font-variant-numeric: tabular-nums; font-size: 17px;
}
.par:focus { outline: none; border-color: var(--accent); }
.par.is-bad { border-color: var(--red-bar); color: var(--red); }
.sticky-save { position: sticky; bottom: calc(var(--safe-b) + 12px); display: flex; justify-content: flex-end; }

/* ---------- admin & history lists ---------- */

.admin-list, .history, .plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.admin-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.admin-row__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 140px; }
.admin-row__name { font-weight: 700; }
.admin-row__meta { color: var(--ink-3); font-size: 14px; overflow-wrap: anywhere; }
.admin-row__actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.admin-row.is-off { opacity: 0.65; }

.history__row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--ink); text-decoration: none;
}
.history__when { font-weight: 700; }
.history__who { grid-column: 1; color: var(--ink-3); font-size: 14px; }
.history__tag { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.plain-list li { color: var(--ink-2); }

.choice-list { display: flex; flex-direction: column; gap: 10px; }

.link-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px;
  padding: 0 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  color: var(--ink); text-decoration: none; font-weight: 650;
}
.link-row .icon:last-child { margin-left: auto; color: var(--ink-3); width: 20px; height: 20px; }

/* stock pills */
.pill-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 99px; font-weight: 650; font-size: 15px; }
.pill .icon { width: 16px; height: 16px; }
.pill--out { background: var(--red-soft); color: var(--red); }
.pill--par { background: var(--purple-soft); color: var(--purple); }

/* ---------- drawer (the sidebar, as a slide-in on phones) ---------- */

.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer__scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 260ms ease-out; }
.drawer__panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 330px);
  display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--safe-t) + 16px) 12px calc(var(--safe-b) + 12px);
  background: var(--surface); border-right: 1px solid var(--line); box-shadow: var(--shadow-lg);
  transform: translateX(-104%);
  transition: transform 340ms var(--ease-sheet);
}
.drawer__panel:focus { outline: none; }
.drawer.is-open .drawer__scrim { opacity: 1; }
.drawer.is-open .drawer__panel { transform: translateX(0); }

.drawer__brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.drawer__mark { width: 44px; height: 44px; border-radius: 12px; background: url("/icons/icon-192.png") center / cover; flex: none; }
.drawer__name { font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.drawer__who { color: var(--ink-2); font-size: 14px; }
.drawer__label { margin: 16px 12px 6px; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.drawer__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.drawer__foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }

.navrow {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 14px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-2); text-decoration: none;
  font-weight: 600; font-size: 17px; text-align: left; cursor: pointer;
}
.navrow .icon { color: var(--ink-3); }
.navrow:active { background: var(--surface-2); }
.navrow.is-active { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 3px 0 0 var(--accent); }
.navrow.is-active .icon { color: var(--accent-text); }
.navrow__badge {
  margin-left: auto; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 99px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums;
}

/* ---------- sheet ---------- */

.sheet-root { position: fixed; inset: 0; z-index: 50; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 220ms ease-out; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 600px; margin: 0 auto;
  max-height: 88dvh; overflow-y: auto;
  padding: 8px 20px calc(20px + var(--safe-b));
  background: var(--surface); border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(105%);
  transition: transform 340ms var(--ease-sheet);
}
.sheet-root.is-open .scrim { opacity: 1; }
.sheet-root.is-open .sheet { transform: translateY(0); }
.sheet__grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 12px; }
.sheet__title { font-size: 22px; font-weight: 800; letter-spacing: -0.015em; margin: 0 0 12px; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 16px; right: 16px; z-index: 60; max-width: 568px; margin: 0 auto;
  bottom: calc(var(--bar-h) + var(--safe-b) + 12px);
  padding: 14px 16px; border-radius: 14px; background: #0f172a; color: #f8fafc;
  font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity 180ms ease-out, transform 220ms var(--ease-out);
}
:root[data-theme="dark"] .toast { background: #e8edf5; color: #0f172a; }
.toast.is-on { opacity: 1; transform: translateY(0); }
.toast--error { background: #991b1b; color: #fff; }
:root[data-theme="dark"] .toast--error { background: #fecaca; color: #450a0a; }

/* ---------- top bar "Done" (bar device) ---------- */

.topbar__done { min-width: 88px; }

/* ---------- toggles ---------- */

.toggle { display: flex; align-items: center; gap: 14px; min-height: 56px; cursor: pointer; }
.toggle__text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.toggle__label { font-weight: 650; }
.toggle__input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  position: relative; width: 52px; height: 32px; border-radius: 99px;
  background: var(--line-strong); transition: background-color 180ms ease-out;
}
.toggle__input::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
  transition: transform 220ms var(--ease-out);
}
.toggle__input:checked { background: var(--accent); }
.toggle__input:checked::before { transform: translateX(20px); }
.toggle__input:disabled { opacity: 0.6; }

.linkbtn {
  background: none; border: 0; padding: 0 2px; min-height: 44px; cursor: pointer;
  color: var(--ink); font-weight: 750; font-size: inherit;
}
.auth__or { margin: 0; text-align: center; color: var(--ink-3); font-size: 14px; }

/* ---------- bar device: name grid ---------- */

.names { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.names__btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 128px; padding: 16px 10px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  color: var(--ink); text-decoration: none; font-weight: 700; font-size: 18px;
  transition: transform 100ms ease-out, background-color 120ms ease-out; touch-action: manipulation;
}
.names__btn:active { transform: scale(0.97); background: var(--surface-2); }
.names__avatar {
  width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 800; font-size: 18px; letter-spacing: 0.02em;
}
.names__name { overflow-wrap: anywhere; }

/* ---------- PIN keypad ---------- */

.device--pin {
  min-height: calc(100dvh - var(--topbar-h) - 32px);
  display: flex; align-items: center; justify-content: center; padding: 8px 16px 24px;
}
.pinpad { display: flex; flex-direction: column; align-items: center; text-align: center; width: 100%; max-width: 340px; margin: 0 auto; }
.pinpad__back { align-self: flex-start; margin-bottom: 8px; background: none; border: 0; cursor: pointer; }
.pinpad__title { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -0.025em; }
.pinpad__sub { margin: 8px 0 0; color: var(--ink-2); font-size: 17px; }
.pinpad__dots { display: flex; gap: 16px; margin: 28px 0 0; }
.pinpad__dot {
  width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: transparent;
  transition: background-color 120ms ease-out, border-color 120ms ease-out, transform 160ms var(--ease-out);
}
.pinpad__dot.is-on { background: var(--ink); border-color: var(--ink); transform: scale(1.08); }
.pinpad__dots.is-error .pinpad__dot { border-color: var(--red-bar); }
.pinpad__dots.is-error .pinpad__dot.is-on { background: var(--red-bar); }
.pinpad__dots.is-shake { animation: pin-shake 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-10px); }
  30% { transform: translateX(9px); }
  45% { transform: translateX(-7px); }
  60% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(1px); }
}
.pinpad__msg { margin: 14px 0 0; min-height: 44px; color: var(--red); font-weight: 600; font-size: 15px; max-width: 300px; }
.pinpad__keys {
  display: grid; grid-template-columns: repeat(3, 76px); gap: 18px 28px; justify-content: center; margin-top: 4px;
}
.pinpad__key {
  width: 76px; height: 76px; border-radius: 50%; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums;
  transition: background-color 160ms ease-out, transform 160ms ease-out;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.pinpad__key:active { background: var(--surface-3); transform: scale(0.96); transition-duration: 0ms; }
.pinpad__key:disabled { opacity: 0.45; cursor: default; }
.pinpad__key--quiet { border-color: transparent; color: var(--ink-2); }
.pinpad__key--quiet .icon { width: 28px; height: 28px; stroke-width: 1.75; }
.pinpad__slot { width: 76px; height: 76px; }
.pinpad__foot { margin: 22px 0 0; color: var(--ink-2); font-size: 16px; }
.pinsheet .device--pin, .pinsheet .pinpad { min-height: 0; }

/* ---------- motion & material preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .sheet, .drawer__panel { transform: none; opacity: 0; transition: opacity 160ms linear !important; }
  .sheet-root.is-open .sheet, .drawer.is-open .drawer__panel { opacity: 1; }
  .toast { transform: none; }
  .bar__fill { transition: none !important; }
  .btn:active, .stepper__btn:active, .roundbtn:active, .stat:active, .names__btn:active, .pinpad__key:active { transform: none; }
  .pinpad__dots.is-shake { animation: none; }
  .pinpad__dot.is-on { transform: none; }
  :root.theme-anim, :root.theme-anim * { transition: none !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .actionbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --line: #94a3b8; --line-strong: #64748b; --ink-2: #1e293b; --ink-3: #334155; }
  :root[data-theme="dark"] { --line: #64748b; --line-strong: #94a3b8; --ink-2: #e2e8f0; --ink-3: #cbd5e1; }
}

@media (max-width: 360px) {
  .pinpad__keys { grid-template-columns: repeat(3, 72px); gap: 14px 22px; }
  .pinpad__key, .pinpad__slot { width: 72px; height: 72px; }
  .page-title { font-size: 28px; }
  .stat__value { font-size: 26px; }
  .stepper__btn { width: 52px; height: 52px; }
  .stepper__value { width: 52px; }
}

/* The hidden switch that gives iPhone its haptic tick (see /js/haptics.js). Never seen, never focused. */
.haptic-switch {
  position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; overflow: hidden;
  opacity: 0; pointer-events: none;
}

/* guide placeholder */
.guide-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
