/* ============ Admin panel styles ============ */
.admin-body { min-height: 100vh; }
[hidden] { display: none !important; }

/* ---- Login screen ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, rgba(202,161,77,0.08), transparent 60%), var(--bg);
  padding: 20px;
}
.login-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 46px 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo { width: 190px; height: auto; object-fit: contain; margin: 0 auto 22px; }
.login-box h1 { font-size: 22px; color: var(--heading); margin-bottom: 6px; }
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 26px; }
.login-box input {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 13px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  text-align: center;
  font-family: inherit;
}
.login-box input:focus { outline: none; border-color: var(--gold); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 14px; }
.login-hint { color: var(--text-muted); font-size: 11.5px; margin-top: 22px; line-height: 1.7; }
.login-hint code { background: var(--gold-soft); padding: 2px 6px; border-radius: 3px; color: var(--gold-light); }

/* ---- App shell ---- */
.admin-app { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-alt);
  border-inline-end: 1px solid var(--line);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 26px;
  font-family: var(--font-heading);
  font-size: 17px;
  color: var(--gold-light);
  letter-spacing: 1px;
}
.admin-brand img { width: auto; height: 30px; object-fit: contain; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; margin-bottom: auto; }
.admin-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  text-align: start;
  transition: all 0.2s;
}
.admin-nav-btn:hover { background: rgba(24,18,10,0.05); color: var(--text); }
.admin-nav-btn.active { background: var(--gold-soft); color: var(--gold-light); }
.view-site-link { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.logout-btn { color: var(--danger); opacity: 0.85; }
.logout-btn:hover { background: rgba(192, 57, 43, 0.1); color: var(--danger); }

.admin-main {
  flex: 1;
  padding: 40px 44px;
  max-width: 1180px;
  /* A flex item defaults to min-width:auto, so it refuses to shrink below its widest
     child — which let a wide table stretch the whole page sideways. min-width:0 lets it
     shrink so .table-wrap can scroll internally instead. */
  min-width: 0;
}

.admin-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}
.admin-panel-header h2 { font-size: 26px; color: var(--heading); margin-bottom: 6px; }
.admin-panel-sub { color: var(--text-muted); font-size: 14px; }

.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.admin-filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 20px;
  border-radius: 30px;
  font-size: 13px;
}
.pill.active { background: var(--gold-gradient-btn); border-color: var(--gold); color: #ffffff; font-weight: 600; }
.admin-search {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  min-width: 240px;
  font-family: inherit;
}
.admin-search:focus { outline: none; border-color: var(--gold); }

/* ---- Table ---- */
.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  /* A wide table must scroll inside its own box — never push the whole page sideways.
     Tablets in particular don't have room for every column at once. */
  overflow-x: auto;
  overflow-y: hidden;
}
.admin-table { min-width: 620px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: start;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.admin-table td { padding: 14px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-size: 14px; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(24,18,10,0.025); }
.prod-thumb { width: 48px; height: 58px; object-fit: cover; border-radius: 3px; }
.prod-name-cell { display: flex; align-items: center; gap: 14px; }
.prod-name-text { display: flex; flex-direction: column; gap: 2px; }
.prod-name-text strong { color: var(--heading); font-weight: 500; }
.prod-name-text span { color: var(--text-muted); font-size: 12px; }
.cat-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  letter-spacing: 0.5px;
  background: rgba(24,18,10,0.06);
  color: var(--text-muted);
}
.price-cell .price-old { display: block; font-size: 11px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #4caf50; }
.status-dot.inactive { background: #6b6b6b; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Mobile-only accordion header for each product in the inventory table */
.inv-group-head { display: none; }

/* ---- Inventory ---- */
.nav-alert-count {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-inline-start: auto;
}
.inventory-alerts { margin-bottom: 24px; }
.inventory-alerts.is-empty {
  background: rgba(76,175,80,0.08);
  border: 1px solid rgba(76,175,80,0.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  color: #3f8a46;
  font-size: 13.5px;
}
.inventory-alerts.has-alerts {
  background: rgba(192,57,43,0.06);
  border: 1px solid rgba(192,57,43,0.28);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.inventory-alerts-title { font-size: 13px; font-weight: 700; color: #a5392b; margin-bottom: 12px; }
.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.alert-row:last-child { border-bottom: none; }
.alert-row img { width: 34px; height: 42px; object-fit: cover; border-radius: 3px; flex-shrink: 0; }
.alert-row .alert-name { color: var(--text); flex: 1; }
.alert-row .alert-size { color: var(--text-muted); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.status-pill.ok { background: rgba(76,175,80,0.12); color: #3f8a46; }
.status-pill.low { background: rgba(214,158,46,0.16); color: #93701f; }
.status-pill.out { background: rgba(192,57,43,0.13); color: #a5392b; }
.status-pill.sale-status-pending { background: rgba(214,158,46,0.16); color: #93701f; }
.status-pill.sale-status-confirmed { background: rgba(76,175,80,0.12); color: #3f8a46; }
.status-pill.sale-status-cancelled { background: rgba(24,18,10,0.08); color: var(--text-muted); }
.stale-tag {
  display: inline-block;
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: #a5392b;
  background: rgba(192,57,43,0.1);
  padding: 2px 8px;
  border-radius: 10px;
}
.password-warning {
  background: rgba(192,57,43,0.08);
  border: 1px solid rgba(192,57,43,0.35);
  color: #a5392b;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.8;
  font-weight: 600;
}

/* Customer details inside the orders log */
.cust-block { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.cust-name { font-size: 12.5px; color: var(--heading); font-weight: 600; }
.cust-wa {
  font-size: 12px;
  color: var(--gold-light);
  text-decoration: none;
  direction: ltr;
  text-align: start;
  font-weight: 600;
}
.cust-wa:hover { text-decoration: underline; }
.cust-meta { font-size: 11.5px; color: var(--text-muted); }
.cust-notes {
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}
.sales-pending-banner {
  background: rgba(214,158,46,0.12);
  border: 1px solid rgba(214,158,46,0.32);
  color: #7a5a1f;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 600;
}

.stock-inputs { display: flex; flex-wrap: wrap; gap: 12px; }
.stock-row { display: flex; flex-direction: column; gap: 5px; }
.stock-row-size { font-size: 12px; color: var(--text-muted); }
.stock-row input {
  width: 72px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
}
.stock-row input:focus { outline: none; border-color: var(--gold); }
.stock-row input:disabled { opacity: 0.5; cursor: not-allowed; }

.inventory-table .stock-cell input {
  width: 76px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
}
.inventory-table .stock-cell input:focus { outline: none; border-color: var(--gold); }
.inventory-table .prod-name-cell strong { display: block; }

.source-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.source-badge.site { background: var(--gold-soft); color: var(--gold-light); }
.source-badge.store { background: rgba(78,110,214,0.13); color: #4e5fc4; }
.icon-action {
  background: rgba(24,18,10,0.05);
  border: none;
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-action:hover { background: var(--gold-soft); color: var(--gold-light); }
.icon-action.danger:hover { background: rgba(192,57,43,0.13); color: var(--danger); }

/* ---- Settings form ---- */
.settings-form { max-width: 900px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 26px; }
.settings-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-card.wide { grid-column: 1 / -1; }
.settings-card h3 { font-size: 14px; color: var(--gold-light); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.settings-card label { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; color: var(--text-muted); }
.settings-card input, .settings-card textarea, .settings-card select {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.settings-card input:focus, .settings-card textarea:focus, .settings-card select:focus { outline: none; border-color: var(--gold); }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 10px !important; }
.checkbox-label input { width: auto; }
.field-hint { color: var(--text-muted); font-size: 12px; margin-top: -6px; }
.settings-card input[type="file"] {
  padding: 9px;
  cursor: pointer;
}
.settings-card input[type="file"]::file-selector-button {
  background: var(--gold-soft);
  color: var(--gold-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: inherit;
  font-size: 12px;
  margin-inline-end: 10px;
  cursor: pointer;
}
.upload-status { color: var(--gold-light); font-size: 12.5px; }
.image-preview-row { display: flex; flex-wrap: wrap; gap: 10px; }
.image-preview-item {
  position: relative;
  width: 64px;
  height: 78px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
.image-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.image-preview-item button {
  position: absolute;
  top: 2px; inset-inline-end: 2px;
  width: 18px; height: 18px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.image-preview-item button:hover { background: var(--danger); }
.size-checkboxes { display: flex; flex-wrap: wrap; gap: 12px; }
.size-checkboxes label { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.size-checkboxes input { width: auto; }

/* ---- Product form modal ---- */
.admin-form-modal {
  position: relative;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 860px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 40px;
}
.admin-form-modal h3 { font-size: 21px; color: var(--heading); margin-bottom: 24px; }
.admin-form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 6px; }

/* ---- Confirm modal ---- */
.confirm-modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.confirm-modal h3 { font-size: 18px; color: var(--heading); margin-bottom: 10px; }
.confirm-modal p { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }

/* ---- Collections manager ---- */
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.collections-modal { max-width: 880px; padding: 34px; }
.collections-modal h3 { margin-bottom: 8px; }

.collection-add {
  display: flex;
  gap: 10px;
  padding-bottom: 18px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.collection-add input {
  flex: 1 1 160px;
  min-width: 0;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}
.collection-add input:focus { outline: none; border-color: var(--gold); }
.collection-add .btn { flex: 0 0 auto; }

.collection-add select {
  flex: 0 0 auto;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}
.collection-add select:focus { outline: none; border-color: var(--gold); }

.collection-list { display: flex; flex-direction: column; }
.collection-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.collection-row:last-child { border-bottom: none; }

/* Cover image for the home-page "shop by type" card */
.col-thumb {
  flex: 0 0 auto;
  position: relative;
  width: 46px;
  height: 58px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  cursor: pointer;
  display: block;
}
.col-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.col-thumb-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-light);
  font-size: 20px;
  opacity: 0.6;
}
/* The label only appears on hover so the row stays calm at rest */
.col-thumb-edit {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  background: rgba(24, 18, 10, 0.78);
  color: #fff;
  font-size: 9.5px;
  text-align: center;
  padding: 3px 2px;
  opacity: 0;
  transition: opacity 0.18s;
}
.col-thumb:hover .col-thumb-edit,
.col-thumb:focus-within .col-thumb-edit { opacity: 1; }
.col-thumb-clear {
  flex: 0 0 auto;
  align-self: flex-start;
  width: 20px;
  height: 20px;
  margin-inline-start: -12px;
  margin-top: -4px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 1;
}
.col-thumb-clear:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* A child row is indented and marked with a rule, so the hierarchy is readable at a
   glance without needing a real tree widget */
.collection-row.is-child .col-names { padding-inline-start: 22px; position: relative; }
.collection-row.is-child .col-names::before {
  content: '';
  position: absolute;
  inset-inline-start: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--gold);
  opacity: 0.4;
}

.col-names { display: flex; gap: 8px; flex: 1 1 auto; min-width: 0; }
.col-names select.col-parent {
  flex: 0 1 132px;
  min-width: 88px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text-muted);
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: inherit;
}
.col-names select.col-parent:focus { outline: none; border-color: var(--gold); }
.col-names select.col-parent:disabled { opacity: 0.45; cursor: not-allowed; }

.col-names input {
  flex: 1 1 120px;
  min-width: 0;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}
.col-names input:focus { outline: none; border-color: var(--gold); }

.col-count {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.col-active {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.col-active input { width: auto; margin: 0; cursor: pointer; }

.col-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.col-actions .btn { padding: 8px 14px; font-size: 12px; }

.collections-modal .empty-state { text-align: center; padding: 26px 0; }

/* ---------- Star rating picker (used both in the "add review" form and each row) ---------- */
.star-picker { display: flex; gap: 3px; flex: 0 0 auto; }
.star-pick {
  background: none;
  border: none;
  padding: 2px;
  font-size: 20px;
  line-height: 1;
  color: var(--line);
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
}
.star-pick:hover { transform: scale(1.12); }
.star-pick.is-filled { color: var(--gold); }

/* ---------- Reviews (testimonials) list ---------- */
.testimonial-add { align-items: flex-start; }
.testimonial-add .star-picker { padding: 11px 4px; }
.testimonial-admin-list { display: flex; flex-direction: column; }
.testimonial-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.testimonial-row:last-child { border-bottom: none; }
.rev-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  margin-top: 2px;
}
.rev-fields { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rev-name,
.rev-comment {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.rev-name:focus,
.rev-comment:focus { outline: none; border-color: var(--gold); }
.rev-name { max-width: 240px; font-weight: 600; }

@media (max-width: 700px) {
  .testimonial-row { flex-wrap: wrap; }
  .rev-fields { flex: 1 1 100%; order: 2; }
  .col-active { order: 3; }
  .col-actions { order: 4; width: 100%; justify-content: flex-end; }
  .rev-name { max-width: none; }
}

/* ---- Product colours (repeatable rows) ---- */
.color-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type="color"] {
  flex: 0 0 44px;
  width: 44px;
  height: 40px;
  padding: 3px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.color-row input[type="text"] {
  flex: 1 1 90px;
  min-width: 0;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}
.color-row input[type="text"]:focus { outline: none; border-color: var(--gold); }
.color-row .cr-del { flex: 0 0 auto; }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }

/* ============================================================
   TABLET — 900px and below
   The 250px sidebar costs too much width, so it becomes icons only.
   ============================================================ */
@media (max-width: 900px) and (min-width: 721px) {
  .admin-sidebar { width: 76px; padding: 20px 10px; }
  .admin-brand span, .admin-nav-btn span:not(.nav-alert-count) { display: none; }
  .admin-brand, .admin-nav-btn { justify-content: center; }
  .admin-main { padding: 28px 20px; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   PHONE — 720px and below
   A vertical rail wastes 20% of a phone screen and sits far from the
   thumb, so the sidebar becomes a fixed BOTTOM TAB BAR instead —
   the pattern people already know from every mobile app.
   ============================================================ */
@media (max-width: 720px) {
  .admin-app { flex-direction: column; }

  .admin-sidebar {
    position: fixed;
    inset: auto 0 0 0;          /* pinned to the bottom edge */
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 0;
    border-inline-end: none;
    border-top: 1px solid var(--line);
    background: var(--surface, var(--card-bg));
    box-shadow: 0 -4px 20px rgba(24,18,10,0.08);
    z-index: 300;
    /* keeps the bar clear of the iPhone home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .admin-brand { display: none; }            /* the page title already says where you are */
  .admin-nav {
    flex-direction: row;
    flex: 1;
    margin-bottom: 0;
    gap: 0;
  }
  .admin-nav-btn {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    padding: 9px 2px 7px;
    border-radius: 0;
    font-size: 10.5px;
    letter-spacing: 0.2px;
    text-align: center;
    position: relative;
    min-height: 54px;
  }
  .admin-nav-btn.active {
    background: transparent;
    color: var(--gold);
    font-weight: 600;
  }
  /* active tab marked by a bar on top, like native tab bars */
  .admin-nav-btn.active::before {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--gold);
    border-radius: 0 0 2px 2px;
  }
  .view-site-link, .logout-btn {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    margin-top: 0;
    border-top: none;
    padding: 9px 2px 7px;
    font-size: 10.5px;
    min-height: 54px;
  }
  .nav-alert-count {
    position: absolute;
    top: 4px;
    inset-inline-start: 50%;
    margin-inline-start: 4px;
    margin-inline-end: 0;
    font-size: 9.5px;
    min-width: 15px;
    height: 15px;
  }

  .admin-main {
    padding: 20px 14px;
    max-width: 100%;
    /* room for the fixed bar so the last row is never trapped underneath */
    padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
  .admin-panel-header { margin-bottom: 20px; gap: 12px; }
  .admin-panel-header h2 { font-size: 21px; }
  .admin-panel-sub { font-size: 13px; }
  .admin-panel-header .btn { width: 100%; }

  .admin-toolbar { gap: 10px; }
  .admin-search { min-width: 0; width: 100%; }
  .toolbar-right { width: 100%; flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar-right .btn { width: 100%; }

  /* Collections manager: a 4-column row cannot survive a phone, so it stacks */
  .collections-modal { padding: 26px 18px; }
  /* flex-basis becomes HEIGHT once the axis is vertical, so 160px would make
     each input 160px tall — reset the basis when the form stacks */
  .collection-add { flex-direction: column; }
  .collection-add input,
  .collection-add select { flex: 0 0 auto; width: 100%; }
  .collection-add .btn { width: 100%; }
  /* Colour rows on a phone: swatch + delete share the top line, names stack full-width
     beneath — cleaner than three controls crammed on one line */
  .color-row { flex-wrap: wrap; }
  .color-row input[type="color"] { order: 1; }
  .color-row .cr-del { order: 2; margin-inline-start: auto; }
  .color-row input[type="text"] { order: 3; flex: 1 1 100%; }
  .collection-row {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      'thumb names'
      'count actions'
      'active actions';
    gap: 10px;
    align-items: center;
    padding: 16px 0;
  }
  .col-thumb { grid-area: thumb; align-self: start; }
  /* Two items in one grid area stack — no absolute positioning needed for the badge */
  .col-thumb-clear { grid-area: thumb; justify-self: end; align-self: start; margin: -6px -6px 0 0; }
  .col-names { grid-area: names; flex-direction: column; gap: 8px; }
  .col-names input,
  .col-names select.col-parent { flex: 0 0 auto; width: 100%; }
  .collection-row.is-child .col-names { padding-inline-start: 16px; }
  .col-count { grid-area: count; }
  .col-active { grid-area: active; }
  .col-actions { grid-area: actions; justify-content: flex-end; }
  .col-actions .btn { padding: 11px 18px; }
  .settings-grid { grid-template-columns: 1fr; gap: 12px; }
  .settings-card { padding: 16px; }
  .settings-form .btn { width: 100%; }

  /* toast must clear the bottom bar */
  .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important; }

  /* ---------- Tables become labelled cards ----------
     Each row turns into a self-contained card. Every value carries its own
     label via data-label, because a bare column of numbers with no headers
     is unreadable once the <thead> is gone. */
  .table-wrap { border: none; background: transparent; overflow: visible; }
  .admin-table { min-width: 0; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }

  .admin-table tr {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    position: relative;
  }
  .admin-table tr:hover td { background: transparent; }
  .admin-table td {
    padding: 5px 0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 26px;
  }
  /* the label sits on the left, the value on the right — scannable in one pass */
  .admin-table td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
  }

  /* product identity: thumbnail and name form the card's header */
  .admin-table td.cell-thumb {
    position: absolute;
    top: 14px;
    inset-inline-start: 16px;
    width: 44px;
    padding: 0;
    min-height: 0;
  }
  .admin-table td.cell-thumb .prod-thumb { width: 44px; height: 54px; }
  .admin-table td.cell-name {
    padding: 0 0 12px;
    width: auto;                 /* 100% + a 56px margin overflowed the viewport */
    margin-inline-start: 56px;
    margin-bottom: 8px;
    min-height: 54px;
    border-bottom: 1px solid var(--line-soft);
    align-items: flex-start;
  }
  .admin-table td.cell-name .prod-name-text strong { font-size: 14.5px; line-height: 1.4; }

  .price-cell { gap: 8px; }
  .price-cell .price-old { display: inline; }
  .row-actions { justify-content: flex-end; margin-top: 6px; gap: 10px; }
  .admin-table td .row-actions .btn { flex: 1; }

  /* ---------- Inventory: an accordion, not a 13,000px scroll ----------
     12 products x 5 sizes is 60 rows. As cards that is an unusable wall of
     scrolling, so each product collapses to one tappable line and reveals its
     sizes on demand. */
  .inventory-table td.cell-thumb, .inventory-table td.cell-name { display: none; }

  .admin-table tr.inv-group-head {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .admin-table tr.inv-group-head td {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    min-height: 0;
  }
  .admin-table tr.inv-group-head .prod-thumb { width: 38px; height: 47px; flex-shrink: 0; }
  .inv-head-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
  .inv-head-text strong {
    font-size: 13.5px; font-weight: 600; color: var(--heading);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .inv-head-meta { font-size: 11.5px; color: var(--text-muted); }
  .inv-chevron { flex-shrink: 0; color: var(--text-muted); transition: transform 0.2s ease; }
  .admin-table tr.inv-group-head.open { border-color: var(--gold-line, var(--border)); }
  .admin-table tr.inv-group-head.open .inv-chevron { transform: rotate(180deg); }

  /* size rows stay hidden until their product header is tapped.
     Specificity must beat ".admin-table tr { display: block }" above. */
  .admin-table tr.inv-size-row { display: none; }
  .admin-table tr.inv-size-row.is-open { display: block; }
  .admin-table tr.inv-size-row {
    width: auto;                 /* margin + 100% would overflow the viewport */
    margin: -4px 0 8px 14px;
    border-inline-start: 2px solid var(--gold-soft);
  }
  .inventory-table .stock-cell input { width: 96px; text-align: center; }
  .inventory-table td.cell-actions { padding-top: 9px; }
  .inventory-table td.cell-actions .row-actions { width: 100%; margin-top: 0; }
  .inventory-table td.cell-actions .btn { flex: 1; padding: 9px 8px !important; font-size: 12px !important; }

  /* alerts list */
  .inventory-alerts.has-alerts, .inventory-alerts.is-empty { padding: 14px 16px; }
  .alert-row { font-size: 12.5px; gap: 9px; }
  .alert-row img { width: 30px; height: 37px; }

  /* customer block in the sales log */
  .cust-notes { max-width: 100%; white-space: normal; }
  .cust-block { align-items: flex-end; }

  /* Touch targets: 32px is too small for a fingertip — 42px clears the usual
     44px guidance once the surrounding padding is counted. */
  .icon-action { width: 42px; height: 42px; }
  .row-actions { gap: 12px; }
  .pill { padding: 9px 18px; }
  .admin-table td.stock-cell input,
  .inventory-table .stock-cell input { padding: 10px 12px; font-size: 15px; }

  /* tighten the expanded size cards a little */
  .admin-table tr.inv-size-row { padding: 11px 14px; }
  .admin-table tr.inv-size-row td { padding: 4px 0; min-height: 24px; }

  /* modals need breathing room on a small screen */
  .admin-form-modal { padding: 22px 16px; max-height: 92vh; }
  .admin-form-actions { flex-direction: column-reverse; gap: 10px; }
  .admin-form-actions .btn { width: 100%; }
  .confirm-modal { padding: 24px 18px; }
}

@media (max-width: 400px) {
  .admin-nav-btn, .view-site-link, .logout-btn { font-size: 9.5px; }
  .admin-main { padding-left: 11px; padding-right: 11px; }
  .admin-table tr { padding: 12px 13px; }
}
