/* ===== Reset & Base ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

:root {
  /* Revo Fitness brand palette — brand.revofitness.com.au */
  --primary:       #DD2B32;  /* Brand Red */
  --primary-light: #E85A60;
  --primary-dark:  #AD212D;  /* Dark Red */
  --green:         #16a34a;
  --green-light:   #dcfce7;
  --amber:         #d97706;
  --amber-light:   #fef3c7;
  --red:           #DD2B32;  /* danger = Brand Red */
  --red-light:     #FBEEE7;  /* Light Pink */
  --pink:          #F392BD;  /* Brand Pink */
  --page-bg:       #FCF9F1;  /* Cream — warm page background */
  --bg:            #F1EEE6;  /* subtle warm fill (table headers, section strips, hovers) */
  --surface:       #FFFFFF;
  --border:        rgba(51,49,50,0.15);
  --ink:           #333132;  /* Brand Black */
  --butter:        #FED133;  /* Brand Yellow */
  --mint:          #8BC6C1;  /* Eucalyptus */
  --cream:         #FCF9F1;  /* Cream */
  --text:          #333132;  /* Brand Black */
  --text-muted:    #6E6C6D;
  --danger:        var(--red);    /* status aliases (used throughout app.js) */
  --warning:       var(--amber);
  --success:       var(--green);
  --font-body:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-display:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --sidebar-w:     240px;
  --bottom-nav-h:  64px;
  --header-h:      56px;
  --radius:        16px;
  --shadow:        5px 6px 0 var(--pink);   /* playful pink hard-shadow on cards */
}

html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--page-bg);
  color: var(--text);
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
#app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.logo-icon { color: var(--butter); font-size: 1.1rem; }

.sidebar-nav { padding: 8px 0; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: var(--butter);
}
.sidebar-nav a .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-nav .nav-section {
  padding: 12px 16px 4px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
}

/* Main wrapper */
#main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar */
#top-bar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 2px solid var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  flex-shrink: 0;
}
#top-bar h1 {
  font-size: 1.1rem;
  font-weight: 900;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  flex: 1;
}
#menu-toggle { display: none; }

/* Content */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

/* Bottom nav */
#bottom-nav {
  display: none;
  height: var(--bottom-nav-h);
  background: var(--ink);
  border-top: 2px solid var(--ink);
  align-items: stretch;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
}
#bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .65rem;
  font-weight: 600;
  padding: 4px 2px;
  transition: color .15s, background .15s;
}
#bottom-nav a .nav-icon { font-size: 1.3rem; }
#bottom-nav a.active { color: var(--butter); background: rgba(255,255,255,.08); }

/* ===== Cards & Grids ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h2 {
  font-size: 1.2rem;
  font-weight: 900;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.stat-card .stat-label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat-card .stat-value {
  font-size: clamp(1.5rem, 2.2vw, 2.2rem);
  font-weight: 900;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  color: var(--primary);
  white-space: nowrap;
}
.stat-card .stat-sub { font-size: .85rem; color: var(--text-muted); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.amber .stat-value { color: var(--amber); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card .stat-denom { font-size: 1.1rem; font-weight: 400; color: var(--text-muted); }

/* ===== Driver dashboard ===== */
.driver-van-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--butter);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 10px 16px;
  margin-bottom: 20px;
  font-weight: 700;
  color: var(--ink);
}

.route-list { list-style: none; padding: 0; margin: 0; }
.route-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
}
.route-item:last-child { border-bottom: none; }
.route-item.done { background: #f0fdf4; }
.route-status { width: 22px; text-align: center; font-size: 1rem; }
.route-item:not(.done) .route-status { color: var(--text-muted); }
.route-item.done .route-status { color: var(--green); font-weight: 700; }
.route-name { flex: 1; font-weight: 500; }
.route-item.done .route-name { color: var(--text-muted); }
.route-group-header {
  padding: 6px 18px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: .9rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 18px; }

/* Coloured chip badge for section/card headings (brand "01/02"-style tags) */
.card-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  flex-shrink: 0;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--ink);
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--cream); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 12px;
  font-size: .9rem;
  font-weight: 700;
  font-family: var(--font-body);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 0 0 var(--ink); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-green  { background: var(--green); color: #fff; border-color: var(--ink); }
.btn-green:hover { opacity: .9; }
.btn-amber  { background: var(--butter); color: var(--ink); border-color: var(--ink); }
.btn-amber:hover { opacity: .9; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--ink); }
.btn-danger:hover { opacity: .9; }
.btn-ghost  { background: var(--surface); color: var(--text); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: .8rem; box-shadow: 2px 2px 0 var(--ink); }
.btn-sm:active { transform: translate(1px, 2px); box-shadow: 1px 0 0 var(--ink); }
.btn-icon { padding: 8px; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--bg); }

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 5px;
  color: var(--text-muted);
}
input[type="text"],
input[type="number"],
input[type="search"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-size: .95rem;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(221,43,50,0.2);
}
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Currency prefix input */
.input-prefix-wrap { position: relative; }
.input-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .95rem;
  font-weight: 700;
  pointer-events: none;
}
.input-prefix-wrap input { padding-left: 26px; }

/* Scan input */
.scan-group {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.scan-group input { flex: 1; font-size: 1rem; }
.scan-btn {
  background: var(--primary);
  color: #fff;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .1s, box-shadow .1s;
}
.scan-btn:hover { background: var(--primary-dark); }
.scan-btn:active { transform: translate(2px, 3px); box-shadow: 1px 0 0 var(--ink); }

/* ===== Cart ===== */
.cart-list { list-style: none; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 600; font-size: .95rem; }
.cart-item-sku  { font-size: .78rem; color: var(--text-muted); }
.cart-item-qty  { font-size: 1.1rem; font-weight: 900; font-family: var(--font-display); color: var(--primary); min-width: 40px; text-align: right; }
.cart-empty { padding: 32px; text-align: center; color: var(--text-muted); }

.qty-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.qty-input-row label { margin: 0; white-space: nowrap; }
.qty-input-row input { max-width: 90px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  border: 1.5px solid var(--ink);
}
.badge-warehouse { background: #fde8e9; color: var(--primary-dark); }
.badge-van       { background: var(--butter); color: var(--ink); }
.badge-machine   { background: var(--mint); color: var(--ink); }
.badge-goods_in  { background: #fde8e9; color: var(--primary-dark); }
.badge-load_van  { background: var(--butter); color: var(--ink); }
.badge-fill_machine { background: var(--mint); color: var(--ink); }
.badge-adjustment       { background: #f3e8ff; color: #6b21a8; }
.badge-write_off        { background: #fee2e2; color: #991b1b; }
.badge-transfer_out     { background: #e0f2fe; color: #0369a1; }
.badge-transfer_in      { background: var(--mint); color: var(--ink); }
.badge-transfer-pending  { background: var(--butter); color: var(--ink); }
.badge-transfer-received { background: var(--mint); color: var(--ink); }
.badge-transfer-cancelled{ background: var(--bg); color: var(--text-muted); }

/* ===== Finance month bar ===== */
.finance-month-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 3px 3px 0 var(--ink);
  width: fit-content;
}
.finance-month-label {
  font-weight: 700;
  font-size: 1rem;
  min-width: 130px;
  text-align: center;
  color: var(--text);
}

/* ===== Page tabs ===== */
.page-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0;
}
.page-tab {
  background: none;
  border: none;
  padding: 10px 18px;
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  transition: color .15s, border-color .15s;
}
.page-tab:hover { color: var(--text); }
.page-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

/* Stock qty colouring */
.qty-ok    { color: var(--green); font-weight: 700; }
.qty-warn  { color: var(--amber); font-weight: 700; }
.qty-empty { color: var(--red);   font-weight: 700; }

/* ===== Search bar ===== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 8px 12px;
  max-width: 320px;
  flex: 1;
}
.search-bar input {
  border: none;
  padding: 0;
  font-size: .9rem;
  background: transparent;
  flex: 1;
  box-shadow: none;
}
.search-bar input:focus { box-shadow: none; border-color: transparent; }
.search-icon { color: var(--text-muted); }

/* ===== Overlays ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(51,49,50,.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.overlay.hidden { display: none; }

.overlay-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  box-shadow: 6px 7px 0 var(--pink);
  width: 100%;
  overflow: hidden;
}
.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: .9rem;
  letter-spacing: -0.01em;
}

.scanner-card { max-width: 420px; }
#scanner-region { width: 100%; }
.scanner-hint { text-align: center; padding: 10px; font-size: .85rem; color: var(--text-muted); }

.confirm-card { max-width: 380px; padding: 24px; }
#qty-overlay .overlay-card { max-width: 360px; }
.confirm-card h2 { margin-bottom: 10px; font-size: 1.1rem; font-family: var(--font-display); font-weight: 900; letter-spacing: -0.02em; }
.confirm-card p { color: var(--text-muted); margin-bottom: 4px; }

/* Generic utility — keep last so it wins specificity ties */
.hidden { display: none !important; }

/* User modal: scrolling body so the save button stays in view on short windows */
.user-modal-card {
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.user-modal-card h2 { margin: 0; }
.user-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap input {
  flex: 1;
  padding-right: 40px;
}
.pw-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
}
.pw-toggle:hover { opacity: 1; }
.user-modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface);
}

/* Product pick modal */
.pick-card { max-width: 480px; max-height: 80vh; display: flex; flex-direction: column; }
.pick-results { flex: 1; overflow-y: auto; list-style: none; }
.pick-results li {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.pick-results li:hover { background: var(--cream); }
.pick-results li .pick-name { font-weight: 600; }
.pick-results li .pick-sub  { font-size: .8rem; color: var(--text-muted); }
.pick-results .no-results    { padding: 24px; text-align: center; color: var(--text-muted); }

/* ===== Toasts ===== */
#toasts {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 99px;
  background: var(--ink);
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  animation: slide-in .2s ease;
  max-width: 320px;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.warning { background: var(--butter); color: var(--ink); }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }

/* ===== Workflow steps ===== */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.step {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: relative;
}
.step:last-child { border-right: none; }
.step.active { background: var(--primary); color: #fff; }
.step.done { background: var(--green); color: #fff; }

/* ===== Location select cards ===== */
.loc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.loc-card {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 3px 4px 0 var(--ink);
  padding: 16px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
  text-align: center;
}
.loc-card:hover { background: var(--cream); }
.loc-card:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.loc-card.selected { background: var(--cream); border-color: var(--primary); box-shadow: 3px 4px 0 var(--primary); }
.loc-card .loc-icon { font-size: 1.8rem; margin-bottom: 6px; }
.loc-card .loc-name { font-weight: 700; font-size: .9rem; }
.loc-card .loc-ref  { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Stock level bar ===== */
.stock-bar-wrap { background: var(--border); border-radius: 4px; height: 6px; overflow: hidden; }
.stock-bar { height: 100%; border-radius: 4px; transition: width .3s; }
.stock-bar.ok   { background: var(--green); }
.stock-bar.warn { background: var(--amber); }
.stock-bar.low  { background: var(--red); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .95rem; }

/* ===== Product images ===== */
.prod-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--ink);
  display: block;
}
.prod-thumb-empty {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--bg);
}
.prod-img-preview {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  display: block;
}
.prod-img-placeholder {
  width: 100px;
  height: 100px;
  border-radius: var(--radius);
  border: 2px dashed var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
  background: var(--bg);
  cursor: pointer;
}

/* ===== CSV Import ===== */
.import-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.import-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.import-drop-zone {
  border: 2px dashed var(--ink);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  background: var(--surface);
  transition: border-color .15s, background .15s;
  cursor: default;
}
.import-drop-zone.drag-over {
  border-color: var(--primary);
  background: #fff0f0;
}
.import-drop-zone.has-file {
  border-color: var(--green);
  background: var(--green-light);
}
.import-drop-zone .drop-icon { font-size: 2rem; margin-bottom: 6px; }
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
  font-weight: 700;
  text-decoration: underline;
  padding: 0;
}
.import-result {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
  background: var(--green-light);
  color: #166534;
  border: 1.5px solid var(--green);
}
.import-result.warning {
  background: var(--amber-light);
  color: #92400e;
  border-color: var(--amber);
}
.import-result.error {
  background: var(--red-light);
  color: #991b1b;
  border-color: var(--red);
}

/* ===== Responsive - Mobile ===== */
@media (max-width: 700px) {
  #sidebar { display: none; }
  #menu-toggle { display: flex; }
  #bottom-nav { display: flex; }

  /* Sidebar as drawer on mobile */
  #sidebar.open {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    z-index: 300;
    animation: drawer-in .2s ease;
  }
  #sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(51,49,50,.5);
    z-index: 299;
  }
  @keyframes drawer-in { from { transform: translateX(-100%); } }

  #content { padding: 12px; padding-bottom: calc(var(--bottom-nav-h) + 12px); }
  #toasts { bottom: calc(var(--bottom-nav-h) + 8px); right: 8px; left: 8px; }
  .toast { max-width: 100%; }

  /* Portrait-friendly: single column everywhere */
  .form-row  { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .two-col   { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Page header stacks vertically, full-width buttons */
  .page-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-header .flex { flex-wrap: wrap; }
  .page-header .btn  { flex: 1; justify-content: center; min-width: 0; }
  .page-header input[type="search"],
  .page-header select { width: 100%; max-width: 100% !important; }

  /* Tables: make them scroll horizontally, larger touch targets */
  table { font-size: .82rem; }
  th, td { padding: 10px 8px; }

  /* Larger scan inputs for gloved/outdoor use */
  .scan-group input { font-size: 1.05rem; padding: 12px 10px; }
  .scan-btn { padding: 12px 16px; font-size: 1.4rem; }

  /* Bottom nav labels bigger */
  #bottom-nav a { font-size: .7rem; }
  #bottom-nav a .nav-icon { font-size: 1.4rem; }

  /* Location cards: 2 per row in portrait */
  .loc-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .loc-card { padding: 14px 10px; }
  .loc-card .loc-icon { font-size: 1.5rem; }

  /* Step indicator: compact text */
  .step { font-size: .72rem; padding: 10px 4px; }

  /* Cart items: more breathing room */
  .cart-item { padding: 12px 10px; }
  .cart-item-qty { font-size: 1.2rem; min-width: 36px; }

  /* Overlay cards full height on mobile */
  .pick-card { max-height: 92dvh; }

  /* Product image: smaller in form on mobile */
  .prod-img-preview, .prod-img-placeholder { width: 72px; height: 72px; }

  /* Import drop zone: less padding */
  .import-drop-zone { padding: 16px 10px; }

  /* Hide less important columns */
  .hide-mobile { display: none; }
}

/* ===== Portrait orientation specific (phones held upright) ===== */
@media (max-width: 700px) and (orientation: portrait) {
  /* Dashboard stats: 2×2 grid */
  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Scan group stacks: input full width, buttons row below */
  .scan-group { flex-wrap: wrap; }
  .scan-group input { flex: 1 1 100%; order: 1; font-size: 1.1rem; }
  .scan-btn   { order: 2; flex: 1; }
  .scan-group .btn { order: 3; flex: 1; }

  /* Stat cards: larger value text on wide screens */
  .stat-card .stat-value { font-size: clamp(1.5rem, 2.2vw, 2.2rem); }
}

@media (min-width: 701px) {
  .hide-desktop { display: none; }
}

/* ===== Utilities ===== */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .85rem; }
.text-center { text-align: center; }
.font-bold   { font-weight: 700; }
.mt-4  { margin-top:  16px; }
.mb-4  { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex  { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ===== Login screen ===== */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
#login-screen.hidden { display: none; }

.login-card {
  background: var(--surface);
  border-radius: 24px;
  border: 2.5px solid var(--ink);
  box-shadow: 6px 7px 0 var(--pink);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.login-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 10px;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo-img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: contain;
}
.login-logo .logo-text {
  font-size: 1.25rem;
  font-weight: 900;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  color: var(--text);
}

.login-heading {
  font-size: 1.4rem;
  font-weight: 900;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.login-error {
  color: var(--red);
  font-size: .875rem;
  font-weight: 600;
  background: var(--red-light);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 4px;
}
.login-error.hidden { display: none; }

.btn-block { width: 100%; justify-content: center; margin-top: 4px; }

/* ===== User badge in top bar ===== */
#top-bar {
  position: relative;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: .85rem;
  color: var(--text-muted);
}
.user-badge.hidden { display: none; }
#user-badge-name { font-weight: 700; color: var(--text); }

.user-badge-role {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1.5px solid var(--ink);
  background: var(--bg);
  color: var(--text-muted);
}
.user-badge-role.role-admin {
  background: #fde8e8;
  color: var(--primary-dark);
}

/* ===== Badges (used in Users table) ===== */
.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1.5px solid var(--ink);
}
.badge-primary { background: #fde8e8; color: var(--primary-dark); }
.badge-coord   { background: #e0f2fe; color: #0369a1; }
.badge-neutral { background: var(--bg); color: var(--text-muted); }
.badge-draft   { background: #fff3cd; color: #856404; }

/* ===== Filler location picker (inside user modal) ===== */
.loc-pick-section {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
}
.loc-pick-header {
  background: var(--bg);
  padding: 8px 12px;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.loc-pick-list {
  display: flex;
  flex-direction: column;
  max-height: 160px;
  overflow-y: auto;
}
.loc-pick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.loc-pick-item:last-child { border-bottom: none; }
.loc-pick-item:hover { background: var(--cream); }
.loc-pick-item input { margin: 0; accent-color: var(--primary); }
.loc-pick-state-filter {
  padding: 6px 10px;
  border-bottom: 2px solid var(--ink);
  background: var(--bg);
}
.loc-pick-state-filter select {
  width: 100%;
  font-size: .85rem;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.loc-pick-subheading {
  padding: 5px 12px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.loc-pick-select-all {
  font-size: .72rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
#um-machines.loc-pick-list { max-height: 280px; }

/* Role chip: coordinator */
.user-badge-role.role-coordinator {
  background: #e0f2fe;
  color: #0369a1;
}

.text-red { color: var(--red); }
.text-right { text-align: right; }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
