:root {
  --ink: #0c1220;
  --ink-2: #1a2438;
  --surface: #111a2b;
  --surface-2: #182338;
  --line: rgba(255, 214, 170, 0.12);
  --line-strong: rgba(255, 214, 170, 0.22);
  --text: #f6f0e8;
  --muted: #9aa8bc;
  --dim: #6b7a90;
  --ember: #ff7a2f;
  --ember-soft: rgba(255, 122, 47, 0.16);
  --mint: #3dcf9a;
  --mint-soft: rgba(61, 207, 154, 0.14);
  --rose: #ff5d7a;
  --rose-soft: rgba(255, 93, 122, 0.14);
  --sky: #4ec4e8;
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 14px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --app-pad-x: clamp(12px, 3vw, 28px);
  --app-pad-y: clamp(12px, 2.2vw, 24px);
  --touch: 44px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html, body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 122, 47, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(78, 196, 232, 0.12), transparent 50%),
    linear-gradient(165deg, #070b14 0%, #0d1524 45%, #101a2c 100%);
  background-attachment: fixed;
}

body {
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }

/* Prevent iOS zoom on focus */
input, select, textarea {
  font-size: 16px;
}

.app {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--app-pad-y) var(--app-pad-x) calc(48px + env(safe-area-inset-bottom, 0px));
  padding-left: max(var(--app-pad-x), env(safe-area-inset-left, 0px));
  padding-right: max(var(--app-pad-x), env(safe-area-inset-right, 0px));
}

/* ========== Top nav ========== */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: clamp(16px, 3vw, 28px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(12, 18, 32, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: max(8px, env(safe-area-inset-top, 0px));
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--font-display);
  background: linear-gradient(135deg, var(--ember), #ff9a4d);
  color: #1a0d05;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 10px 30px var(--ember-soft);
}

.brand-text {
  min-width: 0;
}

.brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-text span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.nav-toggle {
  display: none;
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.04);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  margin-left: auto;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-drawer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.nav-links a,
.nav-chip {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  transition: 0.2s ease;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-chip:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-links a.active {
  color: #1a0d05;
  background: linear-gradient(135deg, #ff8a3d, #ffc27a);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
  max-width: 220px;
}

.nav-user > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  transition: 0.18s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--ember), #ff9a4d);
  color: #1a0d05;
  box-shadow: 0 10px 28px var(--ember-soft);
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }

.btn-ghost {
  border-color: var(--line-strong);
  background: rgba(255,255,255,0.03);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255,255,255,0.07); }

.btn-mint {
  background: var(--mint-soft);
  color: var(--mint);
  border-color: rgba(61, 207, 154, 0.35);
}

.btn-danger {
  background: var(--rose-soft);
  color: var(--rose);
  border-color: rgba(255, 93, 122, 0.3);
}

.btn-sm {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.78rem;
  border-radius: 9px;
}

.btn-block { width: 100%; }

/* Page header */
.page-hero {
  margin-bottom: clamp(14px, 2.5vw, 22px);
}

.page-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3.5vw, 2.15rem);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  line-height: 1.15;
  word-break: break-word;
}

.page-hero p {
  color: var(--muted);
  max-width: 56ch;
  font-size: clamp(0.88rem, 2vw, 1rem);
  line-height: 1.5;
}

/* Cards / panels */
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 35, 56, 0.9), rgba(17, 26, 43, 0.92));
  border-radius: var(--radius);
  padding: clamp(14px, 2.5vw, 20px);
  box-shadow: var(--shadow);
}

.panel + .panel { margin-top: 14px; }

.panel-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-title .actions {
  width: auto;
}

/* Platform pills */
.platform-pills,
.store-plat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.pill {
  padding: 9px 14px;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.84rem;
  display: inline-flex;
  align-items: center;
}
.pill.active {
  color: #1a0d05;
  border-color: transparent;
  background: linear-gradient(135deg, #ff8a3d, #ffc27a);
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.18);
  min-width: 0;
}
.stat .label {
  font-size: 0.7rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.3;
}
.stat .value {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  margin-top: 4px;
  word-break: break-word;
}
.stat .value.mint { color: var(--mint); }
.stat .value.rose { color: var(--rose); }
.stat .value.sky { color: var(--sky); }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

/* Quick commerce: url + city + pin + submit */
.form-grid.form-grid-qc {
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.85fr) minmax(0, 0.85fr) auto;
}

/* Ecom: url + pin + submit */
.form-grid.form-grid-ecom {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) auto;
}

/* Admin add store */
.form-grid.form-grid-store {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  min-width: 0;
}

input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 12px 13px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(6, 10, 18, 0.65);
  color: var(--text);
  outline: none;
  min-height: 46px;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(255, 122, 47, 0.55);
  box-shadow: 0 0 0 3px var(--ember-soft);
}

.form-grid > .btn {
  align-self: end;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar > input[type="search"],
.toolbar > input[type="text"] {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 320px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tabs button {
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.tabs button.active {
  background: var(--ember-soft);
  color: #ffc39a;
  border-color: rgba(255, 122, 47, 0.35);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--line);
  max-width: 100%;
}

/* Scroll hint for narrow screens */
.table-wrap {
  background:
    linear-gradient(90deg, rgba(17,26,43,1) 30%, rgba(17,26,43,0)),
    linear-gradient(270deg, rgba(17,26,43,1) 30%, rgba(17,26,43,0)) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.35), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.35), transparent) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 720px;
}

table.table-compact {
  min-width: 560px;
}

th, td {
  padding: 11px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  background: rgba(0,0,0,0.28);
  position: sticky;
  top: 0;
  z-index: 1;
}
tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-in { background: var(--mint-soft); color: var(--mint); }
.badge-out { background: var(--rose-soft); color: var(--rose); }
.badge-on { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; }
.badge-paused { background: rgba(250, 204, 21, 0.12); color: #fde68a; }

/* Product track cards — one enquiry/product per box */
.track-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.track-empty {
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
}
.track-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel, rgba(255,255,255,0.03));
  overflow: hidden;
}
.track-card.is-paused {
  opacity: 0.72;
  border-style: dashed;
}
.track-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,0.12);
}
.track-card-title h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
  max-width: 52ch;
}
.track-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
}
.track-card-meta .money {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.track-card-meta .mute,
.mute {
  color: var(--dim);
}
.track-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.track-card-body {
  padding: 0;
  overflow-x: auto;
}
.track-loc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.track-loc-table th,
.track-loc-table td {
  padding: 8px 12px;
  text-align: left;
  border-top: 1px solid var(--line);
}
.track-loc-table th {
  color: var(--dim);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.track-loc-table tr.row-paused {
  opacity: 0.55;
}
.loc-actions {
  white-space: nowrap;
}

@media (max-width: 720px) {
  .track-card-head {
    flex-direction: column;
  }
  .track-loc-table th:nth-child(2),
  .track-loc-table td:nth-child(2),
  .track-loc-table th:nth-child(5),
  .track-loc-table td:nth-child(5) {
    display: none;
  }
}
.mono { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); word-break: break-all; }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}

/* Mobile card rows (optional class on table body parent) */
.cards-mobile {
  display: none;
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  z-index: 80;
  max-width: 400px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #121b2d;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(140%);
  opacity: 0;
  transition: 0.25s ease;
  font-size: 0.9rem;
}
.toast.show { transform: none; opacity: 1; }
.toast.ok { border-color: rgba(61, 207, 154, 0.4); }
.toast.err { border-color: rgba(255, 93, 122, 0.4); }

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 14px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row > div { min-width: 0; flex: 1; }

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  background: #24324a;
  border-radius: 999px;
  transition: 0.2s;
}
.switch span::after {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s;
}
.switch input:checked + span { background: var(--ember); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Admin */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.admin-tabs button.active {
  background: linear-gradient(135deg, #ff8a3d, #ffc27a);
  color: #1a0d05;
  border-color: transparent;
}
.admin-section { display: none; }
.admin-section.active { display: block; }
.sel-count { color: var(--dim); font-size: 0.85rem; }

/* Login */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.auth-visual {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 48px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background:
    linear-gradient(160deg, rgba(7,11,20,0.15), rgba(7,11,20,0.82)),
    radial-gradient(circle at 30% 20%, rgba(255,122,47,0.35), transparent 42%),
    radial-gradient(circle at 80% 60%, rgba(78,196,232,0.25), transparent 40%),
    #0a101c;
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.5), transparent 90%);
  pointer-events: none;
}

.auth-visual h1 {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.2vw, 3.4rem);
  letter-spacing: -0.04em;
  max-width: 14ch;
  line-height: 1.05;
  margin: 12px 0 14px;
}

.auth-visual p {
  position: relative;
  max-width: 38ch;
  color: #d7cfc4;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
}

.auth-visual .eyebrow {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffc39a;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 3vw, 28px);
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(20px, 3vw, 28px);
  background: rgba(14, 20, 34, 0.88);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  margin-bottom: 6px;
}
.auth-card .sub {
  color: var(--muted);
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.auth-card .stack { display: grid; gap: 12px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-toggle {
  margin-top: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
.auth-toggle button {
  color: #ffb07a;
  font-weight: 700;
  margin-left: 4px;
}

.auth-error {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--rose-soft);
  color: #ffb3c0;
  font-size: 0.88rem;
}
.auth-error.show { display: block; }

.users-table td { font-size: 0.88rem; }

/* ========== Laptop / desktop (≥1024) ========== */
@media (min-width: 1024px) {
  .topnav {
    padding: 12px 18px;
  }
  .nav-links a {
    padding: 9px 14px;
  }
  .brand-text span {
    max-width: 220px;
  }
  .nav-user > span {
    max-width: 180px;
  }
}

/* ========== Tablet (641–1023) ========== */
@media (max-width: 1023px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .form-grid.form-grid-qc,
  .form-grid.form-grid-ecom {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .form-grid > .btn,
  .form-grid.form-grid-qc > .btn,
  .form-grid.form-grid-ecom > .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .form-grid.form-grid-qc > label.field:first-child,
  .form-grid.form-grid-ecom > label.field:first-child,
  .form-grid > label.field:first-child {
    grid-column: 1 / -1;
  }

  .form-grid.form-grid-store {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid.form-grid-store > .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .topnav {
    border-radius: 18px;
    flex-wrap: wrap;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-drawer {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 10px 4px 6px;
    border-top: 1px solid var(--line);
    margin-top: 4px;
  }

  .topnav.is-open .nav-drawer {
    display: flex;
  }

  .nav-links {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 4px;
  }

  .nav-links a {
    text-align: center;
    padding: 12px 14px;
    border-radius: 12px;
    min-height: var(--touch);
  }

  .nav-user {
    max-width: none;
    width: 100%;
    justify-content: space-between;
    padding: 4px 2px 0;
  }

  .nav-user > span {
    max-width: none;
    flex: 1;
  }

  .brand-text span {
    max-width: 42vw;
  }

  table {
    min-width: 680px;
  }
}

/* ========== Large tablet / small laptop auth ========== */
@media (max-width: 960px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    min-height: min(38vh, 320px);
    justify-content: flex-end;
  }
}

/* ========== Mobile (≤640) ========== */
@media (max-width: 640px) {
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat {
    padding: 10px 12px;
  }

  .stat .value {
    font-size: 1.1rem;
  }

  .form-grid,
  .form-grid.form-grid-qc,
  .form-grid.form-grid-ecom,
  .form-grid.form-grid-store {
    grid-template-columns: 1fr;
  }

  .form-grid > label.field:first-child,
  .form-grid.form-grid-qc > label.field:first-child,
  .form-grid.form-grid-ecom > label.field:first-child {
    grid-column: auto;
  }

  .form-grid > .btn,
  .form-grid.form-grid-qc > .btn,
  .form-grid.form-grid-ecom > .btn,
  .form-grid.form-grid-store > .btn {
    grid-column: auto;
    width: 100%;
    min-height: var(--touch);
  }

  .platform-pills .pill,
  .store-plat-pills .pill {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
    font-size: 0.8rem;
    padding: 10px 12px;
  }

  .panel-title {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-title .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .panel-title .actions .btn {
    width: 100%;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar > input[type="search"],
  .toolbar > input[type="text"] {
    max-width: none;
    width: 100%;
  }

  .toolbar .btn,
  .toolbar label.btn {
    width: 100%;
    justify-content: center;
  }

  .tabs {
    width: 100%;
  }

  .tabs button {
    flex: 1 1 auto;
    text-align: center;
  }

  .admin-tabs button {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  table {
    min-width: 620px;
    font-size: 0.8rem;
  }

  th, td {
    padding: 10px 8px;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .actions .btn {
    width: 100%;
    justify-content: center;
  }

  .actions a.btn {
    text-align: center;
  }

  #settingsForm .actions {
    flex-direction: column;
  }

  #settingsForm .actions .btn {
    width: 100%;
  }

  .auth-visual {
    min-height: auto;
    padding: 28px 20px 24px;
  }

  .auth-visual h1 {
    max-width: none;
    font-size: clamp(1.7rem, 8vw, 2.2rem);
  }

  .auth-panel {
    padding: 8px 16px 32px;
  }

  .brand-text span {
    display: none;
  }

  .toast {
    left: 10px;
    right: 10px;
    max-width: none;
  }

  /* Mobile card list for tracker rows */
  .table-wrap.table-cards {
    background: none;
    border: none;
    overflow: visible;
  }

  .table-wrap.table-cards table,
  .table-wrap.table-cards thead {
    display: none;
  }

  .table-wrap.table-cards tbody {
    display: grid;
    gap: 10px;
  }

  .table-wrap.table-cards tr {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0,0,0,0.18);
    grid-template-columns: 1fr auto;
  }

  .table-wrap.table-cards td {
    border: 0;
    padding: 0;
    display: block;
    min-width: 0;
  }

  .table-wrap.table-cards td:nth-child(1) {
    grid-column: 1 / -1;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.35;
  }

  .table-wrap.table-cards td:nth-child(4) {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }

  .table-wrap.table-cards td:nth-child(2),
  .table-wrap.table-cards td:nth-child(3),
  .table-wrap.table-cards td:nth-child(5),
  .table-wrap.table-cards td:nth-child(6) {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 0.82rem;
  }

  .table-wrap.table-cards td:nth-child(2)::before { content: "Pin · "; color: var(--dim); }
  .table-wrap.table-cards td:nth-child(3)::before { content: "Store · "; color: var(--dim); }
  .table-wrap.table-cards td:nth-child(5)::before { content: "Price · "; color: var(--dim); }
  .table-wrap.table-cards td:nth-child(6)::before { content: "Area · "; color: var(--dim); }

  .table-wrap.table-cards td:nth-child(7) {
    grid-column: 1 / -1;
    margin-top: 4px;
  }

  .table-wrap.table-cards .empty {
    grid-column: 1 / -1;
    border: 1px dashed var(--line);
    border-radius: 12px;
  }
}

/* ========== Very small phones ========== */
@media (max-width: 380px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .admin-tabs button {
    flex: 1 1 100%;
  }

  .panel-title .actions {
    grid-template-columns: 1fr;
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
