/*
 * Airix Transit — single stylesheet. Reskin by editing the variables below.
 * Light theme by default; dark theme follows prefers-color-scheme: dark.
 */
:root {
  color-scheme: light dark;
  /* brand */
  --brand-blue: #4f7fcc;
  --brand-teal: #56c5c9;
  --brand-text: #3f6fbf;
  /* surfaces */
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #eef2f8;
  --border: #d6deea;
  --text: #16202e;
  --muted: #5d6b82;
  --accent: #3f6fbf;
  --accent-contrast: #ffffff;
  --focus: #56c5c9;
  --row-hover: #f1f5fb;
  --late-bg: rgba(220, 38, 38, 0.06);
  --late-bg-hover: rgba(220, 38, 38, 0.11);
  /* status colours */
  --green: #15803d;
  --red: #dc2626;
  --amber: #b45309;
  --pill-ok-bg: rgba(22, 163, 74, 0.14);   --pill-ok-fg: #166534;
  --pill-transit-bg: rgba(59, 130, 246, 0.14); --pill-transit-fg: #1d4ed8;
  --pill-neutral-bg: rgba(100, 116, 139, 0.15); --pill-neutral-fg: #334155;
  --pill-bad-bg: rgba(220, 38, 38, 0.13);  --pill-bad-fg: #b91c1c;
  --reason-fg: #b91c1c;
  /* banners */
  --error-bg: rgba(220, 38, 38, 0.08);  --error-border: rgba(220, 38, 38, 0.35); --error-fg: #991b1b;
  --ok-bg: rgba(22, 163, 74, 0.1);      --ok-border: rgba(22, 163, 74, 0.35);   --ok-fg: #166534;
  --warn-bg: rgba(245, 158, 11, 0.12);  --warn-border: rgba(245, 158, 11, 0.45); --warn-fg: #92400e;
  --info-bg: rgba(79, 127, 204, 0.1);   --info-border: rgba(79, 127, 204, 0.35); --info-fg: #1e3a8a;
  /* type + shape */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --radius-sm: 8px;
  --tap: 44px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand-blue: #6b9ae6;
    --brand-teal: #5fd0d4;
    --brand-text: #9dbcf0;
    --bg: #0f1419;
    --panel: #1a2332;
    --panel-2: #243044;
    --border: #2d3a4f;
    --text: #e8eef7;
    --muted: #8b9bb4;
    --accent: #4f86e0;
    --accent-contrast: #ffffff;
    --row-hover: #1e2a3d;
    --late-bg: rgba(239, 68, 68, 0.08);
    --late-bg-hover: rgba(239, 68, 68, 0.14);
    --green: #22c55e;
    --red: #ef4444;
    --amber: #f59e0b;
    --pill-ok-bg: rgba(34, 197, 94, 0.2);   --pill-ok-fg: #86efac;
    --pill-transit-bg: rgba(59, 130, 246, 0.2); --pill-transit-fg: #93c5fd;
    --pill-neutral-bg: rgba(148, 163, 184, 0.2); --pill-neutral-fg: #cbd5e1;
    --pill-bad-bg: rgba(239, 68, 68, 0.22); --pill-bad-fg: #fca5a5;
    --reason-fg: #fca5a5;
    --error-bg: rgba(239, 68, 68, 0.15);  --error-border: rgba(239, 68, 68, 0.4); --error-fg: #fecaca;
    --ok-bg: rgba(34, 197, 94, 0.15);     --ok-border: rgba(34, 197, 94, 0.4);   --ok-fg: #bbf7d0;
    --warn-bg: rgba(245, 158, 11, 0.15);  --warn-border: rgba(245, 158, 11, 0.45); --warn-fg: #fde68a;
    --info-bg: rgba(79, 134, 224, 0.15);  --info-border: rgba(79, 134, 224, 0.45); --info-fg: #bfdbfe;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.small { font-size: 11px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- brand ---------- */
.brand-row { display: inline-flex; align-items: center; gap: 10px; color: var(--brand-text); text-decoration: none; }
.brand-row:hover { text-decoration: none; }
.brand-logo { display: block; width: auto; color: var(--brand-text); }
.brand-product {
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: 0.02em;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

/* ---------- buttons ---------- */
.btn-primary, .btn-secondary {
  width: 100%;
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); border: none; }
.btn-primary:active { opacity: 0.9; }
.btn-secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); margin-top: 10px; }
.btn-link, .btn-header, .lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.btn-link { background: none; border: none; color: var(--accent); }
.btn-header, .lang-toggle { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.btn-header:hover, .lang-toggle:hover { border-color: var(--muted); text-decoration: none; }
.inline-form { display: inline; margin: 0; }

/* ---------- banners ---------- */
.error-banner, .ok-banner, .warn-banner, .info-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid;
}
.error-banner { background: var(--error-bg); border-color: var(--error-border); color: var(--error-fg); }
.ok-banner { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-fg); }
.warn-banner { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-fg); }
.info-banner { background: var(--info-bg); border-color: var(--info-border); color: var(--info-fg); }
[hidden] { display: none !important; }

/* ---------- auth pages (login / register / settings) ---------- */
.auth-body { min-height: 100vh; min-height: 100dvh; }
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 20px 20px;
  box-shadow: var(--shadow);
}
.auth-card.wide { max-width: 460px; }
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.auth-top-actions { display: flex; gap: 6px; align-items: center; }
.auth-nav { margin: -8px 0 12px; font-size: 14px; }
.auth-nav a { display: inline-flex; align-items: center; min-height: var(--tap); }
.auth-card h1 { margin: 0 0 4px; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.auth-card label { display: block; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card input[type="text"], .auth-card input[type="password"] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px;
  font: inherit;
  font-size: 16px; /* avoid iOS zoom */
  min-height: 48px;
}
.auth-card input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--info-bg); }
.auth-card .foot { margin-top: 18px; text-align: center; font-size: 15px; }
.auth-card .foot a { display: inline-flex; align-items: center; min-height: var(--tap); }
.auth-card .masked { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 6px; }
.auth-card .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.auth-card .note { color: var(--muted); font-size: 12px; margin: 14px 0 0; }

/* ---------- dashboard header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.top-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.whoami { color: var(--muted); font-size: 13px; margin-right: 4px; }

.app { max-width: 1440px; margin: 0 auto; padding: 16px 20px 40px; }
.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.dash-head h1 { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.dash-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.updated { color: var(--muted); font-size: 13px; margin-top: 4px; font-weight: 600; }
.updated.is-refreshing { color: var(--accent); }

.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 80px;
}
.stat .n { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat.late .n { color: var(--red); }
.stat.ok .n { color: var(--green); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.toolbar input[type="search"], .toolbar select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
  font-size: 16px;
  min-height: 40px;
}
.toolbar input[type="search"] { min-width: 220px; flex: 1; }
.toolbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); user-select: none; white-space: nowrap; min-height: 40px; }
.toolbar button {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 6px;
  padding: 0 14px;
  min-height: 40px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.toolbar button.secondary { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.toolbar button:disabled { opacity: 0.5; cursor: wait; }
.meta { color: var(--muted); font-size: 11px; margin-left: auto; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  max-height: calc(100vh - 260px);
}
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
  z-index: 1;
}
th:hover { color: var(--text); }
tr:hover td { background: var(--row-hover); }
tr.late td { background: var(--late-bg); }
tr.late:hover td { background: var(--late-bg-hover); }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reasons { display: flex; flex-direction: column; gap: 2px; max-width: 260px; }
.reasons span { font-size: 11px; color: var(--reason-fg); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-fg);
}
.pill.DELIVERED, .pill.OUT_FOR_DELIVERY, .pill.AVAILABLE_FOR_PICKUP { background: var(--pill-ok-bg); color: var(--pill-ok-fg); }
.pill.IN_TRANSIT, .pill.WAITING_DELIVERY { background: var(--pill-transit-bg); color: var(--pill-transit-fg); }
.pill.EXCEPTION, .pill.EXPIRED, .pill.DELIVERY_FAILED, .pill.late { background: var(--pill-bad-bg); color: var(--pill-bad-fg); }

.links { display: flex; gap: 8px; white-space: nowrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 800px) {
  .topbar-inner { padding: 6px 12px; }
  .app { padding: 12px 12px 32px; }
  .whoami { display: none; }
  .truncate { max-width: 140px; }
  .toolbar input[type="search"] { min-width: 100%; }
  .meta { margin-left: 0; width: 100%; }
  .stats { width: 100%; }
  .stat { flex: 1 1 calc(50% - 8px); }
}
