/* Loopin Glass-System CSS
   Design tokens from DESIGN.md + component classes */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  /* Surface palette */
  --color-surface: #f6fafe;
  --color-surface-dim: #d6dade;
  --color-surface-bright: #f6fafe;
  --color-surface-container-lowest: #ffffff;
  --color-surface-container-low: #f0f4f8;
  --color-surface-container: #eaeef2;
  --color-surface-container-high: #e4e9ed;
  --color-surface-container-highest: #dfe3e7;
  --color-on-surface: #171c1f;
  --color-on-surface-variant: #45464d;
  --color-inverse-surface: #2c3134;
  --color-inverse-on-surface: #edf1f5;
  --color-outline: #76777d;
  --color-outline-variant: #c6c6cd;
  --color-surface-tint: #565e74;
  /* Primary */
  --color-primary: #000000;
  --color-on-primary: #ffffff;
  --color-primary-container: #131b2e;
  --color-on-primary-container: #7c839b;
  --color-inverse-primary: #bec6e0;
  --color-primary-fixed: #dae2fd;
  --color-primary-fixed-dim: #bec6e0;
  --color-on-primary-fixed: #131b2e;
  --color-on-primary-fixed-variant: #3f465c;
  /* Secondary (emerald) */
  --color-secondary: #006c49;
  --color-on-secondary: #ffffff;
  --color-secondary-container: #6cf8bb;
  --color-on-secondary-container: #00714d;
  --color-secondary-fixed: #6ffbbe;
  --color-secondary-fixed-dim: #4edea3;
  --color-on-secondary-fixed: #002113;
  --color-on-secondary-fixed-variant: #005236;
  /* Tertiary */
  --color-tertiary: #000000;
  --color-on-tertiary: #ffffff;
  --color-tertiary-container: #001a42;
  --color-on-tertiary-container: #3980f4;
  --color-tertiary-fixed: #d8e2ff;
  --color-tertiary-fixed-dim: #adc6ff;
  --color-on-tertiary-fixed: #001a42;
  --color-on-tertiary-fixed-variant: #004395;
  /* Error */
  --color-error: #ba1a1a;
  --color-on-error: #ffffff;
  --color-error-container: rgba(239, 68, 68, 0.1);
  --color-on-error-container: #93000a;
  --color-error-red: #ef4444;
  /* Background */
  --color-background: #f6fafe;
  --color-on-background: #171c1f;
  --color-surface-variant: #dfe3e7;
  /* Glass surfaces */
  --color-glass-surface: rgba(255, 255, 255, 0.4);
  --color-glass-nav: rgba(255, 255, 255, 0.6);
  --color-glass-border: rgba(255, 255, 255, 0.8);

  /* Radius */
  --radius-sm: 0.25rem;
  --radius: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* Spacing */
  --space-stack-sm: 8px;
  --space-stack-md: 16px;
  --space-stack-lg: 32px;
  --space-margin-desktop: 48px;
  --space-margin-mobile: 24px;
  --space-gutter: 24px;
  --space-touch-min: 44px;

  /* Typography */
  --font-family: 'Inter', sans-serif;
  --font-size-display: 3.75rem;
  --font-size-headline-lg: 2.25rem;
  --font-size-headline-lg-mobile: 1.875rem;
  --font-size-headline-md: 1.25rem;
  --font-size-body-md: 0.875rem;
  --font-size-label-bold: 0.75rem;
  --font-size-mono-id: 0.875rem;
  --font-size-status-badge: 11px;
}

/* ── Reset / base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-body-md);
  color: var(--color-on-surface);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Never allow the page itself to scroll sideways on phones. */
  overflow-x: hidden;
  max-width: 100%;
}

img, svg, video { max-width: 100%; height: auto; }

a { color: inherit; text-decoration: none; }

/* ── Ambient gradient background ───────────────────────────── */
.bg-ambient {
  background-color: var(--color-background);
  background-image:
    radial-gradient(circle at 15% 50%, rgba(216, 226, 255, 0.4), transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(111, 251, 190, 0.15), transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* ── Glass components ───────────────────────────────────────── */
.glass-card {
  background: var(--color-glass-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-glass-border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  transition: all 0.3s ease;
}
.glass-card:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: scale(1.01);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

.glass-nav {
  background: var(--color-glass-nav);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--color-glass-border);
}

/* ── Glow / delay state ─────────────────────────────────────── */
.glow-error {
  box-shadow: inset 0 0 10px rgba(239, 68, 68, 0.2), 0 0 15px rgba(239, 68, 68, 0.1);
}

/* ── Sidebar (desktop 256px fixed) ──────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 256px;
  display: flex;
  flex-direction: column;
  z-index: 40;
  padding-bottom: var(--space-stack-lg);
}

.sidebar-header {
  padding: var(--space-stack-lg) var(--space-gutter);
  display: flex;
  flex-direction: column;
  gap: var(--space-stack-sm);
}

.sidebar-brand {
  font-size: var(--font-size-headline-md);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.01em;
}

.sidebar-tenant {
  font-size: var(--font-size-body-md);
  color: var(--color-on-surface-variant);
  opacity: 0.8;
}

.sidebar-nav {
  flex: 1;
  padding: 0 var(--space-stack-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-footer {
  padding: 0 var(--space-stack-md);
  margin-top: auto;
}

/* ── Bottom nav (mobile) ────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: var(--space-stack-md) var(--space-gutter);
  background: rgba(246, 250, 254, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--color-glass-border);
}

/* ── Nav items ──────────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--color-on-surface-variant);
  transition: background 0.2s, color 0.2s, transform 0.1s;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--color-surface-container);
  color: var(--color-primary);
}
.nav-item:active { transform: scale(0.95); }

.nav-item.active {
  background: var(--color-surface-container-highest);
  color: var(--color-primary);
  font-weight: 700;
  border-right: 3px solid var(--color-primary);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--color-on-surface-variant);
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}
.bottom-nav-item:active { transform: scale(0.9); }
.bottom-nav-item.active {
  background: var(--color-primary-container);
  color: var(--color-inverse-on-surface);
}
.bottom-nav-item span.icon { font-size: 22px; }
.bottom-nav-item span.label { font-size: 10px; margin-top: 2px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  text-decoration: none;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }

.btn-primary-lg {
  width: 100%;
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  font-size: var(--font-size-headline-md);
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--color-on-surface);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}
.btn-ghost:hover { background: var(--color-surface-container); }
.btn-ghost:active { transform: scale(0.98); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-surface-container);
  color: var(--color-on-surface);
  border: 1px solid var(--color-outline-variant);
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}
.btn-icon:hover { background: var(--color-glass-surface); }

/* ── FAB ────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 88px; right: 24px;
  width: 56px; height: 56px;
  border-radius: var(--radius-xl);
  background: var(--color-primary);
  color: var(--color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: transform 0.1s;
  border: none;
  z-index: 40;
  text-decoration: none;
}
.fab:active { transform: scale(0.95); }

/* ── Inputs ─────────────────────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  background: var(--color-surface-container-lowest);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: var(--font-size-body-md);
  font-family: var(--font-family);
  color: var(--color-on-surface);
  outline: none;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}
.input::placeholder { color: var(--color-outline); }

select.input {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  /* Custom chevron so selects match the glass inputs (no native arrow). */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2345464d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 42px;
  /* Tame the native option-list highlight toward the brand instead of system blue. */
  accent-color: var(--color-primary);
  color-scheme: light;
}
select.input::-ms-expand { display: none; }
select.input option {
  background: var(--color-surface-container-lowest);
  color: var(--color-on-surface);
}

/* ── Custom glass dropdown (replaces the native option list) ──── */
.cdd { position: relative; }
/* Native select kept for form submit + a11y, hidden from view. */
.cdd-native {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
  margin: 0; padding: 0; border: 0;
}
.cdd-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  background-image: none; /* override the native-select chevron bg */
  padding-right: 14px;
}
.cdd-toggle .cdd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdd-chevron {
  font-size: 20px;
  color: var(--color-on-surface-variant);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.cdd.open .cdd-chevron { transform: rotate(180deg); }
.cdd.open .cdd-toggle {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.10);
}
.cdd-list {
  position: fixed;
  z-index: 1000;
  list-style: none;
  margin: 0;
  padding: 8px;
  min-width: 100%;
  width: max-content;
  max-width: 340px;
  max-height: 300px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 44px -10px rgba(15, 23, 42, 0.28);
  transform-origin: top center;
  animation: cdd-pop 0.15s ease;
}
@keyframes cdd-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cdd-list[hidden] { display: none; }
.cdd-option {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-on-surface);
  font-size: var(--font-size-body-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s ease, color 0.12s ease;
}
.cdd-option + .cdd-option { margin-top: 2px; }
.cdd-option:hover,
.cdd-option.active { background: var(--color-surface-container-high); }
/* Currently selected option uses the brand color (not system blue). */
.cdd-option[aria-selected="true"] {
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 600;
}
.cdd-option[aria-selected="true"]:hover,
.cdd-option[aria-selected="true"].active {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

/* ── Status pills ───────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-status-badge);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pill-dot {
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.pill-active {
  background: rgba(111, 251, 190, 0.2);
  color: var(--color-on-secondary-fixed);
}
.pill-active .pill-dot { background: var(--color-secondary); }

.pill-delayed {
  background: var(--color-error-container);
  color: var(--color-error);
}
.pill-delayed .pill-dot { background: var(--color-error-red); }

.pill-neutral {
  background: var(--color-surface-container-highest);
  color: var(--color-on-surface);
}
.pill-neutral .pill-dot { background: var(--color-surface-tint); }

.pill-cancelled {
  background: var(--color-surface-container);
  color: var(--color-on-surface-variant);
  text-decoration: line-through;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-md);
  background: var(--color-surface-container-high);
  color: var(--color-on-surface-variant);
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.badge-delay {
  background: var(--color-error-container);
  color: var(--color-error-red);
}

/* ── Stepper ────────────────────────────────────────────────── */
.stepper {
  display: flex;
  justify-content: space-between;
  position: relative;
}

.stepper-track {
  position: absolute;
  top: 18px; left: 20px; right: 20px;
  height: 4px;
  background: var(--color-surface-container-high);
  border-radius: var(--radius-full);
}

.stepper-progress {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: var(--color-secondary);
  border-radius: var(--radius-full);
  transition: width 1s ease;
}

.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.step-node {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border: 2px solid var(--color-surface-container-lowest);
}

.step-node-done {
  background: var(--color-secondary);
  color: var(--color-on-secondary);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.step-node-current {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.step-node-upcoming {
  background: var(--color-surface-container);
  color: var(--color-on-surface-variant);
}

.step-node-delayed {
  background: var(--color-error-red);
  color: var(--color-on-error);
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.step-label {
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: center;
  color: var(--color-on-surface-variant);
}

.step-label.current { color: var(--color-primary); font-weight: 700; }
.step-label.upcoming { opacity: 0.5; }

/* ── Flash banners ──────────────────────────────────────────── */
.flash {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-body-md);
  font-weight: 500;
  margin-bottom: var(--space-stack-md);
}
.flash-success {
  background: rgba(111, 251, 190, 0.2);
  color: var(--color-secondary);
  border: 1px solid var(--color-secondary-fixed);
}
.flash-error {
  background: var(--color-error-container);
  color: var(--color-error);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.flash-info {
  background: var(--color-primary-fixed);
  color: var(--color-on-primary-fixed);
  border: 1px solid var(--color-primary-fixed-dim);
}

/* ── Layout: tenant app shell ───────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0; /* allow this flex child to shrink instead of overflowing */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 80px; /* room for bottom nav on mobile */
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--color-glass-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}

/* ── Label ──────────────────────────────────────────────────── */
.label {
  display: block;
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
  margin-bottom: 6px;
}

/* ── Table ──────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-body-md);
}
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
  border-bottom: 1px solid var(--color-outline-variant);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(198, 198, 205, 0.3);
  color: var(--color-on-surface);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.3); }

/* ── Form row ───────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-stack-md); }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.stagger-1 { animation: fadeSlideUp 0.4s ease-out 0.1s both; }
.stagger-2 { animation: fadeSlideUp 0.4s ease-out 0.2s both; }
.stagger-3 { animation: fadeSlideUp 0.4s ease-out 0.3s both; }
.stagger-4 { animation: fadeSlideUp 0.4s ease-out 0.4s both; }
.stagger-5 { animation: fadeSlideUp 0.4s ease-out 0.5s both; }

/* ── Utility ────────────────────────────────────────────────── */
.text-mono {
  font-size: var(--font-size-mono-id);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.text-headline-md {
  font-size: var(--font-size-headline-md);
  font-weight: 500;
  line-height: 1.75rem;
}

.text-headline-lg {
  font-size: var(--font-size-headline-lg);
  font-weight: 300;
  line-height: 2.5rem;
  letter-spacing: -0.01em;
}

.text-body { font-size: var(--font-size-body-md); }
.text-label {
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.divider {
  border: none;
  border-top: 1px solid rgba(198, 198, 205, 0.3);
  margin: var(--space-stack-md) 0;
}

/* Settings sub-nav */
.settings-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-outline-variant);
  margin-bottom: var(--space-stack-lg);
}
.settings-nav-item {
  padding: 8px 20px;
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}
.settings-nav-item:hover { color: var(--color-primary); }
.settings-nav-item.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-margin-mobile, 24px);
}
/* Always-present modals toggle visibility via the [hidden] attribute. */
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--color-surface-container-lowest);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  padding: var(--space-stack-lg);
  width: 100%;
  max-width: 480px;
  position: relative;
}

/* WhatsApp bubble */
.wa-bubble {
  background: #d9fdd3;
  border-radius: 12px 12px 2px 12px;
  padding: 12px 16px;
  font-size: var(--font-size-body-md);
  color: #1a1a1a;
  max-width: 340px;
  line-height: 1.5;
  word-break: break-word;
}

/* Responsive: desktop shows sidebar, hides bottom-nav; mobile vice-versa */
@media (min-width: 1024px) {
  .sidebar { display: flex !important; }
  .bottom-nav { display: none !important; }
  .fab { display: none !important; }
  .main-content { margin-left: 256px; padding-bottom: 0; }
}
@media (max-width: 1023px) {
  .sidebar { display: none !important; }
  .bottom-nav { display: flex !important; }
}

/* Page padding */
.page-content {
  padding: var(--space-stack-lg) var(--space-margin-mobile);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  min-width: 0; /* let grid/flex descendants shrink */
}
@media (min-width: 768px) {
  .page-content {
    padding: var(--space-stack-lg) var(--space-margin-desktop);
  }
}
/* On phones, leave room so the floating action button + bottom nav never
   cover the last card. */
@media (max-width: 1023px) {
  .page-content { padding-bottom: 112px; }
}
/* Inner page wrappers shouldn't exceed the viewport. */
.page-content > * { max-width: 100%; }

/* Summary strip */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-stack-md);
  margin-bottom: var(--space-stack-lg);
}
.summary-card {
  background: var(--color-glass-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--color-glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-stack-md);
  text-align: center;
}
.summary-number {
  font-size: 2rem;
  font-weight: 300;
  color: var(--color-primary);
}
.summary-label {
  font-size: var(--font-size-label-bold);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--color-on-surface-variant);
  text-transform: uppercase;
  margin-top: 4px;
}

/* Order grid */
.order-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-stack-md);
}
@media (min-width: 768px) {
  .order-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1280px) {
  .order-grid { grid-template-columns: repeat(3, 1fr); }
}

.order-card {
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Item row in create form */
.item-row {
  background: var(--color-surface-container-low);
  border: 1px solid var(--color-outline-variant);
  border-radius: var(--radius-lg);
  padding: var(--space-stack-md);
  margin-bottom: var(--space-stack-md);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-outline-variant); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-outline); }

/* ── Responsive helpers ─────────────────────────────────────── */

/* Two-column form grid → single column on phones. */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-stack-md);
}
@media (min-width: 640px) {
  .form-grid-2 { grid-template-columns: 1fr 1fr; }
}

/* A row of fields that flows naturally and wraps on narrow screens. */
.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-stack-md);
  align-items: flex-end;
}
.field-row > * { min-width: 0; }
.field-grow { flex: 1 1 200px; min-width: 0; }
.field-fixed { flex: 0 0 auto; }

/* Tables scroll inside their card instead of widening the page. */
.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap .data-table { min-width: 420px; }

/* Stage editor row: fluid via flex-wrap (no breakpoint needed). */
.stage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--color-surface-container-low);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-outline-variant);
}
.stage-row .stage-seq { width: 56px; flex: 0 0 auto; }
.stage-row .stage-name { flex: 1 1 160px; min-width: 0; }
.stage-row .stage-duration { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.stage-row .stage-flags {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-left: auto;
}

/* Delay reason row: input grows, button wraps under on narrow screens. */
.delay-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.delay-row .input { flex: 1 1 200px; min-width: 0; }

/* Detail header: order id/customer on the left, actions on the right; wraps. */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: var(--space-stack-md);
}
.detail-header > div:first-child { min-width: 0; }

/* Mobile stepper: hide the per-step labels (the "Current: …" box names the
   stage), shrink nodes, and keep the connected track — no overflow/overlap. */
@media (max-width: 640px) {
  .step-label { display: none; }
  .step-node { width: 32px; height: 32px; margin-bottom: 0; }
  .step-node .material-symbols-outlined { font-size: 15px !important; }
  .stepper-track { top: 14px; }
}
