/* ==========================================================================
   Boonville Show App - stylesheet
   NYS Woodsmen's Field Days inventory counting tool.
   Dark blue + white, high contrast, big tap targets, outdoor daylight use.
   No external fonts or resources. System font stack only.
   ========================================================================== */

:root {
  --navy: #0b2545;
  --navy-dark: #071a33;
  --navy-mid: #14335f;
  --white: #ffffff;
  --bg: #f3f5f7;
  --panel-bg: #ffffff;
  --text: #12202e;
  --text-muted: #46545f;
  --border: #c7cfd6;
  --border-strong: #8b98a5;

  --green: #0f7a3d;
  --green-bg: #dff3e6;
  --green-border: #0f7a3d;

  --red: #b21f1f;
  --red-bg: #fbe2e2;
  --red-border: #b21f1f;

  --amber: #a8620a;
  --amber-bg: #fdedd2;
  --amber-border: #a8620a;

  --grey: #55606b;
  --grey-bg: #e6e9ec;

  --radius: 10px;
  --radius-lg: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --tap-min: 56px;
  --pill-height: 44px;
}

/* We deliberately default to a LIGHT background even when the device is in
   dark mode. This tool is used outdoors in bright August sunlight, and a
   dark screen is harder to read there than a light one. We still nudge a
   few tones under prefers-color-scheme so pure white does not glare, but we
   do not switch to a full dark theme. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #eceff2;
    --panel-bg: #ffffff;
    --border: #b7c0c9;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}

h1, h2, h3 {
  line-height: 1.25;
  margin: 0 0 12px 0;
}
h1 { font-size: 26px; }
h2 { font-size: 22px; }
h3 { font-size: 19px; }

p { margin: 0 0 12px 0; }

a {
  color: var(--navy);
}

/* ---------------------------------------------------------------------- */
/* Status pill - persistent connection indicator, sticky at the very top   */
/* ---------------------------------------------------------------------- */

.status-pill {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--pill-height);
  min-height: var(--pill-height);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 0 10px;
  border-bottom: 2px solid rgba(0,0,0,0.15);
}

.status-green {
  background: var(--green);
  color: var(--white);
}
.status-amber {
  background: var(--amber);
  color: var(--white);
}
.status-grey {
  background: var(--grey);
  color: var(--white);
}

/* Version badge - small corner indicator so the crew can tell at a glance
   whether a phone is running the latest build or a stale cached copy. Sits
   on top of the status pill's right edge, which is otherwise empty space
   since the pill's own text is centered. */
.version-badge {
  position: fixed;
  top: 6px;
  right: 8px;
  z-index: 210;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--grey-bg);
  color: var(--grey);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.version-badge:empty {
  display: none;
}
.version-badge.version-mismatch {
  background: var(--amber);
  color: var(--white);
  font-size: 13px;
  font-weight: 800;
  padding: 5px 10px;
  max-width: 220px;
  text-align: right;
  line-height: 1.3;
}

/* ---------------------------------------------------------------------- */
/* Top bar / nav                                                          */
/* ---------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: var(--pill-height);
  z-index: 190;
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px 14px;
  gap: 8px;
  border-bottom: 3px solid var(--navy-dark);
}

.topbar-brand {
  color: var(--white);
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.01em;
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topbar-nav a {
  color: var(--white);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: var(--radius);
  min-height: 44px;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.08);
}

.topbar-nav a:active,
.topbar-nav a:focus {
  background: rgba(255,255,255,0.22);
}

/* Log out sits on its own row, set apart with a divider and quieter
   styling, so a hand holding a box does not hit it by accident while
   reaching for Home or Check stock mid count. */
.topbar-logout {
  flex-basis: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.3);
  background: none;
  font-weight: 500;
  opacity: 0.85;
}
.topbar-logout:active {
  background: rgba(255,255,255,0.14);
}

/* ---------------------------------------------------------------------- */
/* Layout                                                                  */
/* ---------------------------------------------------------------------- */

.main-content {
  padding: 16px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 10px 20px;
  font-size: 19px;
  font-weight: 700;
  font-family: var(--font);
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:active:not(:disabled) {
  background: var(--navy-dark);
}

.btn-secondary {
  background: var(--white);
  color: var(--navy);
  border-color: var(--navy);
}
.btn-secondary:active:not(:disabled) {
  background: var(--bg);
}

.btn-save {
  background: var(--green);
  color: var(--white);
  font-size: 22px;
  min-height: 64px;
}
.btn-save:active:not(:disabled) {
  background: #0b5c2d;
}

.btn-step {
  background: var(--white);
  color: var(--navy);
  border-color: var(--border-strong);
  font-size: 24px;
  font-weight: 800;
  min-height: 64px;
  width: auto;
  flex: 1;
}
.btn-step:active {
  background: var(--bg);
}

.btn-auto {
  width: auto;
}

.btn-block-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-icon {
  min-width: 64px;
  width: 64px;
  font-size: 15px;
  padding: 6px;
}

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

label, .field-label {
  display: block;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
textarea,
select {
  width: 100%;
  font-size: 19px;
  font-family: var(--font);
  padding: 12px 14px;
  min-height: var(--tap-min);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
}

textarea {
  min-height: 64px;
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  outline: 3px solid var(--navy-mid);
  outline-offset: 1px;
}

.field {
  margin-bottom: 16px;
}

.field-hint {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Big radio "cards" for choosing a session kind */
.radio-card {
  display: block;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 10px;
  min-height: var(--tap-min);
  background: var(--white);
}
.radio-card input[type="radio"] {
  width: 22px;
  height: 22px;
  margin-right: 10px;
  vertical-align: middle;
}
.radio-card-label {
  font-size: 19px;
  font-weight: 700;
  vertical-align: middle;
}
.radio-card-desc {
  font-size: 15px;
  color: var(--text-muted);
  margin: 6px 0 0 32px;
}
.radio-card:has(input:checked) {
  border-color: var(--navy);
  background: #eaf0f8;
}

/* ---------------------------------------------------------------------- */
/* Cards / lists (home, sessions)                                          */
/* ---------------------------------------------------------------------- */

.card {
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.session-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-left: 8px solid var(--navy);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
  min-height: var(--tap-min);
}
.session-card:active {
  background: var(--bg);
}
.session-card.kind-warehouse { border-left-color: #6a3fa0; }
.session-card.kind-opening { border-left-color: var(--green); }
.session-card.kind-closing { border-left-color: var(--red); }

.session-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.session-name {
  font-size: 20px;
  font-weight: 800;
}

.badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--grey-bg);
  color: var(--grey);
  text-transform: uppercase;
}
.badge-warehouse { background: #ece2f6; color: #6a3fa0; }
.badge-opening { background: var(--green-bg); color: var(--green); }
.badge-closing { background: var(--red-bg); color: var(--red); }
.badge-status { background: var(--grey-bg); color: var(--grey); }

.session-meta {
  color: var(--text-muted);
  font-size: 16px;
  margin-top: 6px;
}

.session-links {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.session-links a {
  font-size: 15px;
  font-weight: 700;
  padding: 8px 10px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  border: 2px solid var(--border-strong);
  text-decoration: none;
  color: var(--navy);
}

/* ---------------------------------------------------------------------- */
/* Banners / notices                                                       */
/* ---------------------------------------------------------------------- */

.banner {
  border-radius: var(--radius);
  border: 2px solid;
  padding: 12px 14px;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 14px;
}
.banner-green { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.banner-red { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }
.banner-amber { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber); }
.banner-grey { background: var(--grey-bg); border-color: var(--border-strong); color: var(--text); }

/* ---------------------------------------------------------------------- */
/* Count screen                                                            */
/* ---------------------------------------------------------------------- */

.count-header {
  margin-bottom: 8px;
}
.count-sub {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 600;
}

.progress-line {
  font-size: 18px;
  font-weight: 800;
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 12px 0;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.search-row input {
  flex: 1;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 14px;
  min-height: 44px;
}
.toggle-row input[type="checkbox"] {
  width: 26px;
  height: 26px;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-row {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  min-height: var(--tap-min);
  font-family: var(--font);
  color: var(--text);
}
.item-row:active {
  background: var(--bg);
}
.item-row.is-counted {
  border-left: 8px solid var(--green);
}
.item-row.is-counted.variance-short {
  border-left-color: var(--red);
}
.item-row.is-counted.variance-over {
  border-left-color: var(--amber);
}

.item-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 19px;
  font-weight: 800;
}
.item-row-desc {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 2px;
}
.item-row-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 15px;
  flex-wrap: wrap;
  gap: 6px;
}
.item-row-counted {
  font-weight: 800;
  font-size: 16px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 12px;
  font-size: 17px;
}

/* Count panel - a plain in-flow section, NOT a trapping modal dialog.
   Always has a visible "Back to list" control. */
.count-panel {
  position: fixed;
  inset: 0;
  background: var(--panel-bg);
  z-index: 300;
  overflow-y: auto;
  padding: 16px;
  padding-top: calc(var(--pill-height) + 16px);
}

.count-panel-inner {
  max-width: 700px;
  margin: 0 auto;
}

.panel-close {
  margin-bottom: 0;
}

/* Wraps "Back to list" and "Scan next box" side by side so the panel does
   not force a trip back to the list just to scan the next box. Pinned to
   the top of the panel's own scroll area (position: sticky) so "Scan next
   box" is still visible without scrolling right after a save, no matter
   how far down the confirmation banner scrolls into view. */
.panel-top-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  position: sticky;
  top: 0;
  background: var(--panel-bg);
  z-index: 5;
  padding-top: 4px;
  padding-bottom: 4px;
}
.panel-top-actions .btn {
  width: auto;
  flex: 1;
  margin-bottom: 0;
}

.panel-item-number {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
}
.panel-description {
  font-size: 18px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.panel-expected {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  margin-bottom: 18px;
}
.panel-expected-label {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.panel-expected-qty {
  display: block;
  font-size: 48px;
  font-weight: 900;
  color: var(--navy);
}

/* Cases x each entry (only shown for items with a case_qty) --------------- */
.case-entry-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.case-entry-field {
  flex: 1;
}
.case-entry-field label {
  text-align: center;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.case-entry-input {
  text-align: center;
  font-size: 30px;
  font-weight: 900;
  min-height: 64px;
}
.case-math-line {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 14px;
}

.counter-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 18px;
}

.count-input {
  flex: 1.4;
  text-align: center;
  font-size: 36px;
  font-weight: 900;
  min-height: 64px;
}

.note-label {
  margin-top: 4px;
}
.note-input {
  margin-bottom: 18px;
}

.variance-result {
  margin-top: 16px;
  border-radius: var(--radius-lg);
  border: 3px solid;
  padding: 20px;
  text-align: center;
}
.variance-result .variance-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.03em;
}
.variance-result .variance-detail {
  font-size: 18px;
  margin-top: 6px;
}
.variance-match {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green);
}
.variance-short {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red);
}
.variance-over {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber);
}

.variance-chip {
  display: inline-block;
  font-weight: 800;
  font-size: 14px;
  padding: 3px 9px;
  border-radius: 999px;
}
.variance-chip.match { background: var(--green-bg); color: var(--green); }
.variance-chip.short { background: var(--red-bg); color: var(--red); }
.variance-chip.over { background: var(--amber-bg); color: var(--amber); }

/* ---------------------------------------------------------------------- */
/* Tables (report, dashboard, users)                                       */
/* ---------------------------------------------------------------------- */

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
}

table.data-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: 16px;
}
table.data-table th,
table.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table th {
  background: var(--navy);
  color: var(--white);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
}
table.data-table tr:last-child td {
  border-bottom: none;
}
table.data-table td.wrap {
  white-space: normal;
}
table.data-table tr.row-short td.variance-cell { color: var(--red); font-weight: 800; }
table.data-table tr.row-over td.variance-cell { color: var(--amber); font-weight: 800; }
table.data-table tr.row-match td.variance-cell { color: var(--green); font-weight: 800; }

.totals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.totals-tile {
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: center;
}
.totals-tile-label {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.totals-tile-value {
  font-size: 26px;
  font-weight: 900;
  color: var(--navy);
}

/* ---------------------------------------------------------------------- */
/* Login page                                                              */
/* ---------------------------------------------------------------------- */

.login-wrap {
  max-width: 420px;
  margin: 40px auto;
  padding: 28px 22px;
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
}
.login-title {
  text-align: center;
  color: var(--navy);
  margin-bottom: 4px;
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  margin-bottom: 24px;
}

/* ---------------------------------------------------------------------- */
/* Misc utility                                                            */
/* ---------------------------------------------------------------------- */

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------------- */
/* Home screen - big action tiles                                          */
/* ---------------------------------------------------------------------- */

.tile-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.action-tile {
  display: block;
  min-height: 100px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--navy);
  background: var(--navy);
  color: var(--white);
  text-decoration: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  cursor: pointer;
}
.action-tile:active {
  background: var(--navy-dark);
}

.tile-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.01em;
  display: block;
}
.tile-desc {
  font-size: 16px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  margin-top: 6px;
  display: block;
}

.action-tile-inactive {
  background: var(--grey-bg);
  border-color: var(--border);
  color: var(--text-muted);
  opacity: 0.75;
  cursor: default;
}
.action-tile-inactive:active {
  background: var(--grey-bg);
}
.action-tile-inactive .tile-title {
  color: var(--text-muted);
}
.action-tile-inactive .tile-desc {
  color: var(--text-muted);
}

.tile-inactive-msg {
  margin-top: -6px;
  margin-bottom: 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--amber-bg);
  border: 2px solid var(--amber-border);
  color: var(--amber);
  font-size: 15px;
  font-weight: 700;
}

.session-mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  text-decoration: none;
  color: var(--text);
  min-height: 48px;
}
.session-mini-row:active {
  background: var(--bg);
}
.session-mini-name {
  font-weight: 700;
  font-size: 16px;
}
.session-mini-meta {
  font-size: 14px;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------- */
/* Stock lookup page (read only, expand in place)                          */
/* ---------------------------------------------------------------------- */

.stock-row {
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.stock-row-main {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 12px 14px;
  min-height: var(--tap-min);
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
}
.stock-row-main:active {
  background: var(--bg);
}
.stock-row.is-open .stock-row-main {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}
.stock-detail {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.stock-detail-field {
  font-size: 15px;
}
.stock-detail-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.stock-detail-value {
  font-size: 18px;
  font-weight: 700;
}

/* Scan result card - replaces the search box + list entirely on a scan
   match, so the crew never has to scroll to find what was just scanned. */
.match-card {
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.match-item-number {
  font-size: 34px;
  font-weight: 900;
  color: var(--navy);
  word-break: break-word;
}
.match-description {
  font-size: 19px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.match-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

/* ---------------------------------------------------------------------- */
/* Dashboard sections                                                       */
/* ---------------------------------------------------------------------- */

.dash-section {
  margin-bottom: 26px;
}
.dash-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.dash-refresh-line {
  font-size: 14px;
  color: var(--text-muted);
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-row select {
  width: auto;
  min-width: 160px;
}
.filter-row input[type="text"] {
  flex: 1;
  min-width: 160px;
}

@media (min-width: 640px) {
  .counter-row .btn-step { font-size: 26px; }
  .main-content { padding: 22px; }
}

@media print {
  .status-pill, .topbar, .btn, .search-row, form { display: none !important; }
  body { background: #fff; padding-top: 0; }
}

/* ---------------------------------------------------------------------- */
/* Barcode scan match line + enroll panel (unknown barcode workflow)       */
/* ---------------------------------------------------------------------- */

.scan-match-line {
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
  margin: -8px 0 12px 0;
}

/* Big X button pattern - used to close the scan match card and the enroll
   panel, so both "leave this view" controls look and behave the same way. */
.panel-x-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.panel-x-row-label {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
}
.panel-x-btn {
  flex-shrink: 0;
  min-width: 56px;
  min-height: 56px;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: var(--radius-lg);
  border: 2px solid var(--navy);
  background: var(--white);
  color: var(--navy);
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.panel-x-btn:active {
  background: var(--bg);
}

.enroll-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 12px;
}

.scan-again-btn {
  margin-bottom: 18px;
}

.enroll-code {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: var(--navy);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: center;
  margin-bottom: 18px;
  word-break: break-all;
}

.enroll-results-list {
  margin-top: 12px;
}
.enroll-results-list .item-row {
  cursor: pointer;
}
.enroll-results-list .item-row:active {
  background: var(--bg);
}

/* ---------------------------------------------------------------------- */
/* Diagnostics link (stock page) - confirms the decoder works without a    */
/* camera on hand.                                                        */
/* ---------------------------------------------------------------------- */

.diag-link {
  display: inline-block;
  background: none;
  border: none;
  color: var(--navy);
  font-size: 15px;
  font-weight: 700;
  text-decoration: underline;
  padding: 10px 0;
  min-height: 44px;
  cursor: pointer;
  width: auto;
}

.diag-result {
  font-size: 15px;
  font-weight: 700;
  margin: -4px 0 16px 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--grey-bg);
  color: var(--text);
}

/* ---------------------------------------------------------------------- */
/* Selling sprint (v8) additions                                           */
/* ---------------------------------------------------------------------- */

.badge-amber { background: var(--amber-bg); color: var(--amber); }

.row-dim { opacity: 0.6; }

.btn-small {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 15px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}
.inline-input {
  min-height: 40px;
  padding: 6px 10px;
  font-size: 15px;
  width: auto;
  flex: 1;
  min-width: 90px;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter-form .field {
  margin-bottom: 0;
  min-width: 180px;
  flex: 1;
}

/* Users admin - ON/OFF status ------------------------------------------- */
.user-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.user-status-label {
  font-weight: 900;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}
.user-status-on { background: var(--green-bg); color: var(--green); }
.user-status-off { background: var(--red-bg); color: var(--red); }

/* Dashboard needs-billing, grouped by customer -------------------------- */
.export-links {
  margin-bottom: 18px;
}
.billing-group {
  background: var(--panel-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
}
.billing-summary {
  cursor: pointer;
  padding: 14px 16px;
  list-style: none;
  display: block;
}
.billing-summary::-webkit-details-marker { display: none; }
.billing-customer-name {
  font-size: 19px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.billing-summary-meta {
  display: block;
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 4px;
}
.billing-line-voided {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Bill (sell) screen ----------------------------------------------------- */
.customer-banner {
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.customer-banner-name {
  font-size: 20px;
  font-weight: 800;
}
.customer-banner-meta {
  font-size: 15px;
  color: rgba(255,255,255,0.85);
  margin: 4px 0 10px 0;
}

.sell-step {
  margin-top: 6px;
}

.serial-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.serial-row-input {
  flex: 1;
  font-size: 17px;
}

.sell-mistake-note {
  text-align: center;
  font-size: 14px;
  margin-top: 14px;
}

/* ---------------------------------------------------------------------- */
/* Camera scanner overlay                                                  */
/* ---------------------------------------------------------------------- */

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #000;
  overflow: hidden;
}

/* Belt-and-suspenders: anything inside the overlay that gets the hidden
   attribute must actually disappear, even though a couple of the elements
   below also set their own display value. */
.scanner-overlay [hidden] {
  display: none !important;
}

.scanner-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.scanner-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 78%;
  height: 26%;
  transform: translate(-50%, -50%);
  border: 4px solid var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.scanner-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tap-min) + 46px);
  transform: translateX(-50%);
  width: 100%;
  padding: 0 20px;
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.scanner-starting {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--white);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.scanner-cancel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  min-height: 56px;
  background: var(--white);
  color: var(--navy);
  border: 3px solid var(--white);
  border-radius: var(--radius-lg);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.04em;
  width: auto;
}
.scanner-cancel:active {
  background: var(--bg);
}

.scanner-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  background: var(--green-bg);
  color: var(--green);
  border: 3px solid var(--green-border);
  border-radius: var(--radius-lg);
  padding: 18px 26px;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
  max-width: 80%;
  word-break: break-all;
}

.scanner-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 30px;
  background: var(--panel-bg);
  text-align: center;
}

.scanner-error-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  max-width: 480px;
}

.scanner-error-close {
  min-height: 56px;
  min-width: 200px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 19px;
  font-weight: 800;
  padding: 10px 26px;
}
.scanner-error-close:active {
  background: var(--navy-dark);
}
