/* ═══════════════════════════════════════════════════════════
   SHARED DASHBOARD — manager / shopper / admin panels
   Depends on styles/main.css for CSS custom properties
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Surfaces ── */
  --bg:          #F5F5F7;   /* Apple’s page background */
  --surface-1:   #FFFFFF;   /* Cards / panels — elevated */
  --surface-2:   #F5F5F7;   /* Table headers, inset areas */
  --surface-3:   #EBEBED;   /* Hover / pressed states */

  /* ── Borders ── */
  --border:        rgba(0,0,0,0.08);
  --border-mid:    rgba(0,0,0,0.12);
  --border-strong: rgba(0,0,0,0.20);

  /* ── Text ── */
  --text-1: #1D1D1F;   /* Apple primary */
  --text-2: #6E6E73;   /* Apple secondary */
  --text-3: #AEAEB2;   /* Apple tertiary */

  /* ── Brand gold (kept for restaurant identity) ── */
  --gold:     #A0783A;
  --gold-dim: rgba(160,120,58,0.12);

  /* ── Apple Blue — the universal “do something” colour ── */
  --blue:        #0071E3;
  --blue-h:      #0077ED;
  --blue-dim:    rgba(0,113,227,0.08);
  --blue-border: rgba(0,113,227,0.22);

  /* ── Semantic — iOS / macOS palette ── */
  --green:         #1A9E43;
  --green-dim:     rgba(26,158,67,0.09);
  --green-border:  rgba(26,158,67,0.22);

  --yellow:        #B25900;
  --yellow-dim:    rgba(178,89,0,0.09);
  --yellow-border: rgba(178,89,0,0.22);

  --red:           #D70015;
  --red-dim:       rgba(215,0,21,0.07);
  --red-border:    rgba(215,0,21,0.20);

  --teal:          #0071A4;
  --teal-dim:      rgba(0,113,164,0.09);
  --teal-border:   rgba(0,113,164,0.22);

  /* ── Shape ── */
  --r-sm:   6px;
  --r:      10px;
  --r-lg:   14px;
  --r-pill: 999px;

  /* ── Shadows — Apple’s extremely subtle depth ── */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05), 0 1px 1px rgba(0,0,0,0.03);
  --shadow:    0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.09), 0 2px 6px rgba(0,0,0,0.04);

  /* ── Typography — SF Pro on Apple, best system font elsewhere ── */
  --font-ui:      -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Cormorant Garamond", Georgia, serif;

  /* ── Legacy aliases (used by JS + main.css nav) ── */
  --accent:         var(--gold);
  --champagne-gold: var(--gold);
  --dash-border:    var(--border);
  --dash-surface:   var(--surface-1);
  --dash-bg-1:      var(--bg);
  --dash-bg-2:      var(--bg);
  --ivory:          var(--text-1);
  --ivory-dim:      var(--text-2);
  --ivory-bright:   var(--text-1);
  --gold-text:      var(--gold);
  --ease-lux:       cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hidden { display: none !important; }

/* ─── BODY / LAYOUT ─── */

.dash-body {
  min-height: 100vh;
  background: var(--bg);
  font-family: var(--font-ui);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
}

.dash-main {
  padding: clamp(5.75rem, 10vw, 7.25rem) 0 3.4rem;
}

.dash-panel {
  display: grid;
  gap: 1.2rem;
}

/* ─── LOGIN FORM ─── */

.dash-form {
  background: var(--surface-1);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  padding: clamp(1.5rem, 4vw, 2.5rem);
  max-width: 440px;
  width: 100%;
  display: grid;
  gap: 1.2rem;
  box-shadow: var(--shadow-lg);
}

.dash-form h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.2;
}

.dash-form .role-badge {
  display: inline-block;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: -0.4rem;
}

.dash-form label { position: relative; }

.dash-form input[type="text"],
.dash-form input[type="password"] {
  width: 100%;
  border: 0;
  border-bottom: 1.5px solid var(--border-mid);
  background: transparent;
  color: var(--text-1);
  padding: 1.1rem 0.2rem 0.5rem;
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 200ms ease;
}

.dash-form input:focus {
  outline: none;
  border-color: var(--blue);
}

.dash-form label span {
  position: absolute;
  left: 0.2rem;
  top: 1.1rem;
  color: var(--text-2);
  font-size: 0.9rem;
  pointer-events: none;
  transition: transform 240ms var(--ease-lux), font-size 240ms var(--ease-lux), color 240ms var(--ease-lux);
}

.dash-form input:focus + span,
.dash-form input:not(:placeholder-shown) + span {
  transform: translateY(-1rem);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--blue);
}

.dash-message {
  min-height: 1.2rem;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-2);
}

.dash-message.error { color: var(--red); }

/* ─── DASHBOARD SHELL ─── */

.dash-dashboard {
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: clamp(1rem, 2.5vw, 1.9rem);
  box-shadow: 0 16px 44px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.03);
}

.dash-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.dash-header-row h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 500;
}

.dash-user-chip {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 0.28rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ─── TABS ─── */

.dash-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dash-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.75rem 1.1rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
  margin-bottom: -1px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

.tab-btn:hover { color: var(--text-1); background: var(--surface-2); }

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── STORE SELECTOR ─── */

.store-select-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.store-select-wrap label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
}

.dash-select {
  background: var(--surface-3);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  min-width: 170px;
  max-width: 100%;
  min-height: 38px;
  transition: border-color 160ms ease;
}

.dash-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-dim); }

.dash-select option { background: var(--surface-2); }

/* ─── KPI CARDS ─── */

.dash-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
  position: relative;
}

.kpi-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.kpi-card p { margin: 0; }

.kpi-card .label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 0.2rem;
}

.kpi-card .value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--text-1);
  line-height: 1;
}

/* ─── DATE NAV ─── */

.dash-toolbar {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.date-nav {
  display: grid;
  grid-template-columns: auto minmax(200px, 300px) auto;
  gap: 0.6rem;
  align-items: center;
}

.dash-arrow {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  cursor: pointer;
  font: inherit;
  transition: background 150ms ease, border-color 150ms ease;
}

.dash-arrow:hover { background: var(--surface-3); border-color: var(--border-strong); }
.dash-arrow:disabled { opacity: 0.35; cursor: default; }

.date-picker-btn {
  min-height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0 1rem;
  text-align: center;
  transition: background 150ms ease, border-color 150ms ease;
  white-space: nowrap;
}

.date-picker-btn:hover { background: var(--surface-3); border-color: var(--blue); }

.hidden-date-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ─── TABLES ─── */

.table-wrap {
  overflow-x: auto;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.dash-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
}

.dash-table td {
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-1);
}

.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr:hover td { background: var(--surface-2); }

/* ─── BADGES ─── */

.badge, .status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--r-pill);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}

.badge.breakfast { background: var(--green-dim);  color: var(--green);  }
.badge.lunch     { background: var(--yellow-dim); color: var(--yellow); }
.badge.dinner    { background: var(--blue-dim);   color: var(--blue);   }

.badge-pending   { background: rgba(0,0,0,0.05);       color: #6E6E73; }
.badge-ordered   { background: var(--blue-dim);         color: var(--blue);            }
.badge-completed { background: var(--green-dim);        color: var(--green);           }
.badge-out       { background: var(--red-dim);          color: var(--red);             }
.badge-replaced  { background: var(--yellow-dim);       color: var(--yellow);          }
.badge-submitted { background: var(--teal-dim);         color: var(--teal);            }
.badge-inprog    { background: var(--yellow-dim);       color: var(--yellow);          }
.badge-draft     { background: rgba(0,0,0,0.05);        color: #AEAEB2;                }

/* ─── STATUS BADGE DOT ─── */
.status-badge::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
  opacity: 0.75;
  flex-shrink: 0;
  vertical-align: middle;
}

/* ─── STATUS SELECT COLORS ─── */
.sel-status-pending      { border-color: rgba(0,0,0,0.12) !important; color: #6E6E73; }
.sel-status-ordered      { border-color: var(--blue-border)   !important; color: var(--blue);   background: var(--blue-dim)   !important; }
.sel-status-completed    { border-color: var(--green-border)  !important; color: var(--green);  background: var(--green-dim)  !important; }
.sel-status-out-of-stock { border-color: var(--red-border)    !important; color: var(--red);    background: var(--red-dim)    !important; }
.sel-status-replaced     { border-color: var(--yellow-border) !important; color: var(--yellow); background: var(--yellow-dim) !important; }
.sel-status-submitted    { border-color: var(--teal-border)   !important; color: var(--teal);   background: var(--teal-dim)   !important; }
.sel-status-in-progress  { border-color: var(--yellow-border) !important; color: var(--yellow); background: var(--yellow-dim) !important; }
.sel-status-draft        { border-color: rgba(0,0,0,0.08)     !important; color: #AEAEB2; }

/* ─── BULK STATUS BAR ─── */
.bulk-status-bar {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  background: var(--blue-dim); border: 1px solid var(--blue-border);
  border-radius: var(--r-sm); padding: 0.4rem 0.8rem;
  margin-bottom: 0.6rem; font-size: 0.8rem; font-weight: 600; color: var(--blue);
}
.bulk-status-bar.hidden { display: none; }
.bulk-count { flex-shrink: 0; white-space: nowrap; }

/* ─── ITEM ROW CHECKBOX ─── */
.item-check-cell { width: 28px; min-width: 28px; padding: 0 0.3rem !important; text-align: center; }
.item-check, .select-all-check {
  width: 15px; height: 15px; accent-color: var(--blue);
  cursor: pointer; vertical-align: middle;
}

/* ─── ACTION BUTTONS ─── */

.btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid var(--red-border);
  background: var(--red-dim);
  color: var(--red);
  cursor: pointer;
  transition: background 150ms ease;
  white-space: nowrap;
}

.btn-delete:hover { background: rgba(247,110,110,0.22); }

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.85rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-mid);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}

.btn-sm:hover { border-color: var(--blue-border); color: var(--blue); background: var(--blue-dim); }

.btn-gold {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--blue);
  border: none;
  border-radius: var(--r-sm);
  color: #fff;
  padding: 0.55rem 1.2rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, transform 100ms ease;
  box-shadow: 0 1px 4px rgba(91,141,238,0.4);
  white-space: nowrap;
}

.btn-gold:hover { background: var(--blue-h); }
.btn-gold:active { transform: scale(0.98); }
.btn-gold:disabled { opacity: 0.45; cursor: default; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  border: 1px solid var(--red-border);
  border-radius: var(--r-sm);
  color: var(--red);
  padding: 0.5rem 1.1rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease;
}

.btn-danger:hover { background: var(--red-dim); }

/* ─── LOADING ─── */

.dash-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 500;
}

.loading-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  animation: pulseDot 1.1s var(--ease-lux) infinite;
}

@keyframes pulseDot {
  0%   { transform: scale(0.8); opacity: 0.5; }
  50%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0.5; }
}

.is-loading-overlay {
  position: relative;
  pointer-events: none;
}

.is-loading-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(245,245,247,0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 10;
}

/* Loading indicator inside a tab panel — full-width centered */
.tab-panel .dash-loading {
  display: flex;
  width: 100%;
  padding: 2.4rem 0;
  justify-content: center;
  font-size: 0.84rem;
}

/* ─── SHOPPING ORDER FORM ─── */

.order-section {
  margin-bottom: 2rem;
}

.order-section h3 {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 0 0 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.order-meta {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.order-meta-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.order-meta-field label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.order-meta-field input[type="date"] {
  background: var(--surface-3);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  min-height: 44px;
}

.order-meta-field input[type="date"]:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-dim); }

/* ─── ORDER TABLE ─── */

.order-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.order-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.order-table th {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 0.55rem 0.5rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.order-table td {
  padding: 0.38rem 0.42rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.order-table tbody tr:last-child td { border-bottom: none; }
.order-table tbody tr:hover td { background: var(--surface-2); }

.col-num  { width: 32px; text-align: center; font-size: 0.78rem; color: var(--ivory-dim); }
.col-item { min-width: 160px; }
.col-qty  { width: 80px; }
.col-where{ width: 160px; }
.col-notes{ min-width: 100px; }
.col-status { width: 130px; }
.col-replace{ min-width: 120px; }
.col-remove { width: 36px; text-align: center; }

/* ─── ORDER INPUTS ─── */

.order-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  transition: border-color 160ms ease, background 160ms ease;
}

.order-input:focus { outline: none; border-color: var(--blue); background: var(--surface-3); box-shadow: 0 0 0 2px var(--blue-dim); }
.order-input::placeholder { color: var(--text-3); }

.order-select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 160ms ease;
  min-height: 36px;
}

.order-select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-dim); }
.order-select option { background: var(--surface-2); }

.remove-row-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  border-radius: var(--r-sm);
  transition: color 150ms ease, background 150ms ease;
}

.remove-row-btn:hover { color: var(--red); background: var(--red-dim); }

/* ─── AUTOCOMPLETE ─── */

.ac-wrap { position: relative; }

.ac-dropdown {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--surface-3);
  border: 1px solid var(--blue-border);
  border-radius: var(--r);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  transition: background 120ms ease;
  gap: 0.4rem;
}

.ac-item:hover { background: var(--blue-dim); }

.ac-name {
  font-size: 0.875rem;
  color: var(--text-1);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-remove {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: var(--r-sm);
  line-height: 1;
  flex-shrink: 0;
  transition: color 120ms ease, background 120ms ease;
}

.ac-remove:hover { color: var(--red); background: var(--red-dim); }

/* ─── ORDER FORM FOOTER ─── */

.order-form-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 0.6rem;
}

/* ─── PAST ORDERS / ORDER CARDS ─── */

.orders-list {
  display: grid;
  gap: 0.7rem;
}

.order-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.92);
  overflow: hidden;
  transition: border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  box-shadow: var(--shadow-sm);
}

.order-card:hover { border-color: var(--border-mid); transform: translateY(-1px); box-shadow: var(--shadow); }

.order-card-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.92rem 1rem;
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(250,250,252,1), rgba(242,243,247,1));
  transition: background 150ms ease;
}

.order-card-head:hover { background: var(--surface-3); }
.order-card.expanded .order-card-head { border-bottom: 1px solid var(--border); }

.order-card-date {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
}

.order-card-meta {
  font-size: 0.75rem;
  color: var(--text-2);
  flex: 1;
}

.order-card-toggle {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-left: auto;
  transition: transform 200ms ease;
  flex-shrink: 0;
}

.order-card.expanded .order-card-toggle { transform: rotate(180deg); }

/* Hide non-essential header items on mobile */
@media (max-width: 640px) {
  .order-card-head .order-card-meta { display: none; }
  .order-status-pill { margin-left: 0 !important; }
  .item-row-main { flex-wrap: wrap; }
  .item-name-text { white-space: normal; }
}

.order-card-body { display: none; }
.order-card.expanded .order-card-body { display: block; }

.order-items-table {
  width: 100%;
  border-collapse: collapse;
}

.order-items-table th {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.order-items-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-1);
  vertical-align: middle;
}

.order-items-table tbody tr:last-child td { border-bottom: none; }

/* Shopper editable item rows (div-based, replaced old tr/td) */
.items-list {
  border-top: 1px solid var(--border);
}

.items-list-hdr {
  padding: 0.4rem 0.75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  cursor: pointer;
  user-select: none;
}

.item-row-edit {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background 150ms;
}

.item-row-edit:last-child { border-bottom: none; }
.item-row-edit:hover { background: var(--surface-2); }
.item-row-edit.is-saving { opacity: 0.72; }
.item-row-edit.is-saved  { background: color-mix(in srgb, var(--green) 6%, var(--surface-1)); }

/* Status-tinted row backgrounds (all non-pending statuses get a subtle wash) */
.item-row-edit[data-status="completed"]    { background: color-mix(in srgb, var(--green)  10%, var(--surface-1)); }
.item-row-edit[data-status="ordered"]      { background: color-mix(in srgb, var(--blue)    8%, var(--surface-1)); }
.item-row-edit[data-status="out-of-stock"] { background: color-mix(in srgb, var(--red)     8%, var(--surface-1)); }
.item-row-edit[data-status="replaced"]     { background: color-mix(in srgb, var(--yellow) 10%, var(--surface-1)); }

.item-row-edit[data-status="completed"]:hover    { background: color-mix(in srgb, var(--green)  16%, var(--surface-1)); }
.item-row-edit[data-status="ordered"]:hover      { background: color-mix(in srgb, var(--blue)   13%, var(--surface-1)); }
.item-row-edit[data-status="out-of-stock"]:hover { background: color-mix(in srgb, var(--red)    13%, var(--surface-1)); }
.item-row-edit[data-status="replaced"]:hover     { background: color-mix(in srgb, var(--yellow) 15%, var(--surface-1)); }

.item-row-main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.item-row-main .qty-input {
  width: 62px;
  min-width: 62px;
  flex-shrink: 0;
  padding: 0.32rem 0.42rem;
  min-height: 36px;
}

.item-row-main .where-select {
  flex: 1;
  min-width: 110px;
  padding: 0.32rem 0.42rem;
  min-height: 36px;
}

.item-name-text {
  flex: 1;
  min-width: 80px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-row-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.notes-field-cell {
  display: none;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-mid);
}
.notes-field-cell.notes-open { display: block; }

.replaced-field {
  display: none;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-mid);
}
.replaced-field.show { display: block; }

/* ─── INLINE IMAGE (item camera button) ─── */
.item-img-inline {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.item-img-inline .item-thumb {
  width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block;
}

.item-img-inline .item-cam-btn {
  background: none; border: none; font-size: 1rem; cursor: pointer;
  color: var(--text-3); padding: 0; line-height: 1; transition: color 150ms;
}
.item-img-inline .item-cam-btn:hover { color: var(--text-1); }
.item-img-inline .item-cam-btn.img-exists {
  position: absolute; bottom: 1px; right: 1px; font-size: 0.65rem;
  opacity: 0; transition: opacity 0.15s;
}
.item-img-inline:hover .item-cam-btn.img-exists { opacity: 1; }

.item-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
}

.iab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border-mid);
  background: var(--surface-2);
  cursor: pointer;
  color: var(--text-3);
  transition: background 140ms, border-color 140ms, color 140ms;
  flex-shrink: 0;
  padding: 0;
}

.iab:hover { background: var(--surface-3); border-color: var(--border); color: var(--text-1); }

.iab-complete.active {
  background: var(--green-dim); border-color: var(--green-border); color: var(--green);
}
.iab-complete.active:hover { background: rgba(80,175,110,0.22); }

.iab-more.active              { border-color: var(--yellow-border); color: var(--yellow); background: var(--yellow-dim); }
.iab-more.active.st-ordered   { border-color: var(--blue-border);   color: var(--blue);   background: var(--blue-dim);   }
.iab-more.active.st-out-of-stock { border-color: var(--red-border); color: var(--red);   background: var(--red-dim);    }
.iab-more.active.st-replaced  { border-color: var(--yellow-border); color: var(--yellow); background: var(--yellow-dim); }

.iab-notes.has-notes { border-color: var(--blue-border); color: var(--blue); background: var(--blue-dim); }

/* More dropdown */
.iab-more-wrap { position: relative; }

.iab-more-list {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--surface-3);
  border: 1px solid var(--border-mid);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  min-width: 150px;
  overflow: hidden;
}

.iab-more-list.hidden { display: none; }

.iab-more-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.8rem;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-1);
  transition: background 110ms;
}

.iab-more-opt:hover { background: var(--blue-dim); }
.iab-more-opt.current { color: var(--blue); font-weight: 700; }

.replaced-field { display: none; }
.replaced-field.show { display: table-cell; }

/* ─── ADMIN FORMS (stores / users) ─── */

.admin-section {
  margin-bottom: 2rem;
}

.admin-section h3 {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field label {
  font-size: 0.69rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field select {
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  min-height: 38px;
  transition: border-color 160ms ease;
}

.form-field input:focus,
.form-field select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-dim); }

.form-field select option { background: var(--surface-2); }

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  color: var(--ivory-bright);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.checkbox-group input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── USER / STORE CARDS (admin list) ─── */

.entity-list {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.entity-card {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  transition: border-color 150ms ease;
}

.entity-card:hover { border-color: var(--border-mid); }

.entity-info { flex: 1; min-width: 0; }

.entity-name {
  font-size: 0.9rem;
  color: var(--ivory-bright);
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.entity-sub {
  font-size: 0.75rem;
  color: var(--ivory-dim);
}

.entity-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.role-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: var(--r-pill);
}

.role-chip.manager { background: var(--blue-dim);  color: var(--blue);  }
.role-chip.shopper { background: var(--green-dim); color: var(--green); }

/* ─── TOGGLE SWITCH ─── */

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--ivory-dim);
  cursor: pointer;
  user-select: none;
}

.toggle-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ─── INLINE EDIT PANEL ─── */

.inline-edit {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--r) var(--r);
  padding: 1rem;
  margin-top: -1px;
}

.inline-edit.show { display: block; }

/* ─── SHEET URL INPUT ─── */

.sheet-url-row {
  display: none;
  margin-top: 0.5rem;
}

.sheet-url-row.show { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.sheet-url-row input[type="text"] {
  flex: 1;
  min-width: 200px;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.875rem;
}

.sheet-url-row input:focus { outline: none; border-color: var(--blue); }

.setup-note {
  color: var(--text-2);
  font-size: 0.82rem;
  line-height: 1.45;
}

.setup-ok {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 600;
}

.setup-muted {
  color: var(--text-2);
  font-size: 0.78rem;
}

/* ─── TOAST ─── */

.toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: 0.7rem 1.1rem;
  font-family: var(--font-ui);
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-1);
  border: 1px solid;
  border-radius: var(--r);
  z-index: 9999;
  transform: translateY(10px);
  opacity: 0;
  transition: transform 260ms var(--ease-lux), opacity 260ms ease;
  max-width: calc(100vw - 2.5rem);
  pointer-events: none;
  background: var(--surface-3);
  box-shadow: var(--shadow-lg);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green-border); }
.toast.error   { border-color: var(--red-border);   }
.toast.info    { border-color: var(--blue-border);  }

.upload-status {
  display: block;
  margin-top: 0.32rem;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--text-2);
}

.upload-status.is-error { color: var(--red); }
.upload-status.is-success { color: var(--green); }

.item-img-btn.is-uploading,
.catalog-item-img-btn.is-uploading {
  min-width: 54px;
  font-variant-numeric: tabular-nums;
}

/* ─── EMPTY STATE ─── */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-3);
  font-size: 0.875rem;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
}

.empty-state.error-state {
  color: var(--red);
  background: var(--red-dim);
  border-color: var(--red-border);
}

/* ─── DATE FILTER ─── */

.date-filter-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.date-filter-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* ─── HISTORY / INSIGHTS ─── */

.history-toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.history-date-input,
.history-search-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(248,245,240,0.26);
  color: var(--ivory);
  padding: 0.45rem 0.7rem;
  font: inherit;
  min-height: 40px;
  border-radius: 10px;
}

.history-date-input:focus,
.history-search-input:focus {
  outline: none;
  border-color: var(--blue);
}

.history-search-field {
  min-width: 220px;
  flex: 1 1 220px;
}

.history-table .trend-link {
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.16rem;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
}

.history-trend-content {
  width: min(760px, calc(100vw - 24px));
  max-height: min(88vh, 860px);
  overflow: auto;
  padding: 1.2rem 1.1rem 1rem;
  background: var(--surface-1);
}

.trend-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding-right: 2rem;
}

.trend-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.trend-sub {
  margin-top: 0.3rem;
  color: var(--text-2);
  font-size: 0.82rem;
}

.trend-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.trend-kpi {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem;
  background: var(--surface-2);
}

.trend-kpi .label {
  color: var(--text-2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.trend-kpi .value {
  margin-top: 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.trend-chart {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.trend-bar-row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 0.6rem;
  align-items: center;
}

.trend-bar-label,
.trend-bar-value {
  font-size: 0.78rem;
  color: var(--text-2);
}

.trend-bar-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.trend-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--yellow));
}

.trend-source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.trend-source-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.38rem 0.7rem;
  font-size: 0.76rem;
  background: var(--surface-2);
}

/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  /* ── General layout ── */
  .dash-kpis         { grid-template-columns: 1fr; }
  .trend-kpis        { grid-template-columns: 1fr 1fr; }
  .dash-header-row   { flex-direction: column; align-items: flex-start; }
  .date-nav          { grid-template-columns: auto 1fr auto; width: 100%; }
  .store-select-wrap,
  .date-filter-row,
  .history-toolbar   { flex-direction: column; align-items: stretch; }
  .dash-select       { min-width: 100%; }
  .order-meta        { flex-direction: column; }
  .order-meta-field  { width: 100%; }
  .order-meta-field input[type="date"] { width: 100%; }
  .tab-btn           { padding: 0.65rem 0.75rem; font-size: 0.74rem; }
  .form-grid         { grid-template-columns: 1fr; }
  .entity-card       { flex-direction: column; align-items: flex-start; }
  .entity-actions    { width: 100%; justify-content: flex-end; }
  .trend-bar-row     { grid-template-columns: 76px 1fr auto; }

  /* Order form actions: full-width stacked buttons */
  .order-form-actions             { flex-direction: column; align-items: stretch; }
  .order-form-actions > *         { width: 100%; justify-content: center; min-height: 46px; font-size: 0.9rem; }

  /* ── ORDER TABLE → 2-column grid cards ── */
  .order-table-wrap { border: none; overflow: visible; }
  .order-table      { min-width: 0; }
  .order-table thead { display: none; }
  .order-table tbody { counter-reset: row-counter; }

  .order-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    padding: 0.85rem;
    margin-bottom: 0.6rem;
    border: 1px solid var(--border-mid);
    border-radius: var(--r);
    background: var(--surface-2);
    position: relative;
    box-shadow: var(--shadow-sm);
  }

  /* Row label */
  .order-table tbody tr::before {
    content: "Item " counter(row-counter);
    counter-increment: row-counter;
    grid-column: 1 / -1;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 0.15rem;
  }

  .order-table td {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border: none;
    padding: 0;
    font-size: 0.875rem;
  }

  .order-table td::before {
    content: attr(data-label);
    font-size: 0.61rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
  }

  /* Column placement within 2-col grid */
  .col-item    { grid-column: 2 / -1; }  /* item: col 2 to end */
  .col-qty     { grid-column: 1; }        /* qty: left  */
  .col-where   { grid-column: 2; }        /* where: right */
  .col-notes   { grid-column: 1 / -1; }  /* notes: full width */
  .col-status  { grid-column: 1 / -1; }
  .col-replace { grid-column: 1 / -1; }
  .col-num     { display: none; }
  .col-img     { grid-column: 1; }

  /* Remove button: absolute top-right */
  .col-remove {
    position: absolute;
    top: 0.55rem;
    right: 0.6rem;
    padding: 0;
    width: auto;
    border: none;
  }
  .col-remove::before { display: none !important; }

  /* Touch-friendly inputs inside cards */
  .order-table td .order-input,
  .order-table td .order-select { min-height: 44px; font-size: 0.9rem; }

  /* ── SHOPPER items list is now div-based, no table overrides needed ── */
  .order-items-table { min-width: 0; }
  .order-items-table thead { display: none; }
}

@media (max-width: 760px) {
  .dash-kpis { grid-template-columns: 1fr; }
}

/* ─── PASSWORD VISIBILITY TOGGLE ─── */

/* Floating-label password field wrapper */
.has-pw-toggle { position: relative; }

.has-pw-toggle input[type="password"],
.has-pw-toggle input[type="text"] {
  padding-right: 2.4rem;
}

/* Non-floating-label wrapper (form-field inputs) */
.pw-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-input-wrap input[type="password"],
.pw-input-wrap input[type="text"] {
  width: 100%;
  padding-right: 2.4rem;
}

/* Toggle button shared styles */
.pw-toggle {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 0.35rem 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 160ms ease;
  z-index: 2;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}

.pw-toggle:hover { color: var(--text-2); }
.pw-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ─── ITEM IMAGE THUMBNAILS ─── */
.item-img-cell { width: 52px; min-width: 52px; }
.item-img-wrap {
  position: relative; width: 44px; min-width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.item-thumb {
  width: 44px; height: 44px; object-fit: cover;
  border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--border); flex-shrink: 0; display: block;
  transition: opacity 0.15s;
}
.item-thumb:hover { opacity: 0.82; }
.item-img-btn {
  padding: 0; width: 44px; height: 44px; font-size: 1.1rem;
  background: var(--surface-3); border: 2px dashed var(--border-mid);
  border-radius: var(--r-sm); cursor: pointer; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.item-img-btn:hover { background: var(--surface-2); color: var(--text-1); border-color: var(--blue); }
.item-img-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Camera overlays thumb when image is present */
.item-img-wrap:has(.item-thumb) .item-img-btn {
  position: absolute; bottom: 0; right: 0;
  width: 18px; height: 18px; font-size: 0.58rem;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 4px; z-index: 1;
}
/* Autocomplete thumbnail */
.ac-thumb {
  width: 28px; height: 28px; object-fit: cover;
  border-radius: 4px; flex-shrink: 0; vertical-align: middle;
}

/* ─── CATALOG ITEMS LIST ─── */
.catalog-items-list { display: flex; flex-direction: column; gap: 0; }
.catalog-item-row {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.6rem 0.75rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-bottom: none;
  transition: background 0.12s;
}
.catalog-item-row:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.catalog-item-row:last-child  { border-bottom: 1px solid var(--border); border-radius: 0 0 var(--r-sm) var(--r-sm); }
.catalog-item-row:only-child  { border-radius: var(--r-sm); border-bottom: 1px solid var(--border); }
.catalog-item-row:hover { background: var(--surface-2); }
.catalog-item-img-cell { position: relative; flex-shrink: 0; width: 44px; height: 44px; }
.catalog-item-thumb {
  width: 44px; height: 44px; object-fit: cover;
  border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--border); display: block;
  transition: opacity 0.15s;
}
.catalog-item-thumb:hover { opacity: 0.82; }
.catalog-item-thumb-placeholder {
  width: 44px; height: 44px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 2px dashed var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--text-3); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.catalog-item-thumb-placeholder:hover { background: var(--surface-2); border-color: var(--blue); }
.catalog-item-img-upload { display: none; }
.catalog-item-img-btn {
  position: absolute; bottom: -2px; right: -2px;
  width: 18px; height: 18px; font-size: 0.58rem; padding: 0;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; z-index: 1;
  display: flex; align-items: center; justify-content: center;
}
.catalog-item-img-btn:hover { background: var(--surface-2); }
.catalog-item-img-btn:disabled { opacity: 0.5; }
.catalog-item-fields {
  flex: 1; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; min-width: 0;
}
.catalog-item-name-input { flex: 2; min-width: 100px; font-weight: 600; }
.catalog-item-where  { flex: 1.5; min-width: 100px; }
.catalog-item-notes  { flex: 1.5; min-width: 80px; }
.catalog-item-actions {
  display: flex; flex-direction: column; gap: 0.25rem; flex-shrink: 0;
}
.catalog-item-actions .catalog-save-btn   { padding: 0.28rem 0.7rem;  font-size: 0.72rem; }
.catalog-item-actions .catalog-delete-btn { padding: 0.28rem 0.55rem; font-size: 0.78rem; }
/* ─── IMAGE MODAL ─── */
.img-modal {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.img-modal.hidden { display: none; }
.img-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.74); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.img-modal-content {
  position: relative; z-index: 1;
  max-width: min(92vw, 680px); max-height: 90vh;
  display: flex; align-items: center; justify-content: center;
}
.img-modal-img {
  max-width: 100%; max-height: 88vh; display: block;
  border-radius: var(--r-lg);
  box-shadow: 0 28px 72px rgba(0,0,0,0.45);
}
.img-modal-close {
  position: absolute; top: -14px; right: -14px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-1); border: 1px solid var(--border);
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-1); box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  transition: background 0.15s;
}
.img-modal-close:hover { background: var(--surface-3); }

/* ─── SHARE SHEET ─── */
.share-sheet {
  position: fixed; inset: 0; z-index: 2100;
  display: flex; align-items: flex-end; justify-content: center;
}
.share-sheet.hidden { display: none; }
.share-sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.share-sheet-panel {
  position: relative; z-index: 1;
  width: 100%; max-width: 480px;
  background: var(--surface-1);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 1.2rem 1.4rem 2.2rem;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.22);
  border: 1px solid var(--border); border-bottom: none;
  animation: shareSlideUp 0.22s var(--ease-lux);
}
@keyframes shareSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.share-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.9rem;
}
.share-sheet-title { font-size: 0.88rem; font-weight: 600; color: var(--text-1); }
.share-sheet-close {
  padding: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--border);
  cursor: pointer; color: var(--text-2); font-size: 0.88rem;
  display: flex; align-items: center; justify-content: center;
}
.share-sheet-preview {
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 0.65rem 0.85rem;
  font-size: 0.72rem; color: var(--text-2); line-height: 1.65;
  white-space: pre-wrap; max-height: 130px; overflow-y: auto;
  margin-bottom: 1rem; font-family: 'SF Mono', 'Fira Mono', monospace;
}
.share-sheet-btns {
  display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap;
}
.share-action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  padding: 0.85rem 1rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; color: var(--text-1); min-width: 88px;
  font-size: 0.76rem; font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}
.share-action-btn:hover { background: var(--surface-3); border-color: var(--blue); }
.share-icon {
  width: 22px; height: 22px;
  stroke: currentColor;
  display: block; flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   ERP / APP-SHELL OVERRIDES — clean Apple-style admin panels
   These intentionally override the marketing-site header styles
   loaded from main.css, but only on dashboard pages.
   ═══════════════════════════════════════════════════════════ */

.dash-body .site-header,
.dash-body .site-header.scrolled {
  background: rgba(255,255,255,0.82);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
}

.dash-body .brand,
.dash-body .nav-links a,
.dash-body .btn-nav {
  color: var(--text-1);
}

.dash-body .brand {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
}

.dash-body .nav-links a {
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.dash-body .nav-links a:hover { color: var(--blue); }

.dash-body .btn-nav {
  min-height: 36px;
  border: 1px solid var(--border-mid);
  background: #fff;
  border-radius: var(--r-pill);
  color: var(--text-1) !important;
  letter-spacing: 0;
  text-transform: none;
}

.dash-body .btn-nav:hover {
  background: var(--surface-2);
  color: var(--text-1) !important;
}

.dash-main { padding-top: 5.25rem; }

.dash-dashboard.dash-with-tabs {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-areas:
    "head head"
    "tabs body";
  gap: 1.25rem;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.dash-dashboard.dash-single {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2vw, 1.35rem);
}

.dash-header-row {
  grid-area: head;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem;
  margin-bottom: 0;
}

.dash-header-row h2 {
  font-family: var(--font-ui);
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.035em;
}

.dash-user-chip {
  background: var(--surface-2);
  color: var(--text-2);
  border: 0;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.dash-tabs {
  grid-area: tabs;
  position: sticky;
  top: 5.25rem;
  align-self: start;
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0.55rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: visible;
}

.tab-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  justify-content: flex-start;
  text-align: left;
  border: 0;
  border-radius: 12px;
  margin: 0;
  padding: 0.72rem 0.85rem;
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 600;
}

.tab-btn::before {
  width: 1.25rem;
  text-align: center;
  color: var(--text-3);
  font-size: 0.98rem;
}

.tab-btn[data-tab="orders"]::before       { content: "\25A1"; }  /* □ */
.tab-btn[data-tab="stores"]::before       { content: "\25C7"; }  /* ◇ */
.tab-btn[data-tab="items"]::before        { content: "\2606"; }  /* ☆ */
.tab-btn[data-tab="users"]::before        { content: "\25CB"; }  /* ○ */

.tab-btn.active::before { color: var(--blue); }

.tab-btn:hover { background: var(--surface-2); color: var(--text-1); }

.tab-btn.active {
  background: var(--blue-dim);
  color: var(--blue);
  border: 0;
}

.tab-panel.active {
  grid-area: body;
  display: block;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2vw, 1.35rem);
}

.dash-form {
  margin-inline: auto;
  background: rgba(255,255,255,0.92);
  border-radius: 24px;
  border-color: rgba(0,0,0,0.06);
}

.dash-form h2 {
  font-family: var(--font-ui);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.dash-form .role-badge {
  color: var(--text-2);
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.dash-form input[type="text"],
.dash-form input[type="password"],
.form-field input[type="text"],
.form-field input[type="password"],
.form-field select,
.order-input,
.order-select,
.dash-select,
.order-meta-field input[type="date"],
.date-filter-row input[type="date"] {
  background: #fff !important;
  border: 1px solid var(--border-mid) !important;
  border-radius: 10px !important;
  color: var(--text-1) !important;
}

.dash-form input[type="text"],
.dash-form input[type="password"] {
  background: transparent !important;
  border-width: 0 0 1px !important;
  border-radius: 0 !important;
}

.btn-gold,
.btn-solid {
  background: var(--blue) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: var(--r-pill) !important;
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.btn-gold:hover,
.btn-solid:hover { background: var(--blue-h) !important; }

.store-select-wrap,
.date-filter-row,
.dash-kpis,
.order-meta,
.order-form-actions { margin-bottom: 1rem; }

.store-select-wrap,
.date-filter-row {
  background: var(--surface-2);
  border-color: var(--border);
  border-radius: 14px;
}

.dash-table th,
.order-table th,
.order-items-table th {
  background: var(--surface-2);
  color: var(--text-2);
}

.order-card,
.entity-card,
.kpi-card {
  background: #fff;
  border-color: var(--border);
  border-radius: 14px;
}

.order-card-head { background: var(--surface-2); }

@media (max-width: 820px) {
  .dash-dashboard.dash-with-tabs {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "tabs"
      "body";
  }

  .dash-tabs {
    position: static;
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    border-radius: 16px;
    padding: 0.45rem;
  }

  .tab-btn {
    width: auto;
    flex: 0 0 auto;
    text-align: center;
    padding: 0.62rem 0.85rem;
    font-size: 0.84rem;
  }

  .tab-panel.active { padding: 1rem; }
}

/* ─── COMPACT FILTER BAR ─── */
.filter-bar {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.95rem;
  padding: 0.85rem 0.95rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(245,245,247,0.95));
  border: 1px solid var(--border);
  border-radius: 16px;
}

.filter-bar-sel,
.filter-bar-input {
  flex: 1;
  min-width: 88px;
  height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-sm);
  color: var(--text-1);
  padding: 0 0.6rem;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 160ms ease;
}

.filter-bar-sel:focus,
.filter-bar-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-dim); }

.filter-bar-refresh {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* ─── ORDER STATUS PILL (in card head) ─── */
.order-status-pill {
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  padding: 0.28rem 0.7rem !important;
  min-height: 30px !important;
  width: auto !important;
  min-width: 108px;
  border-radius: 100px !important;
  margin-left: auto;
  flex-shrink: 0;
  cursor: pointer;
  line-height: 1.4;
}

/* ─── ROW SAVE INDICATOR ─── */
.row-save-ind {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-left: 0.3rem;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.25s, background 0.25s;
  flex-shrink: 0;
}

.is-saving .row-save-ind {
  opacity: 1;
  background: var(--blue);
  animation: row-save-pulse 0.75s ease-in-out infinite;
}

.is-saved .row-save-ind {
  opacity: 1;
  background: var(--green);
}

.is-saving td { transition: opacity 0.2s; opacity: 0.72; }
.is-saved  td { transition: opacity 0.2s; opacity: 1; }

@keyframes row-save-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.5); }
}

/* ─── NOTES TOGGLE BTN ─── */
/* Replaced by .iab-notes action button */
.notes-toggle-btn { display: none; }

/* Notes field: visible on desktop, hidden on mobile (see 640px block above) */

/* ─── STATUS SELECT APPEARANCE ─── */
.item-status-select {
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  min-width: 130px;
}

/* ─── ORDER STORE CHIP ─── */
.order-store-chip {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  background: color-mix(in srgb, var(--blue) 12%, var(--surface-3));
  border: 1px solid color-mix(in srgb, var(--blue) 25%, var(--border));
  border-radius: 100px;
  color: var(--blue);
  white-space: nowrap;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

/* ─── MOBILE-FIRST IMPROVEMENTS ─── */

/* Ensure all interactive elements meet 44px touch target */
@media (max-width: 768px) {
  /* Base touch targets */
  .btn, .btn-sm, .btn-danger, button[type="button"], button[type="submit"],
  .order-select, .order-input, .dash-select, select, input[type="text"],
  input[type="date"], input[type="email"], input[type="password"] {
    min-height: 46px;
    font-size: 1rem;
  }

  /* Login form: bigger & more comfortable */
  .login-card  { padding: 2rem 1.5rem; }
  .form-label  { font-size: 0.95rem; margin-bottom: 0.35rem; }
  .form-input  { font-size: 1rem; padding: 0.75rem 0.9rem; min-height: 50px; }

  /* Navigation */
  .dash-nav         { padding: 0 1rem; min-height: 56px; }
  .nav-user-chip    { font-size: 0.82rem; padding: 0.35rem 0.7rem; min-height: 36px; }
  .logout-btn       { min-height: 38px; padding: 0.4rem 0.75rem; }

  /* Tab buttons */
  .tab-btn { min-height: 48px; padding: 0.7rem 0.9rem; font-size: 0.85rem; }

  /* Order card head: wrap gracefully */
  .order-card-head {
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.9rem 1rem;
    min-height: 60px;
  }
  .order-card-date { font-size: 0.85rem; }
  .order-card-toggle { font-size: 1.1rem; min-width: 28px; text-align: center; }
  .order-status-ctrl { width: 100%; }
  .order-status-ctrl select { width: 100%; min-height: 46px; }

  /* Order card body */
  .order-card-body { padding: 0.75rem; }

  /* Select for status: bigger */
  .item-status-select { min-height: 46px; font-size: 0.95rem; width: 100%; }

  /* Bulk status bar */
  .bulk-status-bar { flex-wrap: wrap; gap: 0.45rem; padding: 0.6rem; }
  .bulk-apply-btn { width: 100%; min-height: 44px; justify-content: center; }

  /* Order form meta fields */
  .order-meta-field label { font-size: 0.9rem; }
  .order-meta-field input, .order-meta-field select { min-height: 46px; font-size: 0.95rem; }

  /* Filter row */
  .filter-row { flex-wrap: wrap; gap: 0.5rem; }
  .filter-row input, .filter-row select { min-height: 46px; font-size: 0.95rem; flex: 1 1 140px; }

  /* Admin section headings and controls */
  .admin-section-head { flex-wrap: wrap; gap: 0.5rem; }
  .admin-section-head .btn-sm { min-height: 44px; }

  /* Catalog item row: single column stacked */
  .catalog-item-row { flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 0.65rem; }
  .catalog-item-fields { width: 100%; }
  .catalog-item-fields input,
  .catalog-item-fields select { min-height: 46px; font-size: 0.95rem; }
  .catalog-item-actions { width: 100%; flex-direction: row; gap: 0.4rem; }
  .catalog-item-actions button { flex: 1; min-height: 44px; justify-content: center; font-size: 0.88rem; }

  /* Image wrap for order rows */
  .item-img-wrap { width: 50px; min-width: 50px; height: 50px; }
  .item-thumb { width: 50px; height: 50px; }
  .item-img-btn { width: 50px; height: 50px; font-size: 1.3rem; }
  .item-img-wrap:has(.item-thumb) .item-img-btn { width: 20px; height: 20px; font-size: 0.65rem; }

  /* Share sheet larger on small phones */
  .share-sheet-panel { padding: 1.4rem 1.2rem 2.8rem; }
  .share-action-btn  { min-width: 96px; padding: 1rem 0.9rem; }
  .share-icon        { width: 26px; height: 26px; }

  /* Img modal close button: larger */
  .img-modal-close { width: 44px; height: 44px; font-size: 1.1rem; }

  /* Admin order table on mobile — same card style as shopper */
  .order-items-table td[data-label="Img"]   { grid-column: 1; }
  .order-items-table td[data-label="Item"]  { grid-column: 2 / -1; }

  /* Remove-row button: bigger */
  .remove-row-btn { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 50%; }

  /* col-img on mobile: inline with item-img-wrap */
  .col-img { grid-column: 1; }
  .col-item { grid-column: 2 / -1; }
}
