/* ============================================================
   VKS Patrol PWA — iOS-style direction
   System-grouped backgrounds, inset rounded lists, hairline
   separators, system-blue tint, Live Activity capsule, sheets.
   Type: Noto Sans Lao + Noto Sans only.
   ============================================================ */

:root {
  /* iOS system colors as HSL triplets */
  --background:        220 16% 96.5%;       /* #F2F2F7 systemGroupedBackground */
  --foreground:        0 0% 0%;             /* label */
  --card:              0 0% 100%;           /* secondarySystemGroupedBackground */
  --card-foreground:   0 0% 0%;
  --popover:           0 0% 100%;
  --popover-foreground: 0 0% 0%;
  --primary:           211 100% 50%;        /* #007AFF systemBlue */
  --primary-foreground: 0 0% 100%;
  --secondary:         240 4% 18%;
  --secondary-foreground: 0 0% 100%;
  --muted:             240 6% 92%;
  --muted-foreground:  240 4% 38%;
  --accent:            240 6% 92%;
  --accent-foreground: 0 0% 0%;
  --destructive:       4 100% 59%;          /* #FF3B30 systemRed */
  --destructive-foreground: 0 0% 100%;
  --border:            240 6% 88%;
  --input:             240 6% 88%;
  --ring:              211 100% 50%;

  /* Page surface — iOS systemGroupedBackground */
  --page-bg:           220 16% 96.5%;

  /* iOS additional system colors */
  --ios-green:         142 71% 45%;         /* #34C759 */
  --ios-orange:        35 100% 50%;         /* #FF9500 */
  --ios-purple:        285 67% 60%;         /* #AF52DE */
  --ios-pink:          340 79% 60%;
  --ios-yellow:        50 100% 50%;
  --ios-indigo:        239 70% 60%;         /* #5856D6 */
  --ios-gray:          240 6% 92%;
  --ios-gray-2:        240 6% 88%;
  --ios-gray-3:        240 6% 78%;
  --ios-label-2:       240 4% 38%;
  --ios-label-3:       240 4% 56%;

  /* Hairline separator (iOS uses 0.33pt rgba black) */
  --hairline:          rgba(60, 60, 67, 0.18);

  /* Brand accent — kept for legacy refs */
  --brand-accent:      #007AFF;

  /* iOS radii — larger and consistent */
  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  /* iOS-style shadows (subtle, depth-of-paper not depth-of-elevation) */
  --shadow-sm: 0 0.5px 0 rgba(0,0,0,0.04);
  --shadow:    0 1px 2px rgba(0,0,0,0.04), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 16px -8px rgba(0,0,0,0.1), 0 0 0 0.5px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 40px -16px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(0,0,0,0.04);

  /* Safe areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; border-width: 0; border-style: solid; border-color: hsl(var(--border)); }

html, body {
  margin: 0; padding: 0;
  min-height: 100vh; min-height: 100dvh;
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "ss01" 1;
  letter-spacing: -0.012em;
  background-color: hsl(var(--page-bg));
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.55;
  overscroll-behavior-y: contain;
}

/* iOS — tabular numerals on numeric displays (timer, scores, IDs, GPS). */
.mono, .input-id, .timer-time, .stat-value, .metric-value, .rating-num, .resume-elapsed,
.history-time, .history-detail-grid strong, .history-card-row2 .mono,
.h-time, .nav-meta,
input[type="time"], time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.025em; }

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-variation-settings: 'FILL' 1, 'wght' 400;
  vertical-align: middle;
  font-size: 1.25rem;
}

.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app-shell {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

.container { width: 100%; padding: 1rem; }

/* ============================================================
   HEADER (matches VKS .site-header pattern)
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(0.875rem + var(--safe-top)) 1rem 0.875rem;
  background: hsl(var(--background) / 0.92);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid hsl(var(--border));
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.header-logo {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(189 94% 35%) 100%);
  color: hsl(var(--primary-foreground));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: hsl(222 47% 11.2%);
}
.brand-text .accent { color: var(--brand-accent); margin-left: 2px; }

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  display: grid;
  place-items: center;
  transition: background 150ms, transform 80ms;
}
.icon-btn:hover { background: hsl(var(--accent)); }
.icon-btn:active { transform: scale(0.94); }

/* ============================================================
   STATUS PILL (online/offline)
   ============================================================ */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.625rem 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
}
.status-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: hsl(var(--muted-foreground));
  position: relative;
  flex: none;
}
.status-pill.online {
  color: hsl(142 76% 30%);
  background: hsl(142 76% 36% / 0.10);
  border-color: hsl(142 76% 36% / 0.25);
}
.status-pill.online .dot { background: hsl(142 76% 36%); }
.status-pill.online .dot::after {
  content: ""; position: absolute; inset: -2px;
  border-radius: 50%; background: hsl(142 76% 36%);
  opacity: 0.45;
  animation: pulse 1.6s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.status-pill.offline {
  color: hsl(38 92% 38%);
  background: hsl(38 92% 50% / 0.10);
  border-color: hsl(38 92% 50% / 0.30);
}
.status-pill.offline .dot { background: hsl(38 92% 50%); }

/* warn — degraded telemetry: GPS denied / GPS searching / heartbeat stale.
   Different from offline: device IS online, but the server's not getting
   what it needs to mark the inspector live on the dashboard. */
.status-pill.warn {
  color: hsl(20 92% 38%);
  background: hsl(20 92% 50% / 0.10);
  border-color: hsl(20 92% 50% / 0.32);
}
.status-pill.warn .dot { background: hsl(20 92% 50%); }

/* P1 slow-net resilience: 'stuck' = navigator.onLine but /api/ping unreachable
   (captive portal, zombie 2G). Same visual weight as offline so the inspector
   knows submits will queue, distinct red so it's not confused with offline. */
.status-pill.stuck {
  color: hsl(0 72% 38%);
  background: hsl(0 72% 50% / 0.10);
  border-color: hsl(0 72% 50% / 0.32);
}
.status-pill.stuck .dot { background: hsl(0 72% 50%); }

/* ============================================================
   CARDS (matches VKS .card pattern with primary left border)
   ============================================================ */

.card {
  border-radius: var(--radius-xl);
  border: 1px solid hsl(var(--border) / 0.8);
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid hsl(var(--primary));
  overflow: hidden;
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 1.25rem 1.25rem 0.75rem;
}
.card-title {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.card-description {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}
.card-content { padding: 0 1.25rem 1.25rem; }

/* Greeting / hero variant */
.card-hero {
  padding: 1.25rem;
}
.card-hero .greeting-line {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}
.card-hero h2 {
  font-size: 1.4rem;
  line-height: 1.2;
  margin: 0.25rem 0 0.875rem;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
  letter-spacing: 0.01em;
}
.chip.chip-id {
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  border-color: hsl(var(--primary) / 0.22);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.chip .material-symbols-outlined { font-size: 0.95rem; }

/* ============================================================
   MODE CARD (matches VKS .mode-card pattern)
   ============================================================ */

.mode-card {
  cursor: pointer;
  padding: 1rem;
  border-radius: var(--radius-xl);
  border: 2px solid hsl(var(--border));
  background: hsl(var(--background));
  display: flex;
  align-items: center;
  gap: 0.875rem;
  transition: all 0.25s ease;
  text-align: left;
  width: 100%;
  position: relative;
}

.mode-card:hover {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.03);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.mode-card:active { transform: scale(0.985); }

.mode-card.patrol:hover { border-color: #3B82F6; background: #EFF6FF; }
.mode-card.special:hover { border-color: #A855F7; background: #FAF5FF; }

.mode-card[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.mode-card[aria-disabled="true"]:hover {
  border-color: hsl(var(--border));
  background: hsl(var(--background));
  transform: none;
  box-shadow: var(--shadow-sm);
}

.mode-icon-box {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-lg);
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.mode-icon-box .material-symbols-outlined { font-size: 1.6rem; }

.mode-card.patrol .mode-icon-box { background: #DBEAFE; color: #2563EB; }
.mode-card.special .mode-icon-box { background: #F3E8FF; color: #9333EA; }
.mode-card.history .mode-icon-box { background: #ECFDF5; color: #059669; }
.mode-card.sites .mode-icon-box { background: #FFF7ED; color: #C2410C; }

.mode-text { flex: 1; min-width: 0; }
.mode-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: hsl(222 47% 11%);
  margin-bottom: 0.125rem;
  line-height: 1.25;
}
.mode-card-desc {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.35;
}

.mode-chevron {
  color: hsl(var(--border));
  transition: color 0.2s, transform 0.2s;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.mode-card:hover .mode-chevron { color: hsl(var(--primary)); transform: translateX(2px); }

.tag-soon {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: hsl(38 92% 50% / 0.12);
  color: hsl(38 92% 38%);
  border: 1px solid hsl(38 92% 50% / 0.25);
  margin-top: 0.25rem;
}

/* ============================================================
   BUTTONS (mirrors VKS .btn family)
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  height: 2.75rem;
  padding: 0 1.25rem;
  cursor: pointer;
  transition: all 150ms;
  user-select: none;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}
.btn:active { transform: scale(0.98); }
.btn:disabled { pointer-events: none; opacity: 0.5; }

.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { opacity: 0.92; }

.btn-outline { background: hsl(var(--background)); border: 1px solid hsl(var(--border)); }
.btn-outline:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }

.btn-block { width: 100%; height: 3rem; font-size: 1rem; }

@media (max-width: 640px) {
  .btn { min-height: 48px; font-size: 1rem; }
}

/* ============================================================
   INPUTS
   ============================================================ */

.input-group { margin-bottom: 1.25rem; }
label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: block;
  color: hsl(var(--foreground));
}

.input {
  display: block;
  width: 100%;
  height: 2.75rem;
  padding: 0 0.875rem;
  font-size: 1rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
  font-family: inherit;
}
.input:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.18);
}
.input::placeholder { color: hsl(var(--muted-foreground)); }

.input-id {
  font-family: 'Noto Sans', system-ui, monospace;
  font-feature-settings: "tnum";
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  font-size: 1.05rem;
}

.field-error {
  margin-top: 0.75rem;
  display: none;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: hsl(var(--destructive) / 0.08);
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.22);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  animation: shake 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.field-error.visible { display: flex; }
.field-error .material-symbols-outlined { font-size: 1.05rem; flex: none; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

.login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(2rem + var(--safe-top)) 1rem calc(1.5rem + var(--safe-bottom));
  animation: fadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-brand .header-logo {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 0.875rem;
  font-size: 1rem;
  border-radius: var(--radius);
}
.login-brand h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: hsl(222 47% 11%);
  margin: 0 0 0.25rem;
}
.login-brand h1 .accent { color: var(--brand-accent); }
.login-brand p {
  color: hsl(var(--muted-foreground));
  font-size: 0.85rem;
  margin: 0;
}

.login-card-wrap { padding: 0; }

.login-footer {
  text-align: center;
  margin-top: 1.25rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* ============================================================
   HOME SCREEN
   ============================================================ */

#screen-home {
  display: flex;
  flex-direction: column;
  flex: 1;
}

main.home-main {
  padding: 1rem 1rem calc(1.5rem + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.section-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.5rem 0.125rem 0;
}
.section-h h3 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
.section-h .section-sub {
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
}

.action-stack { display: flex; flex-direction: column; gap: 0.625rem; }

/* ============================================================
   BOTTOM SHEET MENU
   ============================================================ */

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 440px;
  background: hsl(var(--background));
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border-top: 1px solid hsl(var(--border));
  padding: 0 0 calc(1.25rem + var(--safe-bottom));
  z-index: 101;
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -10px 40px rgb(0 0 0 / 0.18);
  overflow: hidden;
}
.sheet.open { transform: translate(-50%, 0); }
.sheet.dragging { transition: none; }

/* Drag handle hit area — covers the handle plus a touch target above */
.sheet-grabber {
  padding: 0.5rem 0 0.625rem;
  cursor: grab;
  touch-action: none;
}
.sheet-grabber:active { cursor: grabbing; }
.sheet-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: hsl(var(--border));
  margin: 0 auto;
  transition: background 150ms;
}
.sheet-grabber:active .sheet-handle { background: hsl(var(--muted-foreground) / 0.5); }

/* ----- Profile block ----- */
.sheet-profile {
  position: relative;
  padding: 0.5rem 1.25rem 1rem;
  background:
    radial-gradient(120% 80% at 100% 0%, hsl(var(--primary) / 0.10), transparent 55%),
    hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
}
.sheet-profile-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}
.sheet-avatar {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(189 94% 32%) 100%);
  color: hsl(var(--primary-foreground));
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  flex: none;
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.30);
  border: 2px solid hsl(var(--background));
}
.sheet-profile-meta { flex: 1; min-width: 0; }
.sheet-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
  color: hsl(222 47% 11%);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-sub {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0.25rem 0 0;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  background: hsl(var(--primary) / 0.08);
  color: hsl(var(--primary));
  border: 1px solid hsl(var(--primary) / 0.22);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.sheet-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.875rem;
}
.sheet-chip-row .chip { font-size: 0.7rem; padding: 0.2rem 0.55rem; }

/* ----- Sections ----- */
.sheet-section {
  padding: 0.625rem 0.625rem 0.25rem;
}
.sheet-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  padding: 0 0.625rem 0.375rem;
}

.sheet-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 0.625rem;
  border-radius: var(--radius);
  width: 100%;
  text-align: left;
  color: hsl(var(--foreground));
  min-height: 52px;
  transition: background 150ms, transform 80ms;
}
.sheet-row:hover { background: hsl(var(--muted)); }
.sheet-row:active { transform: scale(0.985); background: hsl(var(--accent)); }
.sheet-row .icn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  display: grid;
  place-items: center;
  flex: none;
}
.sheet-row .icn .material-symbols-outlined { font-size: 1.15rem; }
.sheet-row .lbl {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sheet-row .lbl-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0.01em;
}
.sheet-row .meta {
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  background: hsl(var(--muted));
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}
.sheet-row .chevron {
  color: hsl(var(--muted-foreground) / 0.6);
  display: grid;
  place-items: center;
}
.sheet-row .chevron .material-symbols-outlined { font-size: 1.1rem; }

/* ----- Sign out CTA ----- */
.sheet-footer {
  padding: 0.5rem 1rem 0;
  border-top: 1px solid hsl(var(--border));
  margin-top: 0.5rem;
}
.btn-signout {
  width: 100%;
  height: 3rem;
  border-radius: var(--radius);
  background: hsl(var(--destructive) / 0.08);
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.22);
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 150ms, transform 80ms;
}
.btn-signout:hover { background: hsl(var(--destructive) / 0.12); }
.btn-signout:active { transform: scale(0.985); }
.btn-signout .material-symbols-outlined { font-size: 1.15rem; }

/* ============================================================
   PATROL FORM SCREEN
   ============================================================ */

#screen-patrol-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.form-top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: calc(0.75rem + var(--safe-top)) 0.875rem 0.75rem;
  background: hsl(var(--background) / 0.94);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid hsl(var(--border));
}
.form-top-bar .icon-btn { background: transparent; }

/* Step progress */
.step-progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.step-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.step-progress-title {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step-progress-num {
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.step-bar {
  height: 3px;
  background: hsl(var(--muted));
  border-radius: var(--radius-full);
  overflow: hidden;
}
.step-bar-fill {
  height: 100%;
  background: hsl(var(--primary));
  border-radius: inherit;
  transition: width 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.form-main {
  padding: 1rem 1rem calc(7rem + var(--safe-bottom));
  position: relative;
}

/* Stage = one wizard step. Only the active stage is rendered. */
.stage {
  display: none;
  flex-direction: column;
  gap: 0.875rem;
}
.stage.active {
  display: flex;
  animation: slideStage 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.stage.back-anim.active {
  animation: slideStageBack 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes slideStage {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideStageBack {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.form-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-xl);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.form-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  margin: 0 0 0.875rem;
}
.form-card-title .material-symbols-outlined {
  font-size: 1.05rem;
  color: hsl(var(--primary));
}

.form-row + .form-row { margin-top: 0.875rem; }
.form-row label {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: hsl(var(--foreground));
}

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, hsl(var(--muted-foreground)) 50%),
                    linear-gradient(135deg, hsl(var(--muted-foreground)) 50%, transparent 50%);
  background-position: calc(100% - 1.1rem) 1.1rem, calc(100% - 0.85rem) 1.1rem;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.5rem;
}

textarea.input {
  height: auto;
  min-height: 5rem;
  padding: 0.75rem 0.875rem;
  resize: vertical;
  line-height: 1.5;
}

input[type="time"].input { padding: 0 0.875rem; }

/* ----- Radio group ----- */
.radio-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.radio-tile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border: 1.5px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms;
  background: hsl(var(--background));
  font-size: 0.875rem;
  font-weight: 500;
  user-select: none;
}
.radio-tile:has(input:checked) {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
  color: hsl(var(--primary));
}
.radio-tile input { display: none; }
.radio-tile .material-symbols-outlined { font-size: 1.05rem; }

/* ----- Employee type 2-col radio (Permanent vs OT) — Step 1 ----- */
.emp-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.emp-type-grid .radio-tile {
  justify-content: center;
  text-align: center;
  padding: 0.75rem 0.6rem;
  font-size: 0.85rem;
  line-height: 1.3;
}

/* ----- Equipment grid (2x2 mini cards) ----- */
.equip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.equip-cell {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  min-height: 110px;
}
.equip-cell .equip-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  line-height: 1.25;
}
.equip-cell .equip-label .material-symbols-outlined {
  font-size: 1.1rem;
  color: hsl(var(--primary));
  flex: none;
}
.equip-cell .equip-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-top: auto;
}
.equip-cell label.radio-tile {
  padding: 0.5rem 0.4rem;
  font-size: 0.78rem;
  justify-content: center;
  min-height: 38px;
}
.equip-cell label.radio-tile.yes:has(input:checked) {
  border-color: hsl(142 76% 40%);
  background: hsl(142 76% 36% / 0.10);
  color: hsl(142 76% 30%);
}
.equip-cell label.radio-tile.no:has(input:checked) {
  border-color: hsl(var(--destructive));
  background: hsl(var(--destructive) / 0.10);
  color: hsl(var(--destructive));
}

/* ----- Check-tile (single-press perimeter checks) ----- */
.check-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.check-tile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1.5px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms;
  background: hsl(var(--background));
  user-select: none;
}
.check-tile:has(input:checked) {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.05);
}
.check-tile input { display: none; }
.check-tile .check-box {
  width: 1.25rem; height: 1.25rem;
  border-radius: 6px;
  border: 1.5px solid hsl(var(--border));
  display: grid;
  place-items: center;
  flex: none;
  transition: all 150ms;
  background: hsl(var(--background));
}
.check-tile:has(input:checked) .check-box {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
}
.check-tile .check-box .material-symbols-outlined {
  font-size: 1rem;
  color: white;
  opacity: 0;
  transition: opacity 150ms;
}
.check-tile:has(input:checked) .check-box .material-symbols-outlined { opacity: 1; }
.check-tile .check-text { flex: 1; min-width: 0; }
.check-tile .check-text .ct-label {
  font-size: 0.875rem;
  font-weight: 500;
  display: block;
}
.check-tile .check-text .ct-sub {
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground));
}
.check-tile .check-icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  display: grid;
  place-items: center;
  flex: none;
  transition: all 150ms;
}
.check-tile:has(input:checked) .check-icon {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}

/* ----- Photo grid (Stage 5) ----- */
.photo-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 3rem;
  padding: 0 1rem;
  border: 1.5px dashed hsl(var(--primary) / 0.45);
  border-radius: var(--radius);
  background: hsl(var(--primary) / 0.04);
  color: hsl(var(--primary));
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.photo-add-btn:hover { background: hsl(var(--primary) / 0.08); border-color: hsl(var(--primary)); }
.photo-add-btn .material-symbols-outlined { font-size: 1.25rem; }

.photo-add-btn input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-empty {
  text-align: center;
  padding: 1.25rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.85rem;
  border: 1.5px dashed hsl(var(--border));
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  animation: photoIn 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes photoIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
.photo-tile img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.photo-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid; place-items: center;
  color: white;
}
.photo-overlay.error {
  background: hsl(var(--destructive) / 0.85);
}
.photo-overlay .material-symbols-outlined { font-size: 1.5rem; }
.photo-overlay .spinner {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: white;
  width: 22px; height: 22px;
}

.photo-badge {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: hsl(142 76% 36%);
  color: white;
  display: grid; place-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.photo-badge .material-symbols-outlined { font-size: 14px; }

/* P2 slow-net resilience: per-photo upload progress.
   Overlays bottom-half of the tile with a translucent dark band + green
   fill bar + percentage label. Visible only while status='uploading'
   and pct is between 0 and 100 (exclusive). */
.photo-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 22px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.65));
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.02em;
  z-index: 2;
}
.photo-progress-fill {
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, hsl(142 76% 50%), hsl(195 95% 60%));
  transition: width 0.2s ease-out;
}
.photo-progress-pct {
  margin-left: auto;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* 'queued' overlay (offline/unreachable) — neutral amber, distinct from
   'failed' red and 'uploading' spinner. */
.photo-overlay.queued {
  background: rgba(38, 92, 50, 0);
  color: hsl(38 92% 60%);
}

.photo-delete {
  position: absolute;
  top: 6px; left: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 150ms;
}
.photo-delete:hover { background: rgba(0, 0, 0, 0.85); }
.photo-delete .material-symbols-outlined { font-size: 14px; }

.photo-hint {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  margin: 0.5rem 0 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.4;
}
.photo-hint .material-symbols-outlined { font-size: 1rem; flex: none; }

/* Photo hint reactive copy — online/offline variants. The actual storage
 * is offline-safe (formPhotos[].status='queued' + replayQueue on reconnect)
 * so we tell the inspector that, instead of the old "internet required" lie. */
.photo-hint-online  { display: inline; }
.photo-hint-offline { display: none; }
body.is-offline .photo-hint                          { color: hsl(var(--ios-green)); }
body.is-offline .photo-hint .material-symbols-outlined { color: hsl(var(--ios-green)); }
body.is-offline .photo-hint-online   { display: none; }
body.is-offline .photo-hint-offline  { display: inline; }

/* ----- Auto-capture banner (Stage 6) ----- */
.auto-banner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  background: hsl(var(--primary) / 0.06);
  border: 1px dashed hsl(var(--primary) / 0.3);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
}
.auto-banner .ab-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  display: grid; place-items: center;
  flex: none;
}
.auto-banner .ab-icon .material-symbols-outlined { font-size: 1rem; }
.auto-banner .ab-text strong { font-weight: 600; color: hsl(var(--foreground)); }
.auto-banner .ab-text { line-height: 1.4; }
.auto-banner.has-fix {
  background: hsl(142 76% 36% / 0.06);
  border-color: hsl(142 76% 36% / 0.30);
  border-style: solid;
}
.auto-banner.has-fix .ab-icon {
  background: hsl(142 76% 36% / 0.15);
  color: hsl(142 76% 36%);
}
.auto-banner.is-retryable {
  cursor: pointer;
  background: hsl(35 100% 50% / 0.06);
  border-color: hsl(35 100% 50% / 0.35);
  border-style: solid;
}
.auto-banner.is-retryable .ab-icon {
  background: hsl(35 100% 50% / 0.15);
  color: hsl(35 100% 50%);
}
.auto-banner.is-retryable:active { transform: scale(0.985); }

/* ============================================================
   JT-SELECT (custom dropdown — replaces native <select>)
   ============================================================ */

.jt-select { position: relative; }
.jt-select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 2.75rem;
  padding: 0 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  font-size: 1rem;
  font-family: inherit;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: border-color 150ms, box-shadow 150ms;
  text-align: left;
}
.jt-select-trigger:hover { border-color: hsl(var(--muted-foreground) / 0.5); }
.jt-select-trigger.is-open,
.jt-select-trigger:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.18);
  outline: none;
}
.jt-select-trigger .jt-sel-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.95rem;
}
.jt-select-trigger .jt-sel-placeholder { color: hsl(var(--muted-foreground)); }
.jt-select-trigger .jt-sel-arrow {
  font-size: 1.15rem;
  color: hsl(var(--muted-foreground));
  transition: transform 200ms ease;
  flex-shrink: 0;
}
.jt-select-trigger.is-open .jt-sel-arrow { transform: rotate(180deg); }

.jt-select-panel {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 4px);
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.18), 0 4px 8px rgb(0 0 0 / 0.08);
  z-index: 9999;
  overflow: hidden;
  animation: jtDropIn 180ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* Allow the panel to escape ancestor containers (sub-options card, reveal) */
.jt-select { z-index: auto; }
.jt-select:has(.jt-select-trigger.is-open) { z-index: 100; position: relative; }
@keyframes jtDropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.jt-select-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
}
.jt-select-search-wrap .material-symbols-outlined {
  font-size: 1.1rem;
  color: hsl(var(--muted-foreground));
}
.jt-select-search {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 0.875rem;
  font-family: inherit;
  background: transparent;
  color: hsl(var(--foreground));
}
.jt-select-search::placeholder { color: hsl(var(--muted-foreground)); opacity: 0.7; }

.jt-select-scroll {
  max-height: 240px;
  overflow-y: auto;
  padding: 0.25rem;
}

.jt-select-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  font-size: 0.875rem;
  font-family: inherit;
  color: hsl(var(--foreground));
  cursor: pointer;
  text-align: left;
  transition: background 100ms;
  min-height: 40px;
}
.jt-select-option:hover { background: hsl(var(--muted)); }
.jt-select-option.is-selected {
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  font-weight: 600;
}
.jt-select-option .jt-sel-icon { font-size: 1.1rem; flex: none; }
.jt-select-option .jt-sel-text { flex: 1; min-width: 0; }
.jt-select-option .jt-sel-check {
  font-size: 1.1rem;
  color: hsl(var(--primary));
  flex: none;
}
/* Route tag inside dropdown options + trigger label */
.jt-select-option .site-route-tag,
.jt-sel-tag.site-route-tag {
  flex: none;
  font-size: 10.5px;
  padding: 2px 7px;
}
.jt-sel-tag {
  margin-left: 0.4rem;
  vertical-align: middle;
}
.jt-select-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

/* ----- Conditional reveal (uniform/defense missing, sleep/position reason)
        Cap is high enough for the 7-item uniform grid and any future block.
        overflow toggles to visible after the open animation so the
        jt-select dropdown panel can escape the container. */
.reveal {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 320ms cubic-bezier(0.22, 1, 0.36, 1),
              opacity 220ms,
              margin-top 200ms,
              overflow 0s 0s;
  margin-top: 0;
}
.reveal.open {
  max-height: 1400px;
  opacity: 1;
  margin-top: 0.75rem;
  overflow: visible;
  transition: max-height 320ms cubic-bezier(0.22, 1, 0.36, 1),
              opacity 220ms,
              margin-top 200ms,
              overflow 0s 320ms;
}

/* ----- Slider ----- */
.slider-group { padding: 0.25rem 0; }
.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.slider-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.slider-label .material-symbols-outlined {
  font-size: 1rem;
  color: hsl(var(--muted-foreground));
}
.slider-value {
  font-weight: 700;
  color: hsl(var(--primary));
  font-size: 0.95rem;
  min-width: 2.4rem;
  text-align: right;
}
input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: hsl(var(--muted));
  border-radius: var(--radius-full);
  outline: none;
}
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: hsl(var(--primary));
  border: 3px solid hsl(var(--background));
  box-shadow: 0 2px 6px hsl(var(--primary) / 0.4);
  cursor: pointer;
  transition: transform 100ms;
}
input[type="range"].slider::-webkit-slider-thumb:active { transform: scale(1.15); }
input[type="range"].slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: hsl(var(--primary));
  border: 3px solid hsl(var(--background));
  box-shadow: 0 2px 6px hsl(var(--primary) / 0.4);
  cursor: pointer;
}
.slider-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  padding: 0 4px;
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
}
.slider-group + .slider-group {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed hsl(var(--border));
}

/* ----- GPS card ----- */
.gps-card {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: hsl(var(--muted) / 0.5);
  border: 1px dashed hsl(var(--border));
  margin-bottom: 0.75rem;
}
.gps-card.has-fix {
  background: hsl(142 76% 36% / 0.06);
  border-color: hsl(142 76% 36% / 0.3);
  border-style: solid;
}
.gps-icon-box {
  width: 2rem; height: 2rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  display: grid; place-items: center;
  flex: none;
}
.gps-card.has-fix .gps-icon-box {
  background: hsl(142 76% 36% / 0.15);
  color: hsl(142 76% 36%);
}
.gps-info { flex: 1; min-width: 0; }
.gps-info .gps-label { font-size: 0.8rem; font-weight: 500; }
.gps-info .gps-coords {
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground));
  font-family: 'Noto Sans', monospace;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Read-only patrol header ----- */
.patrol-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.patrol-header .avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(189 94% 32%) 100%);
  color: hsl(var(--primary-foreground));
  display: grid;
  place-items: center;
  font-weight: 700;
  flex: none;
}
.patrol-header .meta { flex: 1; min-width: 0; }
.patrol-header .meta strong {
  font-size: 0.9rem;
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.patrol-header .meta small {
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground));
}

/* ----- Sticky submit / nav bar ----- */
.submit-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 440px;
  padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
  background: hsl(var(--background) / 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid hsl(var(--border));
  z-index: 25;
  display: flex;
  gap: 0.5rem;
}
.submit-bar .btn { height: 3rem; }
.submit-bar .btn-flex-grow { flex: 1; }

/* Special-mode bottom bar — same layout as .submit-bar */
.form-bottom-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 440px;
  padding: 0.75rem 1rem calc(0.75rem + var(--safe-bottom));
  background: hsl(var(--background) / 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid hsl(var(--border));
  z-index: 25;
  display: flex;
  gap: 0.5rem;
}
.form-bottom-bar .btn { height: 3rem; }
.form-bottom-bar .btn-flex-grow { flex: 1; }

/* Hide the sticky bottom bar while the soft keyboard is open
   (any input/textarea focused inside the screen). */
#screen-patrol-form:has(input:not([type="hidden"]):focus, textarea:focus) .submit-bar,
#screen-special:has(input:not([type="hidden"]):focus, textarea:focus) .form-bottom-bar {
  transform: translateX(-50%) translateY(140%);
  pointer-events: none;
  opacity: 0;
}
.submit-bar, .form-bottom-bar {
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease;
}

/* ----- Checkbox tile (multi-select missing items) ----- */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.checkbox-tile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border: 1.5px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: pointer;
  background: hsl(var(--background));
  font-size: 0.85rem;
  font-weight: 500;
  user-select: none;
  transition: all 150ms;
  min-height: 44px;
}
.checkbox-tile:has(input:checked) {
  border-color: hsl(var(--destructive));
  background: hsl(var(--destructive) / 0.06);
  color: hsl(var(--destructive));
}
.checkbox-tile input { display: none; }
.checkbox-tile .emoji {
  font-size: 1.05rem;
  flex: none;
}

/* Sub-options block (revealed on No) */
.sub-options {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: hsl(var(--destructive) / 0.04);
  border: 1px dashed hsl(var(--destructive) / 0.30);
  border-radius: var(--radius);
}
.sub-options-label {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.5rem;
  font-weight: 500;
}

/* ----- Summary card (Confirm stage) ----- */
.summary-card {
  background: linear-gradient(180deg, hsl(var(--primary) / 0.06), transparent);
  border: 1px solid hsl(var(--primary) / 0.18);
  border-radius: var(--radius-lg);
  padding: 1rem;
}
.summary-card h4 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.625rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: hsl(var(--primary));
}
.summary-card h4 .material-symbols-outlined { font-size: 1.05rem; }
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed hsl(var(--border));
  font-size: 0.85rem;
}
.summary-row:last-child { border-bottom: 0; }
.summary-row .lbl { color: hsl(var(--muted-foreground)); flex: none; }
.summary-row .val { font-weight: 500; text-align: right; word-break: break-word; }
.summary-row .val.warn { color: hsl(38 92% 38%); }
.summary-row .val.danger { color: hsl(var(--destructive)); }
.summary-row .val.ok { color: hsl(142 76% 30%); }

/* ============================================================
   QUEUE BADGE + TOAST
   ============================================================ */

.queue-badge {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.125rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  background: hsl(38 92% 50% / 0.10);
  border: 1px solid hsl(38 92% 50% / 0.30);
  color: hsl(38 92% 38%);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms;
}
.queue-badge.visible { display: inline-flex; }
.queue-badge:hover { background: hsl(38 92% 50% / 0.16); }
.queue-badge .material-symbols-outlined { font-size: 1.05rem; }
.queue-badge .count {
  margin-left: auto;
  background: hsl(38 92% 50%);
  color: white;
  border-radius: var(--radius-full);
  padding: 0.05rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
}
.queue-badge.syncing { background: hsl(var(--primary) / 0.10); border-color: hsl(var(--primary) / 0.3); color: hsl(var(--primary)); }
.queue-badge.syncing .count { background: hsl(var(--primary)); }
.queue-badge .queue-badge-arrow { margin-left: 0.25rem; font-size: 1.05rem; opacity: 0.7; }
.queue-badge.syncing .queue-badge-icon { animation: queue-spin 1.1s linear infinite; }
@keyframes queue-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .queue-badge.syncing .queue-badge-icon { animation: none; } }

/* Toast — anchored to the top so it doesn't collide with the sticky
   submit/nav bar at the bottom of every screen. */
.toast-stack {
  position: fixed;
  left: 50%;
  top: calc(0.75rem + var(--safe-top));
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9000;
  pointer-events: none;
}
.toast {
  background: hsl(222 47% 11%);
  color: white;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  box-shadow: 0 10px 25px rgb(0 0 0 / 0.35);
  pointer-events: auto;
  animation: toastIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.toast.toast-success { background: hsl(142 71% 30%); }
.toast.toast-warn    { background: hsl(38 92% 38%); }
.toast.toast-error   { background: hsl(0 76% 45%); }
.toast .material-symbols-outlined { font-size: 1.15rem; }
.toast.leaving { animation: toastOut 0.22s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-20px) scale(0.96); }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid hsl(var(--primary-foreground) / 0.3);
  border-top-color: hsl(var(--primary-foreground));
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.5; }
  70%  { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .status-pill.online .dot::after { display: none; }
}

/* =====================================================================
   HISTORY screen
   ===================================================================== */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0 0 5rem;
  position: relative;
}

.history-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.history-card:active {
  transform: scale(0.985);
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2);
}

/* Expandable detail — collapsed by default, slides open when .expanded */
.history-detail {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 280ms ease, opacity 200ms ease, margin-top 200ms ease;
}
.history-card.expanded .history-detail {
  max-height: 240px;
  opacity: 1;
  margin-top: 0.5rem;
}
.history-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  padding: 0.75rem;
  background: hsl(var(--muted) / 0.4);
  border-radius: 10px;
}
.history-detail-grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  font-size: 0.75rem;
  min-width: 0;
}
.history-detail-grid small {
  color: hsl(var(--muted-foreground));
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.history-detail-grid strong {
  color: hsl(var(--foreground));
  font-weight: 600;
  word-break: break-word;
}
.history-chevron {
  margin-left: auto;
  transition: transform 220ms ease;
  color: hsl(var(--muted-foreground));
  opacity: 0.6;
}
.history-card.expanded .history-chevron {
  transform: rotate(180deg);
  color: hsl(var(--primary));
  opacity: 1;
}

/* Skeleton placeholder cards */
.history-skeleton {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.history-skeleton .sk-row1, .history-skeleton .sk-row2 {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.sk-bar, .sk-pill {
  height: 12px;
  background: linear-gradient(90deg, hsl(var(--muted) / 0.5), hsl(var(--muted) / 0.85), hsl(var(--muted) / 0.5));
  background-size: 200% 100%;
  border-radius: 6px;
  animation: skShimmer 1.4s ease-in-out infinite;
}
.sk-pill { width: 56px; height: 18px; border-radius: 999px; flex-shrink: 0; }
.sk-w70 { width: 70%; flex: 1; }
.sk-w30 { width: 30%; }
.sk-w20 { width: 20%; }
.sk-w25 { width: 25%; }
@keyframes skShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Pull-to-refresh indicator */
.pull-indicator {
  position: absolute;
  top: -52px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
}
.pull-indicator .material-symbols-outlined {
  font-size: 22px;
  color: hsl(var(--primary));
  transition: transform 200ms ease;
}
.pull-indicator.ready .material-symbols-outlined {
  transform: rotate(180deg);
}
.pull-indicator.refreshing .material-symbols-outlined {
  animation: spin 0.8s linear infinite;
}

/* GPS retry link inside the timer card */
.gps-retry {
  color: hsl(var(--primary));
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* =====================================================================
   Install banner (Android Chrome beforeinstallprompt capture)
   ===================================================================== */
.install-banner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  background: linear-gradient(135deg, hsl(var(--primary) / 0.1), hsl(var(--primary) / 0.02));
  border: 1px solid hsl(var(--primary) / 0.3);
  border-radius: 14px;
  margin-bottom: 0.75rem;
  animation: slideDownIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.install-banner[hidden] { display: none; }
@keyframes slideDownIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.install-icon {
  flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 10px;
  background: hsl(var(--primary));
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.install-icon .material-symbols-outlined { font-size: 1.2rem !important; }
.install-meta { flex: 1; min-width: 0; }
.install-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: hsl(var(--primary));
}
.install-desc {
  font-size: 0.72rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.35;
}
.install-btn {
  flex-shrink: 0;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: hsl(var(--primary));
  color: white;
  font-weight: 700;
  font-size: 0.78rem;
  border: none; cursor: pointer; font-family: inherit;
  min-height: 36px;
}
.install-btn:active { transform: scale(0.97); }
.install-x {
  flex-shrink: 0;
  min-width: 36px; min-height: 36px;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: transparent;
  color: hsl(var(--muted-foreground));
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
}
.install-x .material-symbols-outlined { font-size: 1.05rem; }

/* =====================================================================
   Resume in-progress duty card (purple-themed, gentle pulse)
   ===================================================================== */
.resume-card {
  width: 100%;
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.875rem 1rem;
  background: linear-gradient(135deg, hsl(262 83% 58% / 0.08), hsl(262 83% 58% / 0.02));
  border: 1px solid hsl(262 83% 58% / 0.3);
  border-radius: 16px;
  margin-bottom: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  position: relative;
  animation: resumePulse 2.4s ease-in-out infinite;
  transition: transform 0.15s ease;
}
.resume-card[hidden] { display: none; }
.resume-card:active { transform: scale(0.99); }
@keyframes resumePulse {
  0%, 100% { box-shadow: 0 0 0 0 hsl(262 83% 58% / 0); }
  50%      { box-shadow: 0 0 0 6px hsl(262 83% 58% / 0.12); }
}
.resume-head { display: flex; align-items: center; gap: 0.625rem; }
.resume-icon {
  flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 11px;
  background: hsl(262 83% 58% / 0.12);
  display: flex; align-items: center; justify-content: center;
  color: hsl(262 83% 58%);
}
.resume-icon .material-symbols-outlined { font-size: 1.25rem !important; animation: timerPulse 2s ease-in-out infinite; }
.resume-text { min-width: 0; flex: 1; }
.resume-sub {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: hsl(262 83% 35%);
}
.resume-title {
  font-size: 0.95rem; font-weight: 700;
  color: hsl(var(--foreground)); margin-top: 0.1rem;
}
.resume-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem;
  background: hsl(var(--card));
  border-radius: 10px; padding: 0.5rem 0.75rem;
}
.resume-meta > div { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.resume-meta small {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: hsl(var(--muted-foreground));
}
.resume-meta strong {
  font-size: 0.8rem; font-weight: 700; color: hsl(var(--foreground));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.resume-elapsed {
  text-align: center;
  font-size: 1.5rem; font-weight: 700;
  color: hsl(262 83% 50%);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  padding: 0.2rem 0;
}
.resume-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem;
}
.resume-act {
  height: 2.6rem;
  font-size: 0.85rem;
  width: 100%;
}

/* =====================================================================
   History — type chips + filter tabs + per-kind stripe
   ===================================================================== */
.history-filter-row {
  display: flex; gap: 0.4rem;
  margin-bottom: 0.75rem;
  position: sticky; top: 0;
  background: hsl(var(--background) / 0.95);
  backdrop-filter: blur(8px);
  z-index: 5;
  padding: 0.25rem 0;
}
.history-filter-tab {
  padding: 0.4rem 0.875rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-height: 36px;
  transition: all 0.15s ease;
}
.history-filter-tab.active {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  border-color: hsl(var(--foreground));
}
.history-card.is-special { border-left: 3px solid hsl(262 83% 58%); }
.history-card.is-patrol  { border-left: 3px solid hsl(var(--primary)); }

.type-chip {
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.type-chip.regular {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}
.type-chip.special {
  background: hsl(262 83% 58% / 0.14);
  color: hsl(262 83% 45%);
}
.type-chip.emergency {
  background: hsl(0 84% 60% / 0.14);
  color: hsl(0 84% 45%);
}

/* =====================================================================
   Sites screen — simple list of route locations
   ===================================================================== */
.sites-list {
  display: flex; flex-direction: column;
  gap: 0.5rem;
  padding: 0 0 5rem;
}
.site-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  padding: 0.75rem 0.875rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.site-num {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-weight: 700;
  font-size: 0.85rem;
}
.site-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  word-break: break-word;
}
.site-route {
  flex-shrink: 0;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Failed-photo tile invites tap to retry */
.photo-tile:has(.photo-overlay.error) {
  cursor: pointer;
}
.photo-tile:has(.photo-overlay.error)::after {
  content: "ກົດເພື່ອລອງໃໝ່ · Tap to retry";
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(239, 68, 68, 0.85);
  color: white;
  font-size: 0.62rem;
  font-weight: 600;
  text-align: center;
  padding: 0.18rem 0.25rem;
  letter-spacing: 0.02em;
}

.history-card-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.history-site {
  font-weight: 600;
  font-size: 0.95rem;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.history-status {
  flex-shrink: 0;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.history-status.normal {
  background: hsl(142 71% 45% / 0.12);
  color: hsl(142 71% 32%);
}

.history-status.issue {
  background: hsl(38 92% 50% / 0.15);
  color: hsl(38 92% 35%);
}

.history-card-row2 {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.875rem;
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
}

.history-card-row2 span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.history-card-row2 .material-symbols-outlined {
  font-size: 14px;
  opacity: 0.7;
}

.history-issues {
  font-size: 0.78rem;
  color: hsl(38 92% 35%);
  line-height: 1.4;
  background: hsl(38 92% 50% / 0.08);
  padding: 0.4rem 0.625rem;
  border-radius: 8px;
  border-left: 2px solid hsl(38 92% 50%);
}

.history-empty,
.history-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  gap: 0.625rem;
}

.history-empty .material-symbols-outlined {
  font-size: 48px;
  color: hsl(var(--primary) / 0.3);
}

.history-empty h3 {
  margin: 0;
  color: hsl(var(--foreground));
  font-size: 1rem;
  font-weight: 600;
}

.history-empty p {
  margin: 0;
  font-size: 0.85rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid hsl(var(--primary) / 0.2);
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =====================================================================
   SPECIAL DUTY screen — duty type cards, timer, risk tiles
   ===================================================================== */

.duty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}

.duty-card {
  background: hsl(var(--card));
  border: 2px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
  font-family: inherit;
}

.duty-card .material-symbols-outlined {
  font-size: 32px;
  color: hsl(var(--muted-foreground));
  transition: color 0.2s ease;
}

.duty-card strong {
  font-size: 0.88rem;
  color: hsl(var(--foreground));
  font-weight: 600;
}

.duty-card small {
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0.02em;
}

.duty-card:active {
  transform: scale(0.96);
}

.duty-card.selected {
  background: hsl(var(--primary) / 0.08);
  border-color: hsl(var(--primary));
}

.duty-card.selected .material-symbols-outlined {
  color: hsl(var(--primary));
}

.duty-card.selected strong {
  color: hsl(var(--primary));
}

.timer-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: linear-gradient(180deg, hsl(var(--primary) / 0.04), hsl(var(--card)));
  border: 1px solid hsl(var(--primary) / 0.18);
  padding: 1rem 1rem 1.25rem;
}

.timer-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0 0.5rem;
  width: 100%;
}

.timer-icon {
  font-size: 36px !important;
  color: hsl(var(--primary));
  margin-bottom: 0.5rem;
  animation: timerPulse 2s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.timer-time {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 2.75rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  letter-spacing: 0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px hsl(var(--primary) / 0.18);
}

.timer-label {
  margin-bottom: 0.625rem;
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 700;
}

.timer-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.875rem 0;
  margin-top: 0.5rem;
  border-top: 1px solid hsl(var(--border));
  border-bottom: 1px solid hsl(var(--border));
}

.timer-meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

.timer-meta-row .material-symbols-outlined {
  font-size: 18px;
  color: hsl(var(--primary));
}

.timer-meta-row strong {
  color: hsl(var(--foreground));
  font-weight: 600;
}

.timer-hint {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.risk-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.risk-tile {
  position: relative;
  cursor: pointer;
}

.risk-tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.risk-tile span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.7rem 0.5rem;
  border: 2px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  transition: all 0.15s ease;
}
.risk-tile span strong {
  font-weight: 700;
  font-size: 0.88rem;
}
.risk-tile span em {
  font-style: normal;
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}
.risk-tile input:checked + span em {
  color: inherit;
  opacity: 0.85;
}

.risk-tile:nth-child(1) input:checked + span {
  background: hsl(142 71% 45% / 0.12);
  border-color: hsl(142 71% 45%);
  color: hsl(142 71% 32%);
}

.risk-tile:nth-child(2) input:checked + span {
  background: hsl(38 92% 50% / 0.15);
  border-color: hsl(38 92% 50%);
  color: hsl(38 92% 35%);
}

.risk-tile:nth-child(3) input:checked + span {
  background: hsl(0 84% 60% / 0.12);
  border-color: hsl(0 84% 60%);
  color: hsl(0 84% 45%);
}

.rating-num {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-weight: 700;
  color: hsl(var(--primary));
  margin-left: 0.25rem;
}

/* =====================================================================
   SPECIAL DUTY — purple mode scope (legacy parity)
   ===================================================================== */
.special-mode {
  --primary: 262 83% 58%;             /* purple #7C3AED */
  --primary-foreground: 0 0% 100%;
}

/* Emergency reason cards (Step 1) */
.emg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.emg-tile {
  position: relative;
  cursor: pointer;
}
.emg-tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.emg-tile span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 0.5rem;
  border: 2px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--card));
  transition: all 0.15s ease;
}
.emg-tile .emg-emoji {
  font-size: 1.5rem;
  margin-bottom: 0.2rem;
}
.emg-tile strong {
  font-weight: 600;
  font-size: 0.88rem;
  color: hsl(var(--foreground));
}
.emg-tile em {
  font-style: normal;
  font-size: 0.7rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.1rem;
}
.emg-tile input:checked + span {
  background: hsl(0 84% 60% / 0.08);
  border-color: hsl(0 84% 60%);
}
.emg-tile input:checked + span strong {
  color: hsl(0 84% 45%);
}

/* Step 2 — Live badge + location card */
.timer-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 0.875rem;
}
.timer-header-text {
  font-size: 1rem;
  font-weight: 700;
  color: hsl(var(--primary));
  line-height: 1.25;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: hsl(0 84% 60% / 0.1);
  border: 1px solid hsl(0 84% 60% / 0.25);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(0 84% 50%);
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: hsl(0 84% 55%);
  position: relative;
}
.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: hsl(0 84% 55%);
  opacity: 0.6;
  animation: liveRing 1.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes liveRing {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(2.4); opacity: 0; }
}

.loc-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: hsl(var(--muted) / 0.4);
  border: 1px solid hsl(var(--border));
  border-radius: 14px;
  padding: 0.75rem 0.875rem;
  width: 100%;
  margin-bottom: 0.875rem;
}
.loc-icon {
  background: hsl(var(--primary) / 0.1);
  padding: 0.5rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loc-icon .material-symbols-outlined {
  color: hsl(var(--primary));
  font-size: 1.4rem !important;
}
.loc-meta {
  flex: 1;
  min-width: 0;
}
.loc-label {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 700;
  margin-bottom: 0.15rem;
}
.loc-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  line-height: 1.3;
  word-break: break-word;
}

/* Onboarding-only "Guard Not Coming?" amber CTA */
.btn-no-show {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  margin-top: 0.875rem;
  background: hsl(38 92% 50% / 0.1);
  border: 1px solid hsl(38 92% 50% / 0.3);
  color: hsl(38 92% 35%);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.btn-no-show:hover { background: hsl(38 92% 50% / 0.18); }

/* Guard Not Coming modal — default hidden; only displayed when [hidden] removed */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9500;
}
.modal-backdrop:not([hidden]) {
  display: flex;
  animation: backdropIn 0.2s ease;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: hsl(var(--card));
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  animation: modalIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  padding: 1.125rem 1.25rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
}
.modal-head h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}
.modal-head p {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}
.modal-body {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.modal-foot {
  display: flex;
  gap: 0.625rem;
  padding: 0.75rem 1.25rem 1.125rem;
  border-top: 1px solid hsl(var(--border));
}
.modal-foot .btn { flex: 1; justify-content: center; }

.reason-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem;
  background: hsl(var(--muted) / 0.3);
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.reason-row:hover { background: hsl(var(--muted) / 0.5); }
.reason-row input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: hsl(var(--primary));
}
.reason-row:has(input:checked) {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.06);
}

.btn-warn {
  background: hsl(38 92% 50%);
  color: white;
  border: none;
  padding: 0.625rem 1rem;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-warn:hover { background: hsl(38 92% 45%); }

/* Destructive confirm action */
.btn-danger {
  background: hsl(0 84% 55%);
  color: white;
}
.btn-danger:hover { background: hsl(0 84% 48%); }
.btn-danger:active { background: hsl(0 84% 42%); transform: scale(0.98); }

/* Reusable confirm dialog */
.confirm-card .modal-head {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
}
.confirm-card .modal-head h3 {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}
.confirm-card .modal-head h3 .material-symbols-outlined {
  font-size: 1.5rem !important;
  color: hsl(0 84% 55%);
  background: hsl(0 84% 55% / 0.1);
  padding: 0.4rem;
  border-radius: 10px;
}
.confirm-card .modal-head p {
  margin: 0;
  font-size: 0.9rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
}
.confirm-card .modal-foot {
  padding: 0.875rem 1.25rem 1rem;
  border-top: 1px solid hsl(var(--border));
}

/* Step 3 — Metric cards header */
.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
}
.metric-card {
  background: hsl(var(--muted) / 0.4);
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  padding: 0.875rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.3rem;
}
.metric-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: hsl(var(--primary) / 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.2rem;
}
.metric-icon .material-symbols-outlined {
  color: hsl(var(--primary));
  font-size: 1.15rem !important;
}
.metric-icon.blue {
  background: hsl(217 91% 60% / 0.12);
}
.metric-icon.blue .material-symbols-outlined {
  color: hsl(217 91% 50%);
}
.metric-label {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  font-weight: 700;
}
.metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  word-break: break-word;
}

/* Step 3 — Risk tile icons */
.risk-tile span .risk-icon {
  font-size: 1.25rem !important;
  margin-bottom: 0.15rem;
}
.risk-low span .risk-icon  { color: hsl(142 71% 40%); }
.risk-med span .risk-icon  { color: hsl(38 92% 50%); }
.risk-high span .risk-icon { color: hsl(0 84% 55%); }

/* Step 3 — Big centered rating below slider */
.rating-big {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--primary));
  margin-top: 0.5rem;
  letter-spacing: 0.05em;
}

/* Step 3 — Dual photo input row + counter */
.photo-dual-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
}
.photo-dual-btn {
  width: 100%;
  justify-content: center;
}
.photo-counter {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.5rem;
}

/* GPS pending / fix / fail badges in the timer card */
.gps-pending {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: hsl(var(--muted-foreground));
}
.gps-dot {
  width: 8px;
  height: 8px;
  background: hsl(var(--primary));
  border-radius: 50%;
  animation: gpsBlink 1.4s ease-in-out infinite;
}
@keyframes gpsBlink {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.15); }
}
.gps-fix {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.78rem;
  color: hsl(142 71% 32%);
}
.gps-fail {
  color: hsl(0 84% 50%);
  font-style: italic;
}

/* Duty summary banner on Stage 3 */
.duty-summary {
  background: linear-gradient(135deg, hsl(var(--primary) / 0.08), hsl(var(--primary) / 0.02));
  border: 1px solid hsl(var(--primary) / 0.2);
  border-radius: var(--radius-xl);
  padding: 0.875rem 1rem;
  box-shadow: var(--shadow-sm);
}
.duty-summary-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.duty-summary-row > .material-symbols-outlined {
  font-size: 28px !important;
  color: hsl(var(--primary));
  flex-shrink: 0;
}
.duty-summary-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}
.duty-summary-text strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}
.duty-summary-text small {
  font-size: 0.78rem;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.duty-summary-time {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  padding: 0.35rem 0.625rem;
  border-radius: 999px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-weight: 600;
  font-size: 0.85rem;
  color: hsl(var(--foreground));
  flex-shrink: 0;
}
.duty-summary-time .material-symbols-outlined {
  font-size: 16px;
  color: hsl(var(--primary));
}

/* ============================================================
   ╔═════════════════════════════════════════════════════════╗
   ║  iOS DIRECTION — overrides applied at the END of file   ║
   ║  Cards become inset grouped lists, buttons become iOS   ║
   ║  tinted/filled, modals become sheets w/ grabber,        ║
   ║  resume card becomes a Live Activity capsule.           ║
   ╚═════════════════════════════════════════════════════════╝
   ============================================================ */

/* Reset some legacy shadows / borders for iOS-flat look */
.card,
.form-card,
.history-card,
.metric-card,
.loc-card,
.duty-summary,
.stat-card,
.tile,
.site-item {
  box-shadow: var(--shadow-sm) !important;
  border: 0;
}

/* ─── iOS top bar: large title pattern ─── */
.site-header {
  background: hsl(var(--page-bg) / 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--hairline);
}
.form-top-bar {
  background: hsl(var(--page-bg) / 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--hairline);
}

/* ─── iOS rounded icon buttons ─── */
.icon-btn {
  background: transparent !important;
  color: hsl(var(--primary));
}
.icon-btn:hover { background: rgba(0, 122, 255, 0.06) !important; }
.icon-btn:active { background: rgba(0, 122, 255, 0.12) !important; transform: scale(0.94); }
.icon-btn .material-symbols-outlined { font-size: 1.5rem; }

/* ─── iOS BUTTONS ─── */
.btn {
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  height: 50px;
  font-size: 17px;
  transition: opacity 150ms, transform 100ms, background 150ms;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: hsl(var(--primary));
  color: white;
}
.btn-primary:hover { background: hsl(var(--primary)); opacity: 0.92; }

.btn-secondary {
  background: rgba(0, 122, 255, 0.1);
  color: hsl(var(--primary));
  border: 0;
}
.btn-secondary:hover { background: rgba(0, 122, 255, 0.16); }

.btn-outline {
  background: rgba(120, 120, 128, 0.12);
  color: hsl(var(--foreground));
  border: 0;
}
.btn-outline:hover { background: rgba(120, 120, 128, 0.18); }

.btn-destructive,
.btn-danger {
  background: hsl(var(--destructive));
  color: white;
}

.btn-warn {
  background: hsl(var(--ios-orange));
  color: white;
  border: 0;
}

.btn-block {
  width: 100%;
  height: 50px;
  font-size: 17px;
}

/* ─── HOME: mode-cards as iOS inset grouped list ─── */
.action-stack {
  margin: 0;
  background: hsl(var(--card));
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.section-h {
  padding: 16px 20px 6px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.section-h h3 {
  font-size: 13px;
  font-weight: 400;
  color: hsl(var(--ios-label-2));
  letter-spacing: 0.02em;
}
.section-h .section-sub { display: none; }

.mode-card {
  background: transparent !important;
  border: 0;
  border-radius: 0;
  padding: 10px 16px !important;
  min-height: 56px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}
.mode-card + .mode-card::before {
  content: "";
  position: absolute; top: 0; left: 60px; right: 0;
  height: 0.5px; background: var(--hairline);
}
.mode-card:active { background: rgba(0, 0, 0, 0.04) !important; }
.mode-card[aria-disabled="true"] { opacity: 0.5; }

.mode-card .mode-icon-box {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: hsl(var(--primary));
  color: white;
  box-shadow: none;
}
.mode-card.special .mode-icon-box  { background: hsl(var(--ios-purple)); }
.mode-card.history .mode-icon-box  { background: hsl(var(--ios-orange)); }
.mode-card.sites   .mode-icon-box  { background: hsl(var(--ios-green)); }
.mode-card .mode-icon-box .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 1, 'wght' 500;
  color: white;
}

.mode-card .mode-text {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.mode-card-title {
  font-size: 16px !important;
  font-weight: 400 !important;
  color: hsl(var(--foreground));
  line-height: 1.3;
  letter-spacing: -0.012em;
}
.mode-card-desc {
  font-size: 13px !important;
  color: hsl(var(--ios-label-2));
  font-weight: 400;
  line-height: 1.3;
}

.mode-chevron {
  flex-shrink: 0;
  color: hsl(var(--ios-label-3));
  display: flex; align-items: center;
}
.mode-chevron .material-symbols-outlined {
  font-size: 18px;
  font-weight: 600;
}

.tag-soon { display: none; }

/* ─── HOME hero greeting card — flat list-style header ─── */
.card-hero {
  background: transparent !important;
  box-shadow: none !important;
  padding: 12px 4px 4px !important;
  margin: 0 !important;
}
.card-hero .greeting-line {
  font-size: 15px;
  color: hsl(var(--ios-label-2));
  margin: 0 0 2px;
  letter-spacing: -0.012em;
}
.card-hero h2 {
  font-size: 28px !important;
  font-weight: 700 !important;
  letter-spacing: -0.022em !important;
  line-height: 1.05;
  margin: 0 0 10px !important;
}
.card-hero .chip-row { gap: 6px; flex-wrap: wrap; }
.card-hero .chip {
  background: hsl(var(--card));
  border: 0;
  box-shadow: 0 0 0 0.5px rgba(60,60,67,0.12);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--ios-label-2));
}

/* ─── Resume card → Live Activity dark capsule ─── */
.resume-card {
  background: linear-gradient(180deg, #1c1c1e, #1a1a1c) !important;
  color: white !important;
  border: 0 !important;
  border-radius: 22px !important;
  padding: 14px !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(255,255,255,0.06) !important;
  animation: none !important;
}
.resume-card .resume-sub {
  color: rgba(255,255,255,0.55) !important;
  font-size: 11px !important;
  letter-spacing: 0.04em !important;
}
.resume-card .resume-title {
  color: white !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}
.resume-card .resume-icon {
  background: hsl(var(--primary)) !important;
}
.resume-card .resume-icon .material-symbols-outlined {
  color: white !important;
  font-variation-settings: 'FILL' 1, 'wght' 600;
  animation: none !important;
}
.resume-card .resume-meta {
  background: rgba(255,255,255,0.08) !important;
  border: 0 !important;
}
.resume-card .resume-meta small {
  color: rgba(255,255,255,0.48) !important;
}
.resume-card .resume-meta strong {
  color: white !important;
}
.resume-card .resume-elapsed {
  color: white !important;
  font-size: 30px !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em !important;
  font-variant-numeric: tabular-nums;
}
.resume-card .resume-actions {
  gap: 6px !important;
}
.resume-card .resume-act {
  height: 40px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
}
.resume-card .btn-secondary {
  background: rgba(255,255,255,0.12) !important;
  color: white !important;
}
.resume-card .btn-primary {
  background: hsl(var(--primary)) !important;
  color: white !important;
}

/* Pulsing live dot in the corner of the live capsule */
.resume-card::before {
  content: "";
  position: absolute;
  top: 14px; right: 14px;
  width: 8px; height: 8px; border-radius: 50%;
  background: hsl(var(--destructive));
  box-shadow: 0 0 10px hsl(var(--destructive));
  animation: ios-pulse 1.4s ease-in-out infinite;
}
@keyframes ios-pulse { 0%,100%{opacity:1}50%{opacity:.4} }

/* ─── Greeting / queue badge as iOS pill ─── */
.queue-badge {
  border-radius: 12px !important;
  background: rgba(255, 149, 0, 0.12) !important;
  color: hsl(var(--ios-orange)) !important;
  border: 0 !important;
}
.queue-badge .material-symbols-outlined { color: hsl(var(--ios-orange)); }

/* ─── Install banner → iOS prompt-style ─── */
.install-banner {
  background: hsl(var(--card)) !important;
  border: 0 !important;
  box-shadow: var(--shadow-md);
  border-radius: 14px !important;
  padding: 12px 14px !important;
}
.install-banner .install-icon {
  background: hsl(var(--primary)) !important;
  border-radius: 9px !important;
}
.install-banner .install-title { color: hsl(var(--foreground)) !important; }
.install-banner .install-desc { color: hsl(var(--ios-label-2)) !important; }
.install-banner .install-btn {
  background: hsl(var(--primary)) !important;
  color: white !important;
}

/* ─── HISTORY filter as iOS segmented control ─── */
.history-filter-row {
  background: rgba(118, 118, 128, 0.12);
  border-radius: 9px;
  padding: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 !important;
  margin: 0 0 14px !important;
  position: sticky;
  top: 8px;
  backdrop-filter: none !important;
}
.history-filter-tab {
  background: transparent !important;
  border: 0 !important;
  border-radius: 7px !important;
  padding: 6px 0 !important;
  min-height: 32px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: hsl(var(--foreground)) !important;
  letter-spacing: -0.01em;
  position: relative;
}
.history-filter-tab.active {
  background: white !important;
  color: hsl(var(--foreground)) !important;
  font-weight: 600 !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08), 0 0 0 0.5px rgba(0,0,0,0.04) !important;
}

/* History cards inside list group look */
.history-list { padding: 0 0 5rem; gap: 0.5rem; }
.history-card {
  border-left: 0 !important;
  border-radius: var(--radius) !important;
  padding: 12px 14px !important;
}
.history-card.is-special::before,
.history-card.is-patrol::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.history-card.is-special::before { background: hsl(var(--ios-purple)); }
.history-card.is-patrol::before  { background: hsl(var(--primary)); }
.type-chip {
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em !important;
  padding: 3px 8px !important;
}
.type-chip.regular {
  background: rgba(0, 122, 255, 0.12) !important;
  color: hsl(var(--primary)) !important;
}
.type-chip.special {
  background: rgba(175, 82, 222, 0.14) !important;
  color: hsl(var(--ios-purple)) !important;
}
.type-chip.emergency {
  background: rgba(255, 59, 48, 0.14) !important;
  color: hsl(var(--destructive)) !important;
}
.history-status {
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em !important;
}
.history-status.normal {
  background: rgba(52, 199, 89, 0.14) !important;
  color: hsl(var(--ios-green)) !important;
}
.history-status.issue {
  background: rgba(255, 149, 0, 0.16) !important;
  color: hsl(var(--ios-orange)) !important;
}

/* ─── Sites screen → iOS list ─── */
.site-item {
  background: hsl(var(--card)) !important;
  border: 0 !important;
  border-radius: var(--radius) !important;
  padding: 12px 14px !important;
}
.site-num {
  background: hsl(var(--primary)) !important;
  color: white !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 7px !important;
  font-size: 12px !important;
}
.site-name { font-size: 15px !important; font-weight: 500 !important; }
.site-route {
  background: rgba(60, 60, 67, 0.08) !important;
  color: hsl(var(--ios-label-2)) !important;
  font-weight: 600 !important;
  font-size: 11px !important;
}

/* ─── Modals → iOS sheet style with grabber ─── */
.modal-card {
  border-radius: 14px !important;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4), 0 0 0 0.5px rgba(0,0,0,0.06) !important;
}
.modal-head {
  padding: 1rem 1.25rem 0.5rem !important;
  border-bottom: 0 !important;
}
.modal-head h3 {
  font-size: 17px !important;
  font-weight: 700 !important;
  letter-spacing: -0.022em !important;
  color: hsl(var(--foreground)) !important;
}
.modal-head h3 .material-symbols-outlined {
  font-size: 1.6rem !important;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}
.modal-head p {
  font-size: 13px !important;
  color: hsl(var(--ios-label-2)) !important;
}
.modal-body {
  padding: 0 1.25rem 1rem !important;
}
.modal-foot {
  padding: 0.625rem 1.25rem 1rem !important;
  border-top: 0.5px solid var(--hairline) !important;
  gap: 0.5rem !important;
}
.modal-foot .btn {
  height: 44px !important;
  font-size: 15px !important;
  border-radius: 12px !important;
}
.confirm-card .modal-head h3 .material-symbols-outlined {
  background: rgba(255,59,48,0.1) !important;
  padding: 0.4rem !important;
  border-radius: 10px !important;
  color: hsl(var(--destructive)) !important;
}
.reason-row {
  background: hsl(var(--page-bg)) !important;
  border: 0 !important;
  border-radius: 12px !important;
  padding: 12px 14px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
}
.reason-row:has(input:checked) {
  background: rgba(0,122,255,0.08) !important;
  border: 0 !important;
}

/* ─── Toast → iOS-style banner notification ─── */
.toast {
  border-radius: 14px !important;
  padding: 10px 14px !important;
  box-shadow: 0 12px 30px rgba(0,0,0,0.2), 0 0 0 0.5px rgba(0,0,0,0.05) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.toast-success { background: rgba(52,199,89,0.95) !important; color: white !important; }
.toast-warn    { background: rgba(255,149,0,0.95) !important; color: white !important; }
.toast-error   { background: rgba(255,59,48,0.95) !important; color: white !important; }
.toast-info    { background: rgba(0,122,255,0.95) !important; color: white !important; }
.toast .material-symbols-outlined { color: white !important; }

/* ─── Stage / form-card polish ─── */
.form-card {
  border-radius: var(--radius) !important;
  padding: 16px !important;
}
.form-card-title {
  font-size: 12px !important;
  letter-spacing: 0.04em !important;
  color: hsl(var(--ios-label-2)) !important;
  margin: 0 0 12px !important;
}
.form-card-title .material-symbols-outlined { color: hsl(var(--primary)) !important; }

/* ─── Inputs → iOS-style ─── */
.input {
  border-radius: 10px !important;
  border: 0 !important;
  background: hsl(var(--page-bg)) !important;
  height: 44px !important;
  font-size: 17px !important;
  padding: 0 14px !important;
}
.input:focus {
  background: white !important;
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.4) !important;
}
textarea.input {
  height: auto !important;
  padding: 12px 14px !important;
  line-height: 1.45;
}

/* ─── Step bottom bars → iOS-blur action bar ─── */
.submit-bar,
.form-bottom-bar {
  background: hsla(var(--page-bg), 0.78) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--hairline) !important;
}
.submit-bar .btn,
.form-bottom-bar .btn { height: 50px !important; font-size: 17px !important; }

/* ─── Special timer card → Live Activity treatment ─── */
.timer-card {
  background: linear-gradient(180deg, #1c1c1e, #1a1a1c) !important;
  border: 0 !important;
  border-radius: 22px !important;
  color: white !important;
  padding: 16px !important;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(255,255,255,0.06) !important;
}
.timer-card .timer-header-text { color: white !important; }
.timer-card .timer-time {
  color: white !important;
  font-size: 56px !important;
  font-weight: 600 !important;
  letter-spacing: -0.04em !important;
  text-shadow: none !important;
  font-variant-numeric: tabular-nums !important;
}
.timer-card .timer-label {
  color: rgba(255,255,255,0.55) !important;
  font-weight: 400;
  letter-spacing: 0.16em !important;
}
.timer-card .timer-meta-row {
  color: rgba(255,255,255,0.7) !important;
}
.timer-card .timer-meta-row strong { color: white !important; }
.timer-card .timer-meta-row .material-symbols-outlined { color: hsl(var(--primary)) !important; }
.timer-card .timer-meta { border-color: rgba(255,255,255,0.12) !important; }
.timer-card .loc-card {
  background: rgba(255,255,255,0.08) !important;
  border: 0 !important;
}
.timer-card .loc-card .loc-icon { background: rgba(0,122,255,0.2) !important; }
.timer-card .loc-card .loc-icon .material-symbols-outlined { color: hsl(var(--primary)) !important; }
.timer-card .loc-card .loc-label { color: rgba(255,255,255,0.55) !important; }
.timer-card .loc-card .loc-value { color: white !important; }
.timer-card .live-badge {
  background: rgba(255,59,48,0.15) !important;
  border: 0 !important;
  color: #FF6961 !important;
}
.timer-card .timer-hint { color: rgba(255,255,255,0.45) !important; }
.timer-card .gps-pending { color: rgba(255,255,255,0.6) !important; }
.timer-card .gps-fix     { color: hsl(var(--ios-green)) !important; }
.timer-card .gps-fail    { color: #FF6961 !important; }

.btn-no-show {
  background: rgba(255,149,0,0.15) !important;
  border: 0 !important;
  color: hsl(var(--ios-orange)) !important;
}

/* ─── Stage 3 metric cards → iOS stat tiles ─── */
.metric-card {
  background: hsl(var(--card)) !important;
  border: 0 !important;
  padding: 14px !important;
}
.metric-icon { background: rgba(0,122,255,0.12) !important; }
.metric-icon .material-symbols-outlined { color: hsl(var(--primary)) !important; }
.metric-icon.blue { background: rgba(88,86,214,0.12) !important; }
.metric-icon.blue .material-symbols-outlined { color: hsl(var(--ios-indigo)) !important; }
.metric-label {
  letter-spacing: 0.04em !important;
  color: hsl(var(--ios-label-2)) !important;
}
.metric-value {
  font-size: 17px !important;
  font-weight: 600 !important;
  letter-spacing: -0.012em !important;
}

/* ─── Risk tiles → iOS-flavored chips ─── */
.risk-tile span {
  border-radius: 12px !important;
  border: 1.5px solid hsl(var(--border)) !important;
}

/* ─── Slider → iOS slider thumb size + rail ─── */
input[type="range"].slider {
  height: 28px;
}
input[type="range"].slider::-webkit-slider-runnable-track {
  height: 4px;
  background: hsl(var(--border));
  border-radius: 99px;
}
input[type="range"].slider::-webkit-slider-thumb {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% !important;
  background: white !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 0 0 0.5px rgba(0,0,0,0.06) !important;
  -webkit-appearance: none;
  margin-top: -12px;
}

/* Scope dropdown to iOS look */
.jt-select-trigger {
  border-radius: 10px !important;
  border: 0 !important;
  background: hsl(var(--page-bg)) !important;
  height: 44px !important;
  font-size: 17px !important;
}
.jt-select-trigger.is-open { background: white !important; box-shadow: 0 0 0 2px hsl(var(--primary) / 0.4) !important; }
.jt-select-panel {
  border-radius: 14px !important;
  box-shadow: 0 12px 28px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(0,0,0,0.06) !important;
}

/* Headline name uses Lao font fallback (Noto Sans Lao stays primary) */
.brand-text { letter-spacing: -0.02em; }
.brand-text .accent { color: hsl(var(--primary)); }
.header-logo {
  background: hsl(var(--primary));
  border-radius: 8px;
}

/* Login screen → cleaner */
.login-card-wrap { box-shadow: var(--shadow-md); border-radius: var(--radius-lg); }

/* Bottom sheet → iOS sheet */
.sheet { border-radius: 14px 14px 0 0 !important; }
.sheet-handle {
  width: 36px !important;
  height: 5px !important;
  background: rgba(60,60,67,0.3) !important;
  border-radius: 999px !important;
}
.sheet-row {
  min-height: 44px;
  padding: 10px 16px !important;
  font-size: 15px !important;
}
.sheet-row .icn { color: hsl(var(--primary)); }
.sheet-row.danger,
.btn-signout {
  color: hsl(var(--destructive)) !important;
}

/* Section labels in sheet → iOS settings style */
.sheet-section-label {
  font-size: 13px !important;
  font-weight: 400 !important;
  letter-spacing: 0.02em !important;
  text-transform: uppercase !important;
  color: hsl(var(--ios-label-2)) !important;
  padding: 10px 16px 4px !important;
}

/* Step progress bar → iOS-style dots / minimal */
.step-progress-title {
  font-size: 16px !important;
  font-weight: 600 !important;
  letter-spacing: -0.012em !important;
}
.step-progress-num {
  font-size: 13px !important;
  color: hsl(var(--ios-label-2)) !important;
  font-weight: 400 !important;
  font-variant-numeric: tabular-nums;
}
.step-bar {
  height: 3px !important;
  background: hsl(var(--ios-gray-2)) !important;
  border-radius: 99px;
}
.step-bar-fill {
  background: hsl(var(--primary)) !important;
  border-radius: 99px;
}

/* Material icons inside iOS list rows: smaller + system color */
.ios-list .material-symbols-outlined { font-size: 22px; }

/* ============================================================
   ╔═════════════════════════════════════════════════════════╗
   ║  NATIVE-FEEL PASS — make it look like an iOS app, not   ║
   ║  a styled webpage: bottom tab bar, large titles, no     ║
   ║  brand chrome, no dashboard accents, edge-to-edge.      ║
   ╚═════════════════════════════════════════════════════════╝
   ============================================================ */

/* App shell holds bottom tab bar room; remove desktop frame look */
.app-shell {
  max-width: 100% !important;
  background: hsl(var(--background));
}

/* ─── Kill the dashboard "border-left primary stripe" on cards ─── */
.card,
.form-card,
.history-card,
.metric-card,
.duty-summary {
  border-left: 0 !important;
}

/* ─── HOME: replace website-style header with iOS large title ─── */
#screen-home .site-header {
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  border-bottom: 0 !important;
  padding: calc(8px + var(--safe-top)) 16px 0 !important;
}
#screen-home .header-container {
  justify-content: flex-end !important;
}
/* Hide the brand block on home — apps don't repeat their name in their nav */
#screen-home .brand-block { display: none !important; }
#screen-home .icon-btn {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  background: hsl(var(--ios-gray-2)) !important;
  color: hsl(var(--foreground)) !important;
  border-radius: 999px !important;
}
#screen-home #netStatus { display: none !important; }

/* Home v6 — 14px gutters + 14px gap rhythm + tab-bar bottom space */
#screen-home .home-main.v6 {
  padding: 14px 14px calc(96px + var(--safe-bottom)) !important;
  gap: 14px !important;
}
#screen-home .card-hero {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 4px 16px 8px !important;
  margin: 0 !important;
}
#screen-home .card-hero .greeting-line {
  font-size: 13px !important;
  font-weight: 500 !important;
  letter-spacing: 0 !important;
  color: hsl(var(--ios-label-2)) !important;
  margin: 0 0 2px 0 !important;
  text-transform: none !important;
}
#screen-home #profileName {
  font-size: 34px !important;
  font-weight: 700 !important;
  letter-spacing: -0.022em !important;
  line-height: 1.1 !important;
  margin: 0 0 12px 0 !important;
  color: hsl(var(--foreground)) !important;
}
#screen-home .card-hero .chip-row {
  gap: 6px !important;
  margin-top: 2px !important;
}
#screen-home .card-hero .chip {
  background: hsl(var(--ios-gray-2)) !important;
  border: 0 !important;
  color: hsl(var(--foreground)) !important;
  font-size: 12px !important;
  padding: 4px 10px !important;
  border-radius: 999px !important;
  font-weight: 500 !important;
}
#screen-home .card-hero .chip .material-symbols-outlined {
  font-size: 14px !important;
  color: hsl(var(--ios-label-2)) !important;
}
#screen-home .card-hero .chip-id {
  background: hsl(var(--primary) / 0.12) !important;
  color: hsl(var(--primary)) !important;
}
#screen-home .card-hero .chip-id .material-symbols-outlined {
  color: hsl(var(--primary)) !important;
}

/* Section heading on home: iOS uppercase "settings" style, edge-aligned */
#screen-home .section-h {
  padding: 24px 32px 6px !important;
  margin: 0 !important;
}
#screen-home .section-h h3 {
  font-size: 12px !important;
  font-weight: 500 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  color: hsl(var(--ios-label-2)) !important;
  margin: 0 !important;
}
#screen-home .section-sub { display: none !important; }

/* Primary actions: two big hero tiles. Patrol and Special Duty are what an
   inspector opens the app for; History and Sites live in the tab bar. */
/* v5-only — v6 home (.action-stack.v6) uses its own column layout */
#screen-home .action-stack.v5 {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 12px !important;
  margin: 0 16px !important;
  padding: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
}
/* Secondary actions: compact full-width list rows below the hero tiles.
   History + Sites are still visible on home (faster than tab bar for a glance),
   just visually de-emphasized — single line, smaller icons, hairline card. */
#screen-home .mode-card.history,
#screen-home .mode-card.sites {
  grid-column: 1 / -1 !important;
  display: grid !important;
  grid-template-columns: 32px 1fr 18px !important;
  grid-template-rows: auto !important;
  align-items: center !important;
  justify-items: stretch !important;
  gap: 12px !important;
  padding: 12px 14px !important;
  min-height: 56px !important;
  background: hsl(var(--card)) !important;
  border-radius: 14px !important;
  box-shadow: 0 0 0 0.5px var(--hairline) !important;
  text-align: left !important;
  transition: transform 100ms cubic-bezier(.4,0,.2,1) !important;
}
/* Tighten the visual gap between the two secondary rows so they read as a pair */
#screen-home .mode-card.sites {
  margin-top: -4px !important;
}
#screen-home .mode-card.history:active,
#screen-home .mode-card.sites:active {
  transform: scale(0.985) !important;
  background: hsl(var(--ios-gray-2)) !important;
}
#screen-home .mode-card.history .mode-icon-box,
#screen-home .mode-card.sites .mode-icon-box {
  width: 32px !important;
  height: 32px !important;
  border-radius: 8px !important;
  margin: 0 !important;
  align-self: center !important;
  background: hsl(var(--ios-orange)) !important;
}
#screen-home .mode-card.sites .mode-icon-box {
  background: hsl(var(--ios-green)) !important;
}
#screen-home .mode-card.history .mode-icon-box .material-symbols-outlined,
#screen-home .mode-card.sites .mode-icon-box .material-symbols-outlined {
  font-size: 18px !important;
}
#screen-home .mode-card.history .mode-card-title,
#screen-home .mode-card.sites .mode-card-title {
  font-size: 15px !important;
  font-weight: 500 !important;
  align-self: center !important;
  letter-spacing: -0.005em !important;
}
#screen-home .mode-card.history .mode-card-desc,
#screen-home .mode-card.sites .mode-card-desc {
  display: none !important;
}
#screen-home .mode-card.history .mode-chevron,
#screen-home .mode-card.sites .mode-chevron {
  display: grid !important;
  place-items: center !important;
  color: hsl(var(--ios-label-3)) !important;
  align-self: center !important;
}
#screen-home .mode-card.history .mode-chevron .material-symbols-outlined,
#screen-home .mode-card.sites .mode-chevron .material-symbols-outlined {
  font-size: 18px !important;
  font-weight: 600 !important;
  color: hsl(var(--ios-label-3)) !important;
}
#screen-home .mode-card {
  background: hsl(var(--card)) !important;
  border: 0 !important;
  border-radius: 22px !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 0 0 0.5px var(--hairline) !important;
  padding: 16px 16px 18px !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: auto 1fr auto !important;
  align-items: stretch !important;
  justify-items: start !important;
  gap: 0 !important;
  position: relative !important;
  width: 100% !important;
  min-height: 148px !important;
  text-align: left !important;
  transition: transform 120ms cubic-bezier(.4,0,.2,1), box-shadow 120ms !important;
  overflow: hidden !important;
}
#screen-home .mode-card::before {
  content: none !important;
}
#screen-home .mode-card:active {
  transform: scale(0.97) !important;
  background: hsl(var(--card)) !important;
}
#screen-home .mode-icon-box {
  width: 44px !important;
  height: 44px !important;
  border-radius: 12px !important;
  display: grid !important;
  place-items: center !important;
  color: white !important;
  box-shadow: none !important;
  margin-bottom: 14px !important;
  align-self: start !important;
}
#screen-home .mode-icon-box .material-symbols-outlined {
  font-size: 26px !important;
  color: white !important;
  font-variation-settings: 'FILL' 1, 'wght' 500 !important;
}
#screen-home .mode-card.patrol .mode-icon-box {
  background: linear-gradient(135deg, hsl(var(--primary)), hsl(211 100% 42%)) !important;
}
#screen-home .mode-card.special .mode-icon-box {
  background: linear-gradient(135deg, hsl(var(--ios-purple)), hsl(285 67% 50%)) !important;
}
#screen-home .mode-card-title {
  font-size: 17px !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em !important;
  color: hsl(var(--foreground)) !important;
  margin: 0 !important;
  line-height: 1.2 !important;
  align-self: end !important;
}
#screen-home .mode-card-desc {
  display: block !important;
  font-size: 12px !important;
  font-weight: 400 !important;
  color: hsl(var(--ios-label-2)) !important;
  margin: 4px 0 0 !important;
  line-height: 1.3 !important;
  letter-spacing: 0 !important;
}
/* Hide chevron on hero tiles — the whole card is the affordance */
#screen-home .mode-chevron {
  display: none !important;
}
/* Section heading above the hero tiles is redundant — the tiles speak for themselves */
#screen-home .section-h { display: none !important; }

/* ============================================================
   STEP 2 — Equipment: HEAD-style section-per-item layout.
   Each item gets its own section with header + accent line and
   two big full-width radio cards (ຄົບຖ້ວນ / ບໍ່ຄົບຖ້ວນ).
   ============================================================ */

/* Strip the wrapper card chrome and use a small uppercase section title */
.stage[data-step="2"] > .form-card {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  border: 0 !important;
}
.stage[data-step="2"] > .form-card > .form-card-title {
  font-size: 12px !important;
  font-weight: 500 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  color: hsl(var(--ios-label-2)) !important;
  padding: 0 16px 12px !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}
.stage[data-step="2"] > .form-card > .form-card-title .material-symbols-outlined {
  font-size: 14px !important;
  color: hsl(var(--ios-label-2)) !important;
}

/* equip-grid → vertical stack of sections (no longer a 2x2 grid) */
.stage[data-step="2"] .equip-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 18px !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
  padding: 0 !important;
}

/* Each cell becomes its own section block */
.stage[data-step="2"] .equip-cell {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  padding: 0 !important;
  min-height: 0 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  position: static !important;
}
.stage[data-step="2"] .equip-cell::before {
  display: none !important;
  content: none !important;
}

/* Section header: icon + bilingual label + horizontal accent line */
.stage[data-step="2"] .equip-cell .equip-label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: hsl(var(--foreground)) !important;
  letter-spacing: -0.005em !important;
  padding: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
  width: 100% !important;
}
.stage[data-step="2"] .equip-cell .equip-label .material-symbols-outlined {
  width: auto !important;
  height: auto !important;
  background: transparent !important;
  border-radius: 0 !important;
  font-size: 16px !important;
  color: hsl(var(--primary)) !important;
}
/* Inline the bilingual label (Lao · English) — drop the <br> */
.stage[data-step="2"] .equip-cell .equip-label > span:last-child br {
  display: none !important;
}
.stage[data-step="2"] .equip-cell .equip-label > span:last-child {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: baseline !important;
  gap: 6px !important;
  white-space: normal !important;
}
.stage[data-step="2"] .equip-cell .equip-label > span:last-child::after {
  display: none;
}
/* Trailing accent hairline after the label */
.stage[data-step="2"] .equip-cell .equip-label::after {
  content: "" !important;
  flex: 1 !important;
  height: 1px !important;
  background: var(--hairline) !important;
  margin-left: 4px !important;
}

/* Two big full-width radio cards per item */
.stage[data-step="2"] .equip-cell .equip-toggle {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 8px !important;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  margin-top: 0 !important;
}
.stage[data-step="2"] .equip-cell label.radio-tile {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 14px 10px !important;
  min-height: 56px !important;
  min-width: 0 !important;
  background: hsl(var(--card)) !important;
  border: 1.5px solid hsl(var(--ios-gray-2)) !important;
  border-radius: 12px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: hsl(var(--foreground)) !important;
  letter-spacing: -0.005em !important;
  box-shadow: none !important;
  transition: all 120ms !important;
}
.stage[data-step="2"] .equip-cell label.radio-tile:active {
  transform: scale(0.985) !important;
}
.stage[data-step="2"] .equip-cell label.radio-tile.yes:has(input:checked) {
  background: hsl(142 71% 45% / 0.10) !important;
  border-color: hsl(142 71% 45%) !important;
  color: hsl(142 71% 28%) !important;
  box-shadow: none !important;
}
.stage[data-step="2"] .equip-cell label.radio-tile.no:has(input:checked) {
  background: hsl(var(--destructive) / 0.10) !important;
  border-color: hsl(var(--destructive)) !important;
  color: hsl(var(--destructive)) !important;
  box-shadow: none !important;
}

/* ============================================================
   STEP 7 — Confirm: iOS Review screen with banner + grouped sections
   ============================================================ */
/* Hide the legacy summary-card chrome — we render our own structure now */
.stage[data-step="7"] .summary-card {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.stage[data-step="7"] .summary-card > h4 {
  display: none !important;
}

/* Top status banner */
.rsum-banner {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  margin: 0 0 18px;
  border: 0;
}
.rsum-banner .material-symbols-outlined {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-variation-settings: 'FILL' 1, 'wght' 500;
  color: white;
}
.rsum-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rsum-banner-text strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
  line-height: 1.2;
}
.rsum-banner-text small {
  font-size: 12px;
  font-weight: 400;
  color: hsl(var(--ios-label-2));
  line-height: 1.3;
}
.rsum-banner.is-normal {
  background: hsl(142 71% 45% / 0.10);
}
.rsum-banner.is-normal .material-symbols-outlined {
  background: linear-gradient(135deg, hsl(142 71% 45%), hsl(142 71% 38%));
}
.rsum-banner.is-issue {
  background: hsl(35 100% 50% / 0.12);
}
.rsum-banner.is-issue .material-symbols-outlined {
  background: linear-gradient(135deg, hsl(35 100% 50%), hsl(35 100% 42%));
}

/* Grouped sections */
.rsum-section { margin-bottom: 22px; }
.rsum-section:last-child { margin-bottom: 8px; }

.rsum-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 6px;
}
.rsum-section-head .material-symbols-outlined {
  font-size: 14px;
  color: hsl(var(--ios-label-2));
  font-variation-settings: 'FILL' 1, 'wght' 500;
}
.rsum-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: hsl(var(--ios-label-2));
}
.rsum-section-sub {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: hsl(var(--ios-label-3));
  margin-left: auto;
}

.rsum-list {
  background: hsl(var(--card));
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--hairline);
}
.rsum-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  position: relative;
  min-height: 52px;
}
.rsum-row + .rsum-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 0;
  height: 0.5px;
  background: var(--hairline);
}
.rsum-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.rsum-lao {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: hsl(var(--foreground));
  line-height: 1.25;
}
.rsum-en {
  font-size: 11px;
  font-weight: 400;
  color: hsl(var(--ios-label-3));
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.rsum-val {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}
.rsum-val.rsum-plain   { color: hsl(var(--foreground)); }
.rsum-val.rsum-ok      { color: hsl(142 71% 35%); }
.rsum-val.rsum-danger  { color: hsl(var(--destructive)); }
.rsum-val.rsum-warn    { color: hsl(35 100% 42%); }
.rsum-val.rsum-missing { color: hsl(var(--ios-label-3)); font-style: italic; }

/* ============================================================
   STEP 2 — Reveal panels (Missing Uniform / Missing Defense)
   The reveal lives INSIDE its own .equip-cell now, so the chips
   appear directly under the radio cards they belong to.
   ============================================================ */
.stage[data-step="2"] .equip-cell .reveal {
  margin-top: 0 !important;
}
.stage[data-step="2"] .reveal .form-card {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin-top: 4px !important;
}
/* Section label above the pills — small uppercase, system red, flush-left
   with the radio cards above it */
.stage[data-step="2"] .reveal .form-card-title {
  font-size: 12px !important;
  font-weight: 500 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  color: hsl(var(--destructive)) !important;
  padding: 0 0 8px !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}
.stage[data-step="2"] .reveal .form-card-title .material-symbols-outlined {
  font-size: 14px !important;
  color: hsl(var(--destructive)) !important;
  display: inline-grid !important;
  width: auto !important;
  height: auto !important;
  background: transparent !important;
  border-radius: 0 !important;
}

/* Wrap-flex of chip pills — no fixed grid, no orphans, flush-left */
.stage[data-step="2"] .checkbox-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  grid-template-columns: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ============================================================
   SITES — make rows tappable + chevron, open Site Detail on tap
   ============================================================ */
.site-item {
  display: grid !important;
  grid-template-columns: 32px 1fr auto 18px !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px 14px !important;
  background: hsl(var(--card)) !important;
  border: 0 !important;
  border-radius: 0 !important;
  width: 100% !important;
  text-align: left !important;
  position: relative !important;
  min-height: 56px !important;
  font-family: inherit !important;
  color: inherit !important;
  cursor: pointer !important;
  transition: background 100ms !important;
}
/* Route tag pill — A is iOS blue, B is iOS purple, AB is teal */
.site-route-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.site-route-a {
  background: hsl(var(--primary) / 0.14);
  color: hsl(var(--primary));
}
.site-route-b {
  background: hsl(var(--ios-purple) / 0.14);
  color: hsl(var(--ios-purple));
}
.site-route-ab {
  background: hsl(174 72% 38% / 0.14);
  color: hsl(174 72% 30%);
}
.site-item + .site-item::before {
  content: "";
  position: absolute;
  top: 0; left: 60px; right: 0;
  height: 0.5px;
  background: var(--hairline);
}
.site-item:active { background: hsl(var(--ios-gray-2)) !important; }
.site-item .site-num {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.site-item .site-name {
  font-size: 15px;
  font-weight: 500;
  color: hsl(var(--foreground));
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-item .site-chev {
  font-size: 18px;
  color: hsl(var(--ios-label-3));
}
/* Wrap consecutive site-items in a single inset card visually */
.sites-list {
  background: hsl(var(--card));
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--hairline);
}

/* ============================================================
   SITE DETAIL — hero, map preview, contacts, SOP
   ============================================================ */
.site-hero {
  background: linear-gradient(160deg, #1c1c1e, #2c2c2e);
  color: #fff;
  margin: 0 0 14px;
  padding: 22px 18px 20px;
  border-radius: 22px;
}
.site-hero-pos {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.site-hero-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.18;
  margin: 0;
}
.site-hero-addr {
  font-size: 13px;
  color: rgba(255,255,255,0.65);
  margin: 6px 0 0;
  line-height: 1.35;
}

/* Map preview tile + Directions CTA */
.site-map-tile {
  height: 200px;
  margin: 0 0 14px;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--hairline);
  background: #e6ecf2;
}
.site-map-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  z-index: 1;
}
/* Fallback only shows when JS toggles it on (e.g. iframe blocked / offline) */
.site-map-fallback {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, transparent 0 14px, rgba(60,60,67,0.04) 14px 28px),
    linear-gradient(180deg, #d6e4f0, #c6d4e6);
  display: none;
  z-index: 0;
}
.site-map-tile.no-iframe .site-map-fallback { display: block; z-index: 1; }
.site-map-tile.no-iframe .site-map-frame { display: none; }
.site-map-pin {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -100%);
  color: hsl(var(--destructive));
  font-size: 36px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
  font-variation-settings: 'FILL' 1, 'wght' 500;
}
.site-map-coords {
  position: absolute;
  bottom: 12px; left: 14px;
  background: rgba(28,28,30,0.85);
  color: #fff;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 11px;
  letter-spacing: -0.005em;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  max-width: calc(100% - 28px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-map-cta {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 2;
  background: rgba(255,255,255,0.96);
  color: hsl(var(--primary));
  padding: 8px 14px 8px 12px;
  border: 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12), 0 0 0 0.5px rgba(0,0,0,0.04);
  transition: transform 100ms;
}
.site-map-cta:active { transform: scale(0.96); }
.site-map-cta .material-symbols-outlined { font-size: 16px; }

/* Section labels above each card on detail */
#screen-site-detail .ios-section-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: hsl(var(--ios-label-2));
  margin: 18px 16px 6px;
}
/* Inset cards (contacts, SOP) */
#screen-site-detail .ios-card {
  background: hsl(var(--card));
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 0.5px var(--hairline);
  margin: 0 0 12px;
}
#screen-site-detail .ios-card .ios-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  position: relative;
  min-height: 56px;
}
#screen-site-detail .ios-card .ios-row + .ios-row::before {
  content: "";
  position: absolute;
  top: 0; left: 58px; right: 0;
  height: 0.5px;
  background: var(--hairline);
}
#screen-site-detail .ios-card .ios-row .icn {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  font-size: 16px;
}
#screen-site-detail .ios-card .ios-row .icn.gray {
  background: hsl(var(--ios-gray-2));
  color: hsl(var(--ios-label-3));
}
#screen-site-detail .ios-card .ios-row .lbl {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
#screen-site-detail .ios-card .ios-row .lbl .top {
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--foreground));
  letter-spacing: -0.005em;
}
#screen-site-detail .ios-card .ios-row .lbl .bot {
  font-size: 11px;
  color: hsl(var(--ios-label-3));
  letter-spacing: 0.005em;
}
/* Empty-state rows look softer */
#screen-site-detail .ios-card .ios-row[data-empty="1"] .lbl .top {
  color: hsl(var(--ios-label-2));
  font-weight: 400;
}

/* SOP row — clickable button that opens the SOP modal */
#screen-site-detail .sop-row {
  width: 100% !important;
  background: transparent !important;
  border: 0 !important;
  text-align: left !important;
  cursor: pointer !important;
  font-family: inherit !important;
  color: inherit !important;
  display: grid !important;
  grid-template-columns: 32px 1fr auto !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 12px 14px !important;
  min-height: 56px !important;
  transition: background 100ms !important;
}
#screen-site-detail .sop-row:active { background: hsl(var(--ios-gray-2)) !important; }
#screen-site-detail .sop-row .bot {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#screen-site-detail .sop-chev {
  font-size: 18px;
  color: hsl(var(--ios-label-3));
}

/* SOP modal — full-text reader */
.sop-modal {
  max-width: 90vw;
  width: 480px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
}
.sop-modal-site {
  font-size: 12px;
  color: hsl(var(--ios-label-2));
  margin: 4px 0 0;
  letter-spacing: 0;
  font-family: inherit;
  font-weight: 400;
}
.sop-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}
.sop-text {
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  color: hsl(var(--foreground));
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  padding: 8px 0 16px;
}

/* Tap-to-call icon button on contact rows */
#screen-site-detail .contact-call {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  display: grid; place-items: center;
  text-decoration: none;
  flex-shrink: 0;
  transition: transform 100ms;
}
#screen-site-detail .contact-call:active {
  transform: scale(0.92);
  background: hsl(var(--primary) / 0.18);
}
#screen-site-detail .contact-call .material-symbols-outlined { font-size: 18px; }

/* Icon tones used by contact rows */
#screen-site-detail .ios-card .ios-row .icn.green {
  background: hsl(var(--ios-green) / 0.12);
  color: hsl(var(--ios-green));
}
#screen-site-detail .ios-card .ios-row .icn.blue {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}
#screen-site-detail .ios-card .ios-row .icn.orange {
  background: hsl(var(--ios-orange) / 0.12);
  color: hsl(var(--ios-orange));
}

/* Hide the existing site-route badge on detail screen — using hero instead */
#screen-site-detail main { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ============================================================
   LANGUAGE PICKER — segmented control in the settings sheet
   ============================================================ */
.lang-seg {
  display: inline-flex;
  background: rgba(60,60,67,0.10);
  padding: 2px;
  border-radius: 8px;
  gap: 2px;
}
.lang-seg .lang-opt {
  padding: 6px 12px;
  min-height: 30px;
  font-size: 12px;
  font-weight: 500;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: hsl(var(--ios-label-2));
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.lang-seg .lang-opt.is-active {
  background: white;
  color: hsl(var(--primary));
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 0 0 0.5px rgba(0,0,0,0.04);
}
.sheet-row-static {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
}
.sheet-row-static .icn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: hsl(var(--ios-gray-2));
  display: grid; place-items: center;
  color: hsl(var(--primary));
}
.sheet-row-static .lbl {
  display: flex; flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}
.sheet-row-static .lbl > span:first-child {
  font-size: 14px; font-weight: 500;
  color: hsl(var(--foreground));
}
.sheet-row-static .lbl-sub {
  font-size: 11px;
  color: hsl(var(--ios-label-3));
}

.stage[data-step="2"] .checkbox-tile {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 8px 14px !important;
  min-height: 36px !important;
  border-radius: 999px !important;
  border: 0 !important;
  background: hsl(var(--ios-gray-2)) !important;
  color: hsl(var(--foreground)) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  letter-spacing: -0.005em !important;
  transition: background 120ms, color 120ms, transform 100ms !important;
  cursor: pointer !important;
  user-select: none !important;
  white-space: nowrap !important;
}
.stage[data-step="2"] .checkbox-tile:active {
  transform: scale(0.96) !important;
}
.stage[data-step="2"] .checkbox-tile:has(input:checked) {
  background: hsl(var(--destructive)) !important;
  color: white !important;
  border: 0 !important;
}
.stage[data-step="2"] .checkbox-tile .emoji {
  font-size: 14px !important;
  line-height: 1 !important;
  flex: none !important;
}

/* Resume / install / queue badge: inset, no full-width edge */
#screen-home .queue-badge,
#screen-home .install-banner,
#screen-home .resume-card {
  margin-left: 16px !important;
  margin-right: 16px !important;
}

/* ─── BOTTOM TAB BAR ─── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: hsl(var(--page-bg) / 0.82);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border-top: 0.5px solid var(--hairline);
  padding: 6px 0 calc(6px + var(--safe-bottom));
  z-index: 90;
}
.tab-bar[hidden] { display: none; }
.tab-item {
  background: transparent;
  border: 0;
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 4px 0 2px;
  color: hsl(var(--ios-label-3));
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 100ms;
}
.tab-item .material-symbols-outlined {
  font-size: 24px;
  font-variation-settings: 'FILL' 0, 'wght' 400;
  transition: font-variation-settings 120ms, transform 120ms;
}
.tab-item .tab-label {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.tab-item.is-active {
  color: hsl(var(--primary));
}
.tab-item.is-active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 500;
  transform: scale(1.04);
}
.tab-item:active {
  transform: scale(0.92);
}

/* History / Sites screens: pad bottom for tab bar */
#screen-history .history-main,
#screen-sites main {
  padding-bottom: calc(96px + var(--safe-bottom)) !important;
}

/* History + Sites: also strip the brand-block on their headers */
#screen-history .brand-block,
#screen-sites .brand-block {
  display: none !important;
}
#screen-history .site-header,
#screen-sites .site-header {
  padding: calc(8px + var(--safe-top)) 16px 0 !important;
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  border-bottom: 0 !important;
}
#screen-history .header-container,
#screen-sites .header-container {
  justify-content: space-between !important;
}
/* Inject a screen title via the netStatus slot — actually use a pseudo-element */
#screen-history .header-container::before {
  content: "ປະຫວັດ";
  font-size: 17px;
  font-weight: 600;
  color: hsl(var(--foreground));
  letter-spacing: -0.01em;
}
#screen-sites .header-container::before {
  content: "ສະຖານທີ່";
  font-size: 17px;
  font-weight: 600;
  color: hsl(var(--foreground));
  letter-spacing: -0.01em;
}
#screen-history #netStatus,
#screen-sites #netStatus {
  display: none !important;
}

/* Form + Special screens: hide tab bar (they have their own back chevron).
 * NOTE: `~` is a *general* sibling combinator — it doesn't care whether
 * the screen is currently visible, only that it exists earlier in the DOM.
 * Both #screen-patrol-form and #screen-special are always in the DOM, so
 * the naive selector below would always match and hide the tab bar
 * everywhere. Gate on :not(.hidden) so the rule only fires when a form
 * screen is actually the visible one.
 */
#screen-patrol-form:not(.hidden) ~ .tab-bar,
#screen-special:not(.hidden) ~ .tab-bar {
  display: none !important;
}

/* Login screen: also strip dashboard look — full-bleed */
#screen-login {
  background: hsl(var(--background));
}
#screen-login .card.login-card-wrap {
  border-left: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* ─── LAST-PATROL CARD (Site Detail) ─── */
.last-patrol-card {
  margin: 0 14px 10px;
  padding: 13px 14px;
  background: hsl(var(--primary) / 0.06);
  border: 0.5px solid hsl(var(--primary) / 0.24);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
}
.last-patrol-card[hidden] { display: none; }
.last-patrol-card .lp-icn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: hsl(var(--primary) / 0.14);
  color: hsl(var(--primary));
  display: grid; place-items: center;
  flex: none;
}
.last-patrol-card .lp-icn .material-symbols-outlined {
  font-size: 19px;
  font-variation-settings: 'FILL' 1;
}
.last-patrol-card .lp-body { flex: 1; min-width: 0; }
.last-patrol-card .lp-ttl {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.005em;
  color: hsl(var(--foreground));
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: baseline;
}
.last-patrol-card .lp-ago {
  font-size: 11px;
  font-weight: 500;
  color: hsl(var(--ios-label-3));
}
.last-patrol-card .lp-sub {
  font-size: 11px;
  color: hsl(var(--ios-label-2));
  margin-top: 2px;
  line-height: 1.4;
}
.last-patrol-card .lp-micro {
  margin-top: 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 10px;
  color: hsl(var(--ios-label-2));
}
.last-patrol-card .lp-micro span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
}
.last-patrol-card .lp-micro .material-symbols-outlined {
  font-size: 12px;
  color: hsl(var(--ios-label-3));
}
.last-patrol-card .lp-chev {
  font-size: 18px;
  color: hsl(var(--ios-label-3));
  flex: none;
}

/* ============================================================
   Top bar for tab-rooted pages (History / Sites / Plan)
   No back button — bottom tab bar handles navigation.
   ============================================================ */
.page-top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(0.75rem + var(--safe-top)) 18px 0.75rem;
  background: hsl(var(--page-bg) / 0.85);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 0.5px solid var(--hairline);
}
.page-top-bar .page-title {
  flex: 1;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.15;
}
.page-top-bar .page-meta {
  font-size: 12px;
  color: hsl(var(--ios-label-3));
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

/* Plan screen: cards manage their own 16px gutters, so zero the
   form-main side padding to avoid a doubled 32px gutter. */
#screen-plan .form-main {
  padding-left: 0;
  padding-right: 0;
}

/* ============================================================
   LIVE ACTIVITY capsule — pinned to top of every tab-rooted screen
   when a Special Duty is in flight. Tap once to expand the actions
   tray (Continue / Cancel). Tap again or outside to collapse.
   ============================================================ */
.live-capsule {
  position: fixed;
  top: calc(var(--safe-top, 0px) + 8px);
  left: 12px;
  right: 12px;
  z-index: 95;
  background: linear-gradient(135deg, #1c1c1e 0%, #0f0f10 100%);
  color: #fff;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 10px 28px -10px rgba(0,0,0,0.55),
    0 4px 10px -4px rgba(0,0,0,0.35),
    inset 0 0 0 1px rgba(255,255,255,0.08);
  width: auto;
  max-width: calc(100vw - 24px);
  margin: 0 auto;
  animation: lc-slide-in .35s cubic-bezier(.4,0,.2,1);
  transition: border-radius .25s ease, box-shadow .25s ease;
}
.live-capsule[hidden] { display: none !important; }
@keyframes lc-slide-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: none; }
}

/* Compact pill rendering when collapsed */
.live-capsule:not(.is-expanded) {
  border-radius: 999px;
}
.live-capsule:not(.is-expanded) .lc-actions {
  display: none;
}
.live-capsule.is-expanded {
  box-shadow:
    0 20px 50px -16px rgba(0,0,0,0.7),
    0 6px 14px -6px rgba(0,0,0,0.4),
    inset 0 0 0 1px rgba(255,255,255,0.10);
}

/* === HEAD (clickable trigger) === */
.live-capsule .lc-head {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 8px 14px 8px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: 100%;
  transition: transform .15s ease;
}
.live-capsule .lc-head:active { transform: scale(0.985); }

.live-capsule .lc-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF9500, #FF3B30);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px -2px rgba(255,59,48,.45);
}
.live-capsule .lc-icon-wrap .material-symbols-outlined {
  font-size: 18px;
  color: #fff;
  font-variation-settings: 'FILL' 1;
}

.live-capsule .lc-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1.15;
}
.live-capsule .lc-label {
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.72);
  letter-spacing: -.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-capsule .lc-clock {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.live-capsule .lc-chev {
  color: rgba(255,255,255,0.55);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.live-capsule .lc-chev .material-symbols-outlined { font-size: 18px; }
.live-capsule.is-expanded .lc-chev { transform: rotate(180deg); }

.live-capsule .lc-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #FF3B30;
  flex-shrink: 0;
  margin-right: 4px;
  position: relative;
}
.live-capsule .lc-pulse::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: rgba(255,59,48,0.35);
  animation: lc-pulse 1.6s ease-in-out infinite;
}
@keyframes lc-pulse {
  0%   { transform: scale(0.8); opacity: 0.8; }
  70%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(0.8); opacity: 0; }
}

/* === EXPANDED ACTIONS TRAY === */
.live-capsule .lc-actions {
  display: flex;
  gap: 8px;
  padding: 4px 12px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  animation: lc-tray-in .25s cubic-bezier(.4,0,.2,1);
}
@keyframes lc-tray-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.live-capsule .lc-act {
  flex: 1;
  appearance: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.005em;
  transition: transform .15s ease, opacity .15s ease;
}
.live-capsule .lc-act:active { transform: scale(0.97); }
.live-capsule .lc-act .material-symbols-outlined { font-size: 16px; }
.live-capsule .lc-cancel {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.95);
}
.live-capsule .lc-continue {
  background: #fff;
  color: #FF3B30;
  box-shadow: 0 4px 12px -4px rgba(255,255,255,.25);
}

/* Scrim — invisible but catches taps to collapse the capsule */
.lc-scrim {
  position: fixed;
  inset: 0;
  z-index: 94;
  background: transparent;
  cursor: pointer;
}
.lc-scrim[hidden] { display: none !important; }

/* Push tab-rooted page content down so the capsule doesn't overlap titles. */
body.has-live-capsule .page-top-bar {
  padding-top: calc(var(--safe-top, 0px) + 0.75rem + 56px);
}
body.has-live-capsule #screen-home .site-header {
  padding-top: calc(var(--safe-top, 0px) + 56px);
}
body.has-live-capsule #screen-home .home-main {
  padding-top: 4px;
}

/* ============================================================
   MY PLAN page — tracking-only PatrolPlans view
   Density rules: 40px compact rows · status-grouped · tap-to-expand
   Privacy: other shifts are summary-only, never expandable.
   ============================================================ */
.plan-scope {
  display: inline-flex;
  background: rgba(120,120,128,0.16);
  padding: 2px;
  border-radius: 9px;
  margin: 8px 16px 4px;
  font-size: 13px;
  font-weight: 600;
}
.plan-scope-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px 18px;
  border-radius: 7px;
  color: hsl(var(--ios-label-2));
  font: inherit;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.plan-scope-btn.is-active {
  background: #fff;
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 0 rgba(0,0,0,.04);
}

.plan-banner {
  margin: 10px 16px 0;
  padding: 8px 12px;
  background: linear-gradient(90deg, hsl(var(--primary) / 0.10), hsl(var(--primary) / 0.04));
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: hsl(var(--primary));
  letter-spacing: .04em;
  text-transform: uppercase;
}
.plan-banner .material-symbols-outlined { font-size: 14px; }

.plan-section-header {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: hsl(var(--ios-label-3));
  padding: 14px 22px 6px;
}

/* Hero card — shift summary with progress + pills */
.plan-hero {
  margin: 10px 16px 0;
  padding: 18px 18px 16px;
  background: hsl(var(--card));
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 14px -6px rgba(0,0,0,.06);
}
.plan-hero-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.plan-hero-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px -2px rgba(0,0,0,.12);
}
.plan-hero-icon .material-symbols-outlined {
  font-size: 24px;
  font-variation-settings: 'FILL' 1;
}
.plan-hero-icon.shift-morning { background: linear-gradient(135deg, #FFB45C, #FF9500); }
.plan-hero-icon.shift-evening { background: linear-gradient(135deg, #5AC8FA, #007AFF); }
.plan-hero-icon.shift-night   { background: linear-gradient(135deg, #C781F0, #AF52DE); }

.plan-hero-meta { flex: 1; min-width: 0; }
.plan-hero-name {
  font-size: 17px;
  font-weight: 700;
  color: hsl(var(--foreground));
  letter-spacing: -.01em;
  line-height: 1.2;
}
.plan-hero-sub  {
  font-size: 12.5px;
  color: hsl(var(--ios-label-3));
  margin-top: 3px;
  font-weight: 500;
}
.plan-hero-ratio { text-align: right; flex-shrink: 0; }
.plan-hero-ratio .big {
  font-weight: 800;
  font-size: 28px;
  color: hsl(var(--foreground));
  line-height: 1;
  letter-spacing: -.02em;
}
.plan-hero-ratio .pct {
  font-size: 11px;
  color: hsl(var(--ios-label-3));
  margin-top: 3px;
  font-weight: 600;
}

.plan-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 14px;
  background: rgba(0,0,0,0.05);
}
.plan-bar > span { height: 100%; }
.plan-bar .seg-v { background: hsl(var(--ios-green)); }
.plan-bar .seg-m { background: hsl(var(--destructive)); }
.plan-bar .seg-p { background: hsl(var(--ios-orange)); }
.plan-bar .seg-o { background: hsl(var(--ios-label-3)); }

.plan-pills {
  display: flex;
  gap: 6px;
  margin-top: 11px;
  flex-wrap: wrap;
}
.plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}
.plan-pill .material-symbols-outlined {
  font-size: 13px;
  font-variation-settings: 'FILL' 1;
}
.plan-pill.v { background: hsl(var(--ios-green) / 0.12);   color: #1a7a3a; }
.plan-pill.m { background: hsl(var(--destructive) / 0.12); color: #b91d12; }
.plan-pill.p { background: hsl(var(--ios-orange) / 0.14);  color: #9a5a00; }
.plan-pill.o { background: rgba(142,142,147,0.18);         color: #3a3a3c; }

/* Filter pills — quick scope by status */
.plan-filter {
  display: flex;
  gap: 6px;
  margin: 14px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.plan-filter::-webkit-scrollbar { display: none; }
.plan-filter-tab {
  appearance: none;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--ios-label-2));
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  scroll-snap-align: start;
  transition: background .15s, color .15s, border-color .15s, transform .12s;
}
.plan-filter-tab:active { transform: scale(0.96); }
.plan-filter-tab .ct {
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(0,0,0,0.06);
  color: hsl(var(--ios-label-3));
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: center;
}
.plan-filter-tab.is-active {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  border-color: hsl(var(--foreground));
}
.plan-filter-tab.is-active .ct {
  background: rgba(255,255,255,0.18);
  color: hsl(var(--background));
}

.plan-filter-empty {
  margin: 24px 16px;
  padding: 24px 16px;
  background: hsl(var(--card));
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: hsl(var(--ios-label-3));
  font-size: 13px;
  font-weight: 500;
}
.plan-filter-empty .material-symbols-outlined {
  font-size: 32px;
  color: hsl(var(--ios-label-4, 240 4% 70%));
}

/* Group header */
.plan-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.plan-group-head .left { display: flex; align-items: center; gap: 6px; }
.plan-group-head .left .material-symbols-outlined { font-size: 14px; }
.plan-group-head.missed   { color: #b91d12; }
.plan-group-head.pending  { color: #9a5a00; }
.plan-group-head.visited  { color: #1a7a3a; }
.plan-group-head.off      { color: #3a3a3c; }
.plan-group-head .count {
  background: rgba(0,0,0,0.06);
  color: hsl(var(--ios-label-2));
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
}

/* Mini-card row list — each row is its own card */
.plan-list {
  margin: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 0;
  min-height: 56px;
  background: hsl(var(--card));
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  width: 100%;
  appearance: none;
  text-align: left;
  font: inherit;
  color: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: transform .12s ease, box-shadow .15s ease, background .15s;
  overflow: hidden;
}
.plan-row:active {
  transform: scale(0.985);
  background: rgba(0,0,0,0.02);
}
.plan-row .strip {
  width: 4px;
  align-self: stretch;
  flex-shrink: 0;
  min-height: 56px;
}
.plan-row.r-v .strip { background: hsl(var(--ios-green)); }
.plan-row.r-m .strip { background: hsl(var(--destructive)); }
.plan-row.r-p .strip { background: hsl(var(--ios-orange)); }
.plan-row.r-o .strip { background: hsl(var(--ios-label-3)); }
.plan-row .sc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.plan-row .sc .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 1;
  color: #fff;
}
.plan-row.r-v .sc { background: hsl(var(--ios-green)); }
.plan-row.r-m .sc { background: hsl(var(--destructive)); }
.plan-row.r-p .sc { background: hsl(var(--ios-orange)); }
.plan-row.r-o .sc { background: hsl(var(--ios-label-3)); }
.plan-row .body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan-row .nm {
  font-size: 14.5px;
  font-weight: 600;
  color: hsl(var(--foreground));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.plan-row .sub {
  font-size: 11.5px;
  color: hsl(var(--ios-label-3));
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-row .sub .material-symbols-outlined { font-size: 12px; }
.plan-row .sub .dot { width: 2px; height: 2px; background: currentColor; border-radius: 50%; opacity: .5; }
.plan-row .sub-insp {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: hsl(var(--ios-label-2));
  font-weight: 600;
}
.plan-row .sub-insp .material-symbols-outlined { font-size: 12px; }
.plan-row .mt {
  font-size: 11.5px;
  color: hsl(var(--ios-label-3));
  font-weight: 600;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.plan-row .rt {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
  align-self: flex-start;
}
.plan-row .rt.A { background: hsl(var(--primary) / 0.12);   color: hsl(var(--primary)); }
.plan-row .rt.B { background: hsl(var(--ios-pink) / 0.14);  color: hsl(var(--ios-pink)); }
.plan-row .cv {
  color: hsl(var(--ios-label-3));
  flex-shrink: 0;
  transition: transform .2s;
  display: flex;
  align-items: center;
}
.plan-row .cv .material-symbols-outlined { font-size: 18px; }

/* Expanded inline detail */
.plan-row.is-expanded {
  flex-direction: column;
  align-items: stretch;
  background: hsl(var(--card));
  padding: 0;
  border: 1px solid hsl(var(--ios-green) / 0.25);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 18px -8px hsl(var(--ios-green) / 0.20);
}
.plan-row.is-expanded .plan-row-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px 14px 12px 0;
}
.plan-row.is-expanded .cv { transform: rotate(90deg); color: hsl(var(--primary)); }

.plan-expand {
  padding: 8px 14px 12px;
  border-top: 1px solid var(--hairline);
  background: hsl(var(--card));
}
.plan-data-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 9px;
}
.plan-data-cell {
  background: rgba(0,0,0,0.03);
  border-radius: 8px;
  padding: 7px 9px;
}
.plan-data-cell .lbl {
  font-size: 9.5px;
  font-weight: 600;
  color: hsl(var(--ios-label-3));
  text-transform: uppercase;
  letter-spacing: .04em;
}
.plan-data-cell .val {
  font-size: 13px;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin-top: 1px;
}
.plan-data-cell .val.green { color: #1a7a3a; }

/* Other-shift summary card (NOT expandable — privacy rule) */
.plan-other {
  margin: 8px 16px 0;
  background: hsl(var(--card));
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  overflow: hidden;
  cursor: default;
}
.plan-other-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
}
.plan-other-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.plan-other-icon .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 1;
}
.plan-other-icon.shift-morning { background: linear-gradient(135deg, #FFB45C, #FF9500); }
.plan-other-icon.shift-evening { background: linear-gradient(135deg, #5AC8FA, #007AFF); }
.plan-other-icon.shift-night   { background: linear-gradient(135deg, #C781F0, #AF52DE); }

.plan-other-meta { flex: 1; min-width: 0; }
.plan-other-meta .nm {
  font-size: 13.5px;
  font-weight: 700;
  color: hsl(var(--foreground));
  letter-spacing: -.005em;
}
.plan-other-meta .ii {
  font-size: 11px;
  color: hsl(var(--ios-label-3));
  font-weight: 500;
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-other-meta .ii .material-symbols-outlined { font-size: 11px; }

.plan-other-ratio { text-align: right; flex-shrink: 0; }
.plan-other-ratio .big {
  font-weight: 700;
  font-size: 18px;
  color: hsl(var(--foreground));
  line-height: 1;
}
.plan-other-ratio .pct {
  font-size: 10px;
  color: hsl(var(--ios-label-3));
  font-weight: 600;
  margin-top: 2px;
}

.plan-other-bar { padding: 0 12px 11px; }
.plan-other-bar .plan-bar { margin-top: 0; }
.plan-other-stats {
  display: flex;
  gap: 6px;
  padding: 0 12px 11px;
  flex-wrap: wrap;
}

/* ============================================================
   PROFILE PAGE — full-page replacement for the bottom-sheet.
   Hero (identity + level) → Stats grid → Activity heatmap →
   Settings → About + Sign out.
   ============================================================ */

#screen-profile .form-main {
  padding: 0 16px calc(7rem + var(--safe-bottom));
}
#screen-profile .profile-hero { margin: 0 0 12px; }
#screen-profile .profile-stats-grid { padding: 0; margin: 0 0 16px; }
#screen-profile .profile-heatmap-card,
#screen-profile .profile-settings-card { margin: 0 0 16px; }
#screen-profile .section-h { padding: 0; }
#screen-profile .profile-signout-row { padding: 4px 0 32px; }

/* ----- Hero ----- */
.profile-hero {
  border-radius: 16px;
  padding: 18px 16px 16px;
  margin: 12px 16px 8px;
  background: linear-gradient(135deg, hsl(var(--primary) / 0.92), hsl(var(--ios-indigo) / 0.92));
  color: white;
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.18);
  position: relative;
  overflow: hidden;
}
.profile-hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -25%;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}
.profile-hero-row {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.profile-hero-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
}
.profile-hero-meta { flex: 1; min-width: 0; }
.profile-hero-name {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 2px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-hero-id {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.02em;
}
.profile-on-duty-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: hsl(var(--ios-green) / 0.95);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.profile-on-duty-chip .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
  animation: profile-pulse 1.6s ease-in-out infinite;
}
@keyframes profile-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1); }
}

.profile-level-card {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}
.profile-level-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.profile-level-badge {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  border-radius: 8px;
  background: white;
  color: hsl(var(--primary));
  flex-shrink: 0;
}
.profile-level-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.profile-level-title { font-size: 13px; font-weight: 600; }
.profile-level-sub   { font-size: 11px; color: rgba(255, 255, 255, 0.78); margin-top: 1px; }
.profile-level-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}
.profile-level-fill {
  height: 100%;
  background: white;
  border-radius: 4px;
  transition: width 360ms ease;
}

.profile-hero-chips {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.profile-hero-chips .chip {
  background: rgba(255, 255, 255, 0.18);
  color: white;
  border: 0;
}
.profile-hero-chips .chip .material-symbols-outlined { color: white; }

/* ----- Stats grid ----- */
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 16px;
  margin-bottom: 16px;
}
.stat-tile {
  background: hsl(var(--card));
  border-radius: 12px;
  padding: 12px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  border: 0.5px solid hsl(var(--hairline));
  min-height: 90px;
}
.stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: hsl(var(--primary) / 0.10);
  color: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.stat-tile[data-stat="quality"]  .stat-icon { background: hsl(var(--ios-orange) / 0.12); color: hsl(var(--ios-orange)); }
.stat-tile[data-stat="issues"]   .stat-icon { background: hsl(var(--destructive) / 0.10); color: hsl(var(--destructive)); }
.stat-tile[data-stat="duration"] .stat-icon { background: hsl(var(--ios-purple) / 0.12); color: hsl(var(--ios-purple)); }
.stat-tile[data-stat="sites"]    .stat-icon { background: hsl(var(--ios-green) / 0.12); color: hsl(var(--ios-green)); }
.stat-tile[data-stat="patrolsMonth"] .stat-icon { background: hsl(var(--ios-indigo) / 0.12); color: hsl(var(--ios-indigo)); }
.stat-icon .material-symbols-outlined { font-size: 16px; }
.stat-label {
  font-size: 10.5px;
  color: hsl(var(--ios-label-2));
  font-weight: 500;
  line-height: 1.25;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: hsl(var(--foreground));
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}
.stat-delta {
  font-size: 10px;
  color: hsl(var(--ios-label-3));
  font-weight: 600;
  margin-top: auto;
}
.stat-delta.is-up   { color: hsl(var(--ios-green)); }
.stat-delta.is-down { color: hsl(var(--destructive)); }

/* ----- Activity heatmap ----- */
.profile-heatmap-card {
  background: hsl(var(--card));
  border: 0.5px solid hsl(var(--hairline));
  border-radius: 14px;
  margin: 0 16px 16px;
  padding: 14px 14px 12px;
}
/* GitHub-style scaffold: month labels above, day labels at left, square cells. */
.profile-heatmap-months {
  display: grid;
  grid-template-columns: 18px repeat(8, 1fr);
  font-size: 9.5px;
  font-weight: 600;
  color: hsl(var(--ios-label-3));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  line-height: 1;
}
.profile-heatmap-months > span { padding-left: 1px; }
.profile-heatmap-wrap {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 4px;
}
.profile-heatmap-days {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  gap: 3px;
  font-size: 9.5px;
  color: hsl(var(--ios-label-3));
  text-transform: uppercase;
  font-weight: 600;
  line-height: 1;
}
.profile-heatmap-days > span {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.profile-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 3px;
  aspect-ratio: 8 / 7;
  margin-bottom: 12px;
}
.hm-cell {
  border-radius: 2.5px;
  background: hsl(var(--ios-gray));
  min-width: 0;
  min-height: 0;
}
.hm-cell.l1 { background: hsl(var(--primary) / 0.22); }
.hm-cell.l2 { background: hsl(var(--primary) / 0.45); }
.hm-cell.l3 { background: hsl(var(--primary) / 0.70); }
.hm-cell.l4 { background: hsl(var(--primary) / 0.95); }
.hm-cell.is-today {
  outline: 1.5px solid hsl(var(--ios-orange));
  outline-offset: -1px;
}
.hm-cell.is-future {
  background: hsl(var(--ios-gray) / 0.40);
}
.profile-heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  color: hsl(var(--ios-label-3));
}
.hl-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
}
.hl-cell.hl-l0 { background: hsl(var(--ios-gray)); }
.hl-cell.hl-l1 { background: hsl(var(--primary) / 0.20); }
.hl-cell.hl-l2 { background: hsl(var(--primary) / 0.40); }
.hl-cell.hl-l3 { background: hsl(var(--primary) / 0.65); }
.hl-cell.hl-l4 { background: hsl(var(--primary) / 0.95); }
.hl-label { padding: 0 4px; }

/* ----- Settings + About cards ----- */
.profile-settings-card {
  background: hsl(var(--card));
  border: 0.5px solid hsl(var(--hairline));
  border-radius: 14px;
  margin: 0 16px 16px;
  overflow: hidden;
}
.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
  border: 0;
  background: transparent;
  width: 100%;
  cursor: pointer;
  border-bottom: 0.5px solid hsl(var(--hairline));
}
.profile-row:last-child { border-bottom: 0; }
.profile-row.profile-row-static { cursor: default; }
.profile-row[hidden] { display: none; }
.profile-row[disabled] { opacity: 0.55; cursor: not-allowed; }
.profile-row:not([disabled]):not(.profile-row-static):active { background: hsl(var(--ios-gray)); }
.profile-row .icn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: hsl(var(--ios-gray-2));
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-row .icn .material-symbols-outlined { font-size: 18px; }
.profile-row .lbl {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--foreground));
  min-width: 0;
}
.profile-row .lbl-sub {
  font-size: 11px;
  color: hsl(var(--ios-label-3));
  font-weight: 400;
  margin-top: 2px;
}
.profile-row .meta {
  font-size: 12px;
  color: hsl(var(--ios-label-3));
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* iOS-style toggle */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: hsl(var(--ios-gray-2));
  border-radius: 999px;
  transition: background 200ms;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 27px;
  height: 27px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 200ms;
}
.toggle-switch input:checked + .toggle-slider {
  background: hsl(var(--ios-green));
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}
/* Disabled state - browser blocked / unsupported / mid-request. The user
   can see the toggle exists but can't operate it. */
.toggle-switch.disabled,
.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.45;
  cursor: not-allowed;
}
.toggle-switch input:disabled + .toggle-slider {
  pointer-events: none;
}

/* Sign out — outlined / demoted */
.profile-signout-row {
  padding: 4px 16px 32px;
}
.btn-signout-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  background: transparent;
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.30);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms;
}
.btn-signout-outline:active { background: hsl(var(--destructive) / 0.08); }
.btn-signout-outline .material-symbols-outlined { font-size: 18px; }


/* =================================================================
   HOME v5 — bell, greeting strip, weather hero, pre-shift banner,
   upgraded action cards. Overrides earlier `.card-hero`,
   `.action-stack`, `.mode-card` patterns when v5 markup is present.
   ================================================================= */

/* Header right cluster — net status pill + bell button */
.site-header .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bell-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: hsl(var(--ios-fill-3, 240 6% 95%));
  display: grid;
  place-items: center;
  color: hsl(var(--foreground));
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.15s ease;
}
.bell-btn:hover  { transform: scale(1.06); background: hsl(var(--ios-fill-2, 240 6% 92%)); }
.bell-btn:active { transform: scale(0.96); }
.bell-btn .material-symbols-outlined { font-size: 20px; }
.bell-badge {
  position: absolute;
  top: -2px;
  right: -3px;
  background: #FF453A;
  color: #fff;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 9px;
  border: 2px solid #fff;
  line-height: 1;
  min-width: 18px;
  text-align: center;
  letter-spacing: 0;
}
.bell-badge.zero { display: none; }

/* Pre-shift weather banner — fires at T-15 (hidden until shift schedule
   is wired; markup ready for backend). Severity tinting via CSS vars. */
.preshift {
  --ws-from: #DBEAFE;
  --ws-to:   #FFFFFF;
  --ws-bd:   #7AB8FF;
  --ws-ic:   #3B82F6;
  background: linear-gradient(135deg, var(--ws-from) 0%, var(--ws-to) 100%);
  border: 1.5px solid var(--ws-bd);
  border-radius: 13px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: preshiftSlide 0.4s ease;
}
@keyframes preshiftSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.preshift-ic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--ws-ic);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 800;
}
.preshift-body { flex: 1; min-width: 0; }
.preshift-t {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: hsl(var(--foreground));
  line-height: 1.2;
}
.preshift-lao {
  font-size: 11px;
  color: hsl(var(--ios-label-2));
  font-weight: 600;
  display: block;
  margin-top: 1px;
}
.preshift-sub {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 10.5px;
  color: hsl(var(--ios-label-2));
  margin-top: 2px;
  letter-spacing: 0.01em;
}
.preshift-cta {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 10.5px;
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  padding: 6px 9px;
  border-radius: 7px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  border: 0;
  cursor: pointer;
}

/* Greeting strip — slim identity row that doesn't compete with weather hero */
.greet-strip {
  background: hsl(var(--card));
  border-radius: 13px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.25s ease;
}
.greet-strip:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.06); }

.greet-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(189 94% 35%) 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  box-shadow: 0 3px 10px hsl(var(--primary) / 0.25);
  flex-shrink: 0;
  position: relative;
}
.greet-avatar::after {
  content: "";
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  background: #22C55E;
  border: 2px solid #fff;
  border-radius: 50%;
}
.greet-text { min-width: 0; }
.greet-line {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  color: hsl(var(--ios-label-3, 240 4% 65%));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  line-height: 1;
  margin: 0;
}
.greet-name {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: hsl(var(--foreground));
  letter-spacing: -0.015em;
  margin-top: 3px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.greet-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  color: hsl(var(--ios-label-2));
  font-weight: 600;
  letter-spacing: 0.02em;
}
.greet-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: hsl(var(--ios-label-3, 240 4% 75%));
  display: inline-block;
}
.greet-id {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  color: hsl(var(--ios-label-2));
  background: hsl(var(--ios-fill-3, 240 6% 95%));
  padding: 5px 8px;
  border-radius: 7px;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  border: 1px solid hsl(var(--border));
  white-space: nowrap;
}

/* Weather hero — animated, severity-coded, hourly + tip */
.wx-hero {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  color: #fff;
  transition: background 0.8s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
}
.wx-hero.w-sun   { background: linear-gradient(160deg, #5D9FF0 0%, #3D7EC5 45%, #1E5B9E 100%); }
.wx-hero.w-cloud { background: linear-gradient(160deg, #7C8AA8 0%, #5A6C8E 45%, #3A4866 100%); }
.wx-hero.w-rain  { background: linear-gradient(160deg, #3D5778 0%, #243A58 45%, #13243D 100%); }
.wx-hero.w-storm { background: linear-gradient(160deg, #3A2C5E 0%, #241A3D 45%, #120C22 100%); }

.wx-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 18px;
}
.wx-bg .sun {
  position: absolute;
  top: -30px;
  right: -25px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,248,214,0.95) 0%, rgba(255,217,102,0.7) 30%, rgba(255,179,71,0.3) 55%, transparent 80%);
  box-shadow: 0 0 80px rgba(255,217,102,0.55);
  animation: sunSpin 36s infinite linear;
}
.wx-bg .sun::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,248,214,0.18) 30%, transparent 60%);
  animation: sunPulse 3.5s infinite ease-in-out;
}
@keyframes sunSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes sunPulse { 0%, 100% { transform: scale(1); opacity: 0.55; } 50% { transform: scale(1.15); opacity: 0.85; } }

.wx-bg .cloud-bg {
  position: absolute;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  animation: cloudDrift 16s infinite linear;
  filter: blur(2px);
}
.wx-bg .cloud-bg.b1 { width: 110px; height: 38px; top: 22px;  left: -30%; }
.wx-bg .cloud-bg.b2 { width: 80px;  height: 30px; top: 64px;  left: -20%; animation-duration: 22s; animation-delay: -8s;  opacity: 0.65; }
.wx-bg .cloud-bg.b3 { width: 95px;  height: 34px; top: 108px; left: -25%; animation-duration: 19s; animation-delay: -14s; opacity: 0.45; }
@keyframes cloudDrift { 0% { transform: translateX(0); } 100% { transform: translateX(500px); } }

.wx-bg .rain-bg i {
  position: absolute;
  width: 1.5px;
  background: linear-gradient(180deg, transparent, rgba(190,220,255,0.92));
  border-radius: 1px;
  animation: rainFall 0.85s infinite linear;
}
@keyframes rainFall {
  0%   { transform: translateY(-30px) translateX(0); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(360px) translateX(-12px); opacity: 0; }
}
.wx-bg .lightning-bg {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  animation: lightningFlash 5.5s infinite;
  pointer-events: none;
}
@keyframes lightningFlash {
  0%, 93%, 100% { background: rgba(255,255,255,0); }
  94% { background: rgba(255,255,255,0.45); }
  95% { background: rgba(255,255,255,0); }
  96% { background: rgba(255,255,255,0.6); }
  97% { background: rgba(255,255,255,0); }
}

.wx-content {
  position: relative;
  z-index: 2;
  padding: 16px 16px 13px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wx-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wx-loc {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  color: rgba(255,255,255,0.78);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.wx-loc .material-symbols-outlined { font-size: 14px; }
.wx-update {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
  font-weight: 700;
}
.wx-update::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(116,255,138,0.85);
  box-shadow: 0 0 6px rgba(116,255,138,0.6);
  animation: livePulse 1.6s infinite;
}
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.wx-update.stale::before { background: rgba(255,179,71,0.85); box-shadow: 0 0 6px rgba(255,179,71,0.55); }
.wx-update.error::before { background: rgba(255,107,107,0.85); box-shadow: 0 0 6px rgba(255,107,107,0.55); }

.wx-now {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: -4px;
}
.wx-now-left h3 {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 200;
  font-size: 64px;
  letter-spacing: -0.05em;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 14px rgba(0,0,0,0.18);
  margin: 0;
}
.wx-cond {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  margin-top: 2px;
  letter-spacing: -0.005em;
}
.wx-cond-lao {
  font-size: 11px;
  color: rgba(255,255,255,0.78);
  font-weight: 600;
  display: block;
  margin-top: 1px;
}
.wx-now-right {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
}
.wx-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 65%);
}
.wx-big-em {
  font-size: 72px;
  line-height: 1;
  animation: wxFloat 4s infinite ease-in-out;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.3));
  position: relative;
  z-index: 3;
}
@keyframes wxFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-6px) rotate(1deg); }
}

.wx-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.wx-stat {
  background: rgba(255,255,255,0.12);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 11px;
  padding: 9px 6px;
  text-align: center;
  transition: transform 0.2s ease;
}
.wx-stat:hover { transform: translateY(-1px); background: rgba(255,255,255,0.16); }
.wx-stat-ic {
  margin: 0 auto 3px;
  width: 18px;
  height: 18px;
  color: rgba(255,255,255,0.65);
}
.wx-stat-ic .material-symbols-outlined { font-size: 16px; }
.wx-stat b {
  color: #fff;
  display: block;
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.wx-stat-lbl {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 8px;
  color: rgba(255,255,255,0.62);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 3px;
  font-weight: 700;
  display: block;
}

.wx-hourly {
  background: rgba(0,0,0,0.22);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 8px 5px;
  display: flex;
  gap: 3px;
}
.wx-hr {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 1px;
  border-radius: 7px;
  transition: background 0.2s ease;
}
.wx-hr.now {
  background: rgba(255,255,255,0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18), 0 2px 6px rgba(0,0,0,0.12);
}
.wx-hr.alert { background: rgba(255,107,107,0.22); }
.wx-hr-h {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 8.5px;
  color: rgba(255,255,255,0.6);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.wx-hr.now .wx-hr-h { color: #fff; }
.wx-hr-em { font-size: 14px; line-height: 1; }
.wx-hr-t {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  color: rgba(255,255,255,0.85);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.wx-hr.now .wx-hr-t { color: #fff; }

.wx-tip {
  background: rgba(255,255,255,0.14);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 11px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: preshiftSlide 0.4s ease;
}
.wx-tip[hidden] { display: none; }
.wx-tip.urgent {
  background: rgba(255,107,107,0.24);
  border-color: rgba(255,107,107,0.5);
  animation: preshiftSlide 0.4s ease, urgentPulse 2s infinite;
}
@keyframes urgentPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,107,107,0.45); }
  50%      { box-shadow: 0 0 0 5px rgba(255,107,107,0); }
}
.wx-tip-em { font-size: 18px; flex-shrink: 0; line-height: 1; }
.wx-tip-body { flex: 1; line-height: 1.35; min-width: 0; }
.wx-tip-body b {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: 11.5px;
  color: #fff;
  display: block;
  letter-spacing: -0.005em;
}
.wx-tip-lao {
  font-size: 10px;
  color: rgba(255,255,255,0.78);
  font-weight: 600;
  display: block;
  margin-top: 1px;
}

/* Section header v5 — only visible on home */
.section-h.v5 {
  padding: 8px 4px 4px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  text-transform: none;
  letter-spacing: 0;
}
.section-h.v5 h3 {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: hsl(var(--foreground));
  letter-spacing: -0.005em;
}
.section-h.v5 .section-sub {
  display: inline-block;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  color: hsl(var(--ios-label-2));
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: hsl(var(--ios-fill-3, 240 6% 95%));
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
}

/* Action stack v5 — break out of iOS inset list, give each card individual treatment */
.action-stack.v5 {
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: transparent !important;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
  margin-top: 2px;
}

.mode-card.v5 {
  position: relative;
  background: hsl(var(--card)) !important;
  border-radius: 15px !important;
  padding: 14px !important;
  display: grid !important;
  grid-template-columns: auto 1fr auto;
  gap: 13px;
  align-items: center;
  border: 1.5px solid transparent !important;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
  overflow: hidden;
  min-height: 0;
}
.mode-card.v5::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--mc-glow, rgba(0,122,255,0.05)) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.mode-card.v5:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.08) !important;
  border-color: var(--mc-bd, rgba(0,122,255,0.25)) !important;
}
.mode-card.v5:hover::before { opacity: 1; }
.mode-card.v5:active { transform: translateY(0); }
.mode-card.v5 + .mode-card.v5::before { /* kill iOS hairline separator */ display: block; }

.mode-card.v5 .mode-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.mode-card.v5 .mode-icon-box .material-symbols-outlined {
  font-size: 24px;
  color: #fff;
  font-variation-settings: 'FILL' 1, 'wght' 500;
}
.mode-card.patrol.v5 {
  --mc-bd:   rgba(0,122,255,0.32);
  --mc-glow: rgba(0,122,255,0.06);
}
.mode-card.patrol.v5 .mode-icon-box {
  background: linear-gradient(135deg, #007AFF, #0096CC);
  box-shadow: 0 6px 16px rgba(0,122,255,0.32);
}
.mode-card.special.v5 {
  --mc-bd:   rgba(167,139,250,0.32);
  --mc-glow: rgba(167,139,250,0.06);
}
.mode-card.special.v5 .mode-icon-box {
  background: linear-gradient(135deg, #A78BFA, #7C3AED);
  box-shadow: 0 6px 16px rgba(167,139,250,0.36);
}

.mode-card.v5 .mode-text {
  position: relative;
  z-index: 1;
  min-width: 0;
}
.mode-card.v5 .mode-card-title {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-weight: 700 !important;
  font-size: 15px !important;
  color: hsl(var(--foreground));
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.mode-card.v5 .mode-card-desc {
  font-size: 11.5px;
  color: hsl(var(--ios-label-2));
  margin-top: 3px;
  line-height: 1.35;
}

.mode-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9.5px;
  color: hsl(var(--ios-label-2));
  font-weight: 600;
  letter-spacing: 0.02em;
}
.mode-meta .mode-pip {
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.mode-card.patrol.v5 .mode-meta .mode-pip {
  background: rgba(0,122,255,0.1);
  color: #007AFF;
  border: 1px solid rgba(0,122,255,0.22);
}
.mode-card.special.v5 .mode-meta .mode-pip {
  background: rgba(167,139,250,0.12);
  color: #7C3AED;
  border: 1px solid rgba(167,139,250,0.28);
}
.mode-meta .mode-sep { color: hsl(var(--ios-label-3, 240 4% 75%)); }
.mode-meta b { color: hsl(var(--foreground)); font-weight: 700; }

.mode-card.v5 .mode-chevron {
  color: hsl(var(--ios-label-3, 240 4% 75%));
  position: relative;
  z-index: 1;
  transition: transform 0.25s ease, color 0.2s ease;
}
.mode-card.patrol.v5:hover  .mode-chevron { color: #007AFF; transform: translateX(3px); }
.mode-card.special.v5:hover .mode-chevron { color: #7C3AED; transform: translateX(3px); }
.mode-card.v5 .mode-chevron .material-symbols-outlined { font-size: 22px; }

@media (prefers-reduced-motion: reduce) {
  .preshift, .wx-tip,
  .wx-bg .sun, .wx-bg .sun::after, .wx-bg .cloud-bg, .wx-bg .rain-bg i, .wx-bg .lightning-bg,
  .wx-update::before, .wx-big-em,
  .mode-card.v5, .mode-card.v5::before, .mode-card.v5 .mode-chevron {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   HOME v6 — Lao-only, hero + action stack + wx strip + recent rail
   Tokens: 14px gap, 14px/22px radii, 2 shadows
   ============================================================ */

:root {
  --v6-shadow-sm: 0 1px 2px rgba(15,23,42,0.05), 0 2px 8px rgba(15,23,42,0.04);
  --v6-shadow-md: 0 6px 18px rgba(15,23,42,0.08), 0 2px 6px rgba(15,23,42,0.05);
  --v6-shadow-modal: 0 -10px 40px rgba(15,23,42,0.18), 0 -2px 10px rgba(15,23,42,0.10);
  --v6-ink: #0F172A;
  --v6-muted: #64748B;
  --v6-line: #E5E7EB;
  --v6-bg: #F4F6FA;
  --v6-primary: #16A34A;
  --v6-primary-deep: #15803D;
  --v6-special: #6366F1;
  --v6-special-deep: #4338CA;
  --v6-warn: #F59E0B;
  --v6-danger: #DC2626;
  --v6-blue: #5BA0E5;
  --v6-blue-deep: #2563B0;
}

/* Home app bar (replaces site-header on home only) */
#screen-home .home-app-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: transparent;
}
#screen-home .home-app-bar .brand-block { display: flex; align-items: center; gap: 8px; }
#screen-home .home-app-bar .header-logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg,#16A34A,#0EA5E9);
  color: #fff; display: grid; place-items: center;
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em;
  font-family: 'Noto Sans', sans-serif;
}
#screen-home .home-app-bar .brand-text {
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--v6-ink);
}
#screen-home .home-app-bar .brand-text .accent { color: var(--v6-primary); margin-left: 4px; }
#screen-home .home-app-bar #netStatus { font-size: 11px; padding: 4px 9px; }

/* HERO — warm gradient identity card */
.home-hero {
  background: linear-gradient(135deg,#FFF1E0 0%,#FFE3CD 50%,#FFD4CB 100%);
  border-radius: 22px; padding: 18px;
  box-shadow: var(--v6-shadow-md);
  position: relative; overflow: hidden;
}
.home-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(180px 90px at 80% -10%, rgba(255,255,255,0.55), transparent),
    radial-gradient(120px 80px at 0% 100%, rgba(255,200,140,0.35), transparent);
}
.home-hero > * { position: relative; z-index: 1; }
.hero-top { display: flex; align-items: center; gap: 12px; }
.hero-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg,#16A34A 0%,#0891B2 100%);
  color: #fff; display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(8,145,178,0.35);
  border: 2px solid rgba(255,255,255,0.7);
  position: relative; flex: none;
  font-family: 'Noto Sans Lao', sans-serif;
}
.hero-avatar::after {
  content: ""; position: absolute; right: -1px; bottom: -1px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #16A34A; border: 2px solid #FFEFD9;
}
.hero-id { flex: 1; min-width: 0; }
.hero-greet { font-size: 12px; color: rgba(15,23,42,0.6); font-weight: 600; }
.hero-name {
  font-size: 22px; font-weight: 800; line-height: 1.25; letter-spacing: -0.01em;
  margin-top: 3px; color: var(--v6-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-bell {
  position: relative;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.95);
  display: grid; place-items: center;
  backdrop-filter: blur(8px);
  cursor: pointer; transition: transform .15s ease;
  flex: none; padding: 0;
}
.hero-bell:hover, .hero-bell:active { transform: scale(1.06); }
.hero-bell .material-symbols-outlined { font-size: 20px; color: #B45309; }
.hero-bell .bell-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; border-radius: 99px;
  background: var(--v6-danger); color: #fff;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center; padding: 0 5px;
  border: 2px solid #FFEFD9;
  font-family: 'Noto Sans', sans-serif;
}
.hero-countdown { margin-top: 18px; }
.hero-countdown-lbl {
  font-size: 12px; font-weight: 700;
  color: rgba(15,23,42,0.6); margin-bottom: 6px;
}
.hero-countdown-num {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-size: 50px; font-weight: 800; letter-spacing: -0.035em;
  line-height: 1; color: var(--v6-ink);
  display: inline-flex; align-items: baseline; gap: 0;
  font-variant-numeric: tabular-nums;
}
.hero-countdown-num .unit {
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 16px; font-weight: 700;
  color: rgba(15,23,42,0.55);
  margin-left: 3px; margin-right: 10px;
  letter-spacing: 0;
}
.hero-meta {
  margin-top: 16px; padding-top: 13px;
  border-top: 1px dashed rgba(15,23,42,0.13);
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: rgba(15,23,42,0.7); font-weight: 500;
}
.hero-meta .material-symbols-outlined { font-size: 17px; color: rgba(15,23,42,0.55); }

/* shift-state variants — toggled by JS by setting .home-hero[data-shift-state="..."] */
.home-hero[data-shift-state="active"] {
  background: linear-gradient(135deg,#DCFCE7 0%,#BBF7D0 50%,#86EFAC 100%);
}
.home-hero[data-shift-state="active"] .hero-avatar::after { border-color: #DCFCE7; }
.home-hero[data-shift-state="active"] .hero-bell { background: rgba(255,255,255,0.65); }
.home-hero[data-shift-state="active"] .hero-bell .bell-badge { border-color: #DCFCE7; }
.home-hero[data-shift-state="off"] {
  background: linear-gradient(135deg,#E0E7FF 0%,#C7D2FE 50%,#A5B4FC 100%);
}
.home-hero[data-shift-state="off"] .hero-avatar::after { border-color: #E0E7FF; }
.home-hero[data-shift-state="off"] .hero-bell { background: rgba(255,255,255,0.65); }
.home-hero[data-shift-state="off"] .hero-bell .bell-badge { border-color: #E0E7FF; }

/* ACTION STACK v6 */
.action-stack.v6 { display: flex; flex-direction: column; gap: 10px; }

.action-stack.v6 .cta-primary {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg,var(--v6-primary) 0%,var(--v6-primary-deep) 100%);
  color: #fff; padding: 16px 18px; border-radius: 16px;
  box-shadow: 0 8px 22px rgba(22,163,74,0.30), 0 2px 6px rgba(22,163,74,0.18);
  border: none; cursor: pointer;
  animation: v6Pulse 2.6s ease-in-out infinite;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  width: 100%; text-align: left;
}
@keyframes v6Pulse {
  0%,100% { box-shadow: 0 8px 22px rgba(22,163,74,0.30), 0 2px 6px rgba(22,163,74,0.18); }
  50%     { box-shadow: 0 12px 30px rgba(22,163,74,0.42), 0 4px 10px rgba(22,163,74,0.25); }
}
.action-stack.v6 .cta-primary:active { transform: scale(0.985); }
.action-stack.v6 .cta-icon {
  width: 38px; height: 38px; border-radius: 11px;
  background: rgba(255,255,255,0.18); display: grid; place-items: center; flex: none;
}
.action-stack.v6 .cta-icon .material-symbols-outlined { font-size: 24px; color: #fff; }
.action-stack.v6 .cta-icon.special {
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(99,102,241,0.06));
}
.action-stack.v6 .cta-icon.special .material-symbols-outlined { color: var(--v6-special); }
.action-stack.v6 .cta-stack { flex: 1; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; min-width: 0; }
.action-stack.v6 .cta-stack small { font-size: 11px; font-weight: 600; opacity: 0.88; }
.action-stack.v6 .cta-primary .cta-stack small { color: rgba(255,255,255,0.85); }
.action-stack.v6 .cta-stack strong { font-size: 18px; font-weight: 800; letter-spacing: -0.005em; }
.action-stack.v6 .cta-arrow { font-size: 22px; opacity: 0.85; color: #fff; }

.action-stack.v6 .cta-special {
  display: flex; align-items: center; gap: 12px;
  background: hsl(var(--card)); color: var(--v6-special-deep);
  padding: 15px 18px; border-radius: 16px;
  box-shadow: var(--v6-shadow-sm);
  border: 1.5px solid rgba(99,102,241,0.18);
  cursor: pointer; font-family: inherit;
  transition: transform .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
  width: 100%; text-align: left;
}
.action-stack.v6 .cta-special:active { transform: scale(0.985); box-shadow: var(--v6-shadow-md); }
.action-stack.v6 .cta-special .cta-stack small { color: var(--v6-muted); }
.action-stack.v6 .cta-special .cta-stack strong { color: var(--v6-ink); font-size: 17px; }
.action-stack.v6 .cta-count {
  background: rgba(99,102,241,0.10); color: var(--v6-special-deep);
  font-size: 12px; font-weight: 700; padding: 4px 11px; border-radius: 99px;
  font-variant-numeric: tabular-nums; white-space: nowrap; flex: none;
}
.action-stack.v6 .cta-count .num { font-family: 'Noto Sans', sans-serif; font-weight: 800; }

/* WEATHER STRIP — slim, tappable */
button.wx-strip {
  background: hsl(var(--card)); border-radius: 14px;
  padding: 11px 14px;
  box-shadow: var(--v6-shadow-sm);
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px;
  align-items: center;
  border: 0; cursor: pointer; font-family: inherit;
  text-align: left; width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s ease, box-shadow .15s ease;
}
button.wx-strip:active { transform: scale(0.99); box-shadow: var(--v6-shadow-md); }
.wx-strip-ic {
  width: 36px; height: 36px;
  background: linear-gradient(135deg,#94B5DB,#6E92BC);
  border-radius: 10px; display: grid; place-items: center; color: #fff;
}
.wx-strip-ic .material-symbols-outlined { font-size: 21px; }
.wx-strip-data { display: flex; flex-direction: column; min-width: 0; }
.wx-strip-temp {
  font-size: 15px; font-weight: 700; color: var(--v6-ink);
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
}
.wx-strip-temp .deg { color: var(--v6-muted); margin: 0 1px; font-weight: 500; font-family: 'Noto Sans', sans-serif; }
.wx-strip-cond { font-size: 11.5px; color: var(--v6-muted); margin-top: 1px; }
.wx-strip-meta {
  display: flex; gap: 10px; font-size: 11.5px; color: var(--v6-muted);
  padding-left: 10px; border-left: 1px solid var(--v6-line);
}
.wx-strip-meta b {
  color: var(--v6-ink); font-weight: 700; margin-right: 3px;
  font-variant-numeric: tabular-nums; font-family: 'Noto Sans', sans-serif;
}

/* RECENT RAIL */
.recent-rail-wrap { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.rail-title { font-size: 14px; font-weight: 700; color: var(--v6-ink); }
.rail-link {
  background: transparent; border: 0; padding: 4px 6px;
  font-size: 12px; color: var(--v6-primary); font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.recent-rail {
  display: flex; gap: 10px; overflow-x: auto;
  margin: 0 -14px; padding: 4px 14px 8px;
  scrollbar-width: none;
}
.recent-rail::-webkit-scrollbar { display: none; }
.recent-rail-empty {
  flex: 1; padding: 18px 12px; text-align: center;
  color: var(--v6-muted); font-size: 12px;
  background: hsl(var(--card)); border-radius: 12px;
  border: 1px dashed var(--v6-line);
}
.recent-card {
  flex: 0 0 142px; background: hsl(var(--card)); border-radius: 12px; padding: 10px;
  box-shadow: var(--v6-shadow-sm); cursor: pointer;
  border: 0; font-family: inherit; text-align: left;
}
.recent-card:active { transform: scale(0.98); }
.recent-thumb {
  height: 60px; border-radius: 8px;
  background: linear-gradient(135deg,#DBEAFE,#BFDBFE);
  display: grid; place-items: center; color: #1E3A8A;
  margin-bottom: 8px; position: relative;
}
.recent-thumb.warm  { background: linear-gradient(135deg,#FED7AA,#FDBA74); color: #7C2D12; }
.recent-thumb.green { background: linear-gradient(135deg,#BBF7D0,#86EFAC); color: #14532D; }
.recent-thumb.purple{ background: linear-gradient(135deg,#E9D5FF,#D8B4FE); color: #5B21B6; }
.recent-thumb .material-symbols-outlined { font-size: 24px; opacity: .75; }
.recent-thumb .badge {
  position: absolute; top: 5px; right: 5px;
  background: rgba(255,255,255,0.9); color: var(--v6-ink);
  font-size: 9.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 99px;
}
.recent-thumb .badge.special { background: rgba(99,102,241,0.92); color: #fff; }
.recent-name { font-size: 12px; font-weight: 700; color: var(--v6-ink); }
.recent-time {
  font-size: 10.5px; color: var(--v6-muted); margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   MODAL BOTTOM-SHEET (weather + notifications popups)
   Pattern from .agent/skills/vks-mobile-popup-fix Pattern A:
   sheet is position:fixed pinned to viewport edges (bypasses
   any flex-sizing weirdness on Android WebViews / iOS PWAs).
   .active class drives visibility, not [hidden].
   ============================================================ */
/* No touch-action: none — that blocks subsequent taps after close */
body.modal-open { overflow: hidden; }

.v6-modal-bd {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,0.40);
  display: none; /* shown via .active */
}
.v6-modal-bd.active {
  display: block;
  animation: v6FadeIn .25s ease both;
}
@keyframes v6FadeIn { from { opacity: 0; } to { opacity: 1; } }

.v6-modal-sheet {
  position: fixed !important;
  left: 0 !important; right: 0 !important; bottom: 0 !important;
  margin: 0 !important;
  width: 100% !important; max-width: 100% !important;
  max-height: 88dvh !important;
  background: hsl(var(--card));
  border-radius: 28px 28px 0 0;
  box-shadow: var(--v6-shadow-modal);
  display: flex; flex-direction: column;
  animation: v6SlideUp .35s cubic-bezier(0.22, 1, 0.36, 1) both;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 201;
}
@keyframes v6SlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-handle {
  width: 36px; height: 4px; border-radius: 99px;
  background: rgba(15,23,42,0.18);
  margin: 8px auto 0; flex: none;
}
.v6-modal-sheet .modal-header {
  padding: 14px 20px 10px;
  display: flex; align-items: center; justify-content: space-between;
  flex: none; gap: 10px;
}
.modal-title-stack { line-height: 1.25; min-width: 0; }
.v6-modal-sheet .modal-title { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; color: var(--v6-ink); }
.v6-modal-sheet .modal-sub { font-size: 11.5px; color: var(--v6-muted); margin-top: 1px; }
.modal-header-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.v6-modal-sheet .modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--v6-bg); border: 0; display: grid; place-items: center;
  cursor: pointer; flex: none; padding: 0;
}
.v6-modal-sheet .modal-close .material-symbols-outlined { font-size: 19px; color: var(--v6-ink); }
.v6-modal-sheet .modal-action {
  background: transparent; border: 0;
  color: var(--v6-primary); font-weight: 700; font-size: 12.5px;
  cursor: pointer; padding: 4px 8px; font-family: inherit;
}
.v6-modal-sheet .modal-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 6px 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
  scrollbar-width: none;
}
.v6-modal-sheet .modal-body::-webkit-scrollbar { display: none; }
/* Critical: every direct child of modal-body must keep its natural
   height so the content scrolls instead of shrinking the now-panel
   (caused the "only 30° visible" bug in v6.1). */
.v6-modal-sheet .modal-body > * { flex-shrink: 0; }

/* ── WEATHER MODAL CONTENT ── */
.wxm-now {
  background: linear-gradient(135deg,#5BA0E5 0%,#3B82C9 60%,#2563B0 100%);
  color: #fff; border-radius: 20px;
  padding: 18px 20px 16px;
  position: relative; overflow: hidden;
}
.wxm-now::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(160px 80px at 90% -20%, rgba(255,255,255,0.35), transparent),
    radial-gradient(140px 80px at -10% 100%, rgba(255,255,255,0.18), transparent);
}
.wxm-now > * { position: relative; z-index: 1; }
.wxm-now-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.wxm-now-row > div:first-child { flex: 1; min-width: 0; }
.wxm-now-temp {
  font-family: 'Noto Sans', sans-serif;
  font-size: 52px; font-weight: 800; letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.wxm-now-temp .deg { font-size: 26px; opacity: 0.85; margin-left: 2px; font-weight: 600; }
.wxm-now-icon {
  width: 64px; height: 64px;
  background: rgba(255,255,255,0.18); border-radius: 16px;
  display: grid; place-items: center; flex: none;
}
.wxm-now-icon .material-symbols-outlined { font-size: 42px; color: #fff; }
.wxm-now-cond { font-size: 15px; font-weight: 600; margin-top: 6px; }
.wxm-now-meta {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.18);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.wxm-now-meta div { display: flex; flex-direction: column; }
.wxm-now-meta .lbl { font-size: 10px; color: rgba(255,255,255,0.7); font-weight: 600; }
.wxm-now-meta .val { font-size: 14px; font-weight: 700; margin-top: 2px; }
.wxm-now-meta .val .num { font-family: 'Noto Sans', sans-serif; }

.wxm-section-title {
  font-size: 12px; font-weight: 700; color: var(--v6-ink);
  margin: 4px 2px -2px;
  display: flex; align-items: center; justify-content: space-between;
}
.wxm-section-title .right { font-size: 11px; color: var(--v6-muted); font-weight: 500; }

.wxm-hourly {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px 0 4px;
  margin: 0 -18px; padding-left: 18px; padding-right: 18px;
  scrollbar-width: none;
}
.wxm-hourly::-webkit-scrollbar { display: none; }
.wxm-hour {
  flex: 0 0 78px;
  background: var(--v6-bg); border-radius: 14px;
  padding: 12px 6px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 1px solid var(--v6-line);
}
.wxm-hour.now {
  background: rgba(91,160,229,0.12);
  border-color: rgba(91,160,229,0.40);
  box-shadow: 0 2px 6px rgba(91,160,229,0.10);
}
.wxm-hour.night {
  background: rgba(99,102,241,0.06);
  border-color: rgba(99,102,241,0.18);
}
.wxm-hour.now.night {
  background: rgba(99,102,241,0.10);
  border-color: rgba(99,102,241,0.35);
}
.wxm-hour .h-time { font-size: 11px; color: var(--v6-muted); font-weight: 700; font-family: 'Noto Sans', sans-serif; letter-spacing: 0.02em; }
.wxm-hour.now .h-time { color: var(--v6-blue-deep); }
.wxm-hour.night .h-time { color: var(--v6-special-deep); }
.wxm-hour .h-icon .material-symbols-outlined { font-size: 26px; color: var(--v6-blue); font-variation-settings: 'FILL' 1; }
.wxm-hour.sunny .h-icon .material-symbols-outlined { color: var(--v6-warn); }
.wxm-hour.clear-night .h-icon .material-symbols-outlined { color: var(--v6-special); }
.wxm-hour.partly-night .h-icon .material-symbols-outlined { color: var(--v6-special); }
.wxm-hour .h-temp { font-size: 14px; font-weight: 800; color: var(--v6-ink); font-family: 'Noto Sans', sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1; }
.wxm-hour .h-feels {
  font-size: 9.5px; color: var(--v6-muted); font-weight: 600;
  font-family: 'Noto Sans Lao', sans-serif;
}
.wxm-hour .h-feels .num { font-family: 'Noto Sans', sans-serif; font-variant-numeric: tabular-nums; }
.wxm-hour .h-chips {
  display: flex; flex-direction: column; gap: 3px; align-items: center;
  min-height: 14px; margin-top: 2px;
}
.wxm-hour .h-chip {
  font-size: 9px; font-weight: 700;
  font-family: 'Noto Sans', sans-serif;
  padding: 1px 6px; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 3px;
}
.wxm-hour .h-chip.rain  { color: var(--v6-blue-deep); background: rgba(91,160,229,0.15); }
.wxm-hour .h-chip.wind  { color: var(--v6-muted);     background: rgba(100,116,139,0.13); }
.wxm-hour .h-chip .material-symbols-outlined { font-size: 10px; }

.wxm-tomorrow {
  background: var(--v6-bg); border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid var(--v6-line);
  margin-top: 8px;
}
.wxm-tom-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wxm-tom-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.wxm-tom-icon-pair { display: flex; align-items: center; gap: 4px; flex: none; }
.wxm-tom-icon-pair .material-symbols-outlined { font-size: 26px; color: var(--v6-blue); }
.wxm-tom-icon-pair .arrow { color: var(--v6-muted); font-size: 18px; }
.wxm-tom-cond { font-size: 13px; font-weight: 700; color: var(--v6-ink); min-width: 0; }
.wxm-tom-cond .sub { display: block; font-size: 11px; color: var(--v6-muted); font-weight: 500; margin-top: 1px; }
.wxm-tom-temps { text-align: right; flex: none; }
.wxm-tom-temps .high { font-size: 17px; font-weight: 800; color: var(--v6-ink); font-family: 'Noto Sans', sans-serif; font-variant-numeric: tabular-nums; }
.wxm-tom-temps .low { font-size: 13px; color: var(--v6-muted); font-family: 'Noto Sans', sans-serif; font-variant-numeric: tabular-nums; }
.wxm-tom-divider { border-top: 1px dashed var(--v6-line); padding-top: 10px; margin-top: 10px; }
.wxm-tom-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.wxm-tom-pill {
  background: rgba(91,160,229,0.10); color: var(--v6-blue-deep);
  font-size: 10.5px; font-weight: 700;
  padding: 4px 10px; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 5px;
}
.wxm-tom-pill .material-symbols-outlined { font-size: 13px; }

.wxm-extras {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 8px;
}
.wxm-extra {
  background: var(--v6-bg); border-radius: 12px; padding: 10px;
  border: 1px solid var(--v6-line);
  display: flex; flex-direction: column; gap: 4px;
  align-items: flex-start;
}
.wxm-extra .ic { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; }
.wxm-extra .ic .material-symbols-outlined { font-size: 16px; }
.wxm-extra .ic.sun { background: rgba(245,158,11,0.13); color: #B45309; }
.wxm-extra .ic.dusk { background: rgba(99,102,241,0.13); color: var(--v6-special-deep); }
.wxm-extra .ic.pm { background: rgba(100,116,139,0.13); color: var(--v6-muted); }
.wxm-extra .ic.pm.level-good      { background: rgba(22,163,74,0.15);  color: var(--v6-primary-deep); }
.wxm-extra .ic.pm.level-moderate  { background: rgba(245,158,11,0.18); color: #B45309; }
.wxm-extra .ic.pm.level-sensitive { background: rgba(249,115,22,0.18); color: #C2410C; }
.wxm-extra .ic.pm.level-unhealthy { background: rgba(239,68,68,0.18);  color: #B91C1C; }
.wxm-extra .ic.pm.level-very      { background: rgba(124,58,237,0.20); color: #6D28D9; }
.wxm-extra .ic.pm.level-hazardous { background: rgba(127,29,29,0.25);  color: #7F1D1D; }
.wxm-extra .pm-lvl {
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 10.5px; color: var(--v6-muted);
  font-weight: 600; margin-left: 4px;
  display: block; margin-top: 1px;
}
.wxm-extra .lbl .unit {
  font-family: 'Noto Sans', sans-serif;
  font-weight: 500; opacity: 0.7;
  margin-left: 2px;
}
.wxm-extra .lbl { font-size: 10px; color: var(--v6-muted); font-weight: 600; }
.wxm-extra .val {
  font-size: 13px; font-weight: 700; color: var(--v6-ink);
  font-family: 'Noto Sans', sans-serif; font-variant-numeric: tabular-nums;
}
.wxm-extra .val span#wxmUvLbl, .wxm-extra .val span:not([id]) {
  font-family: 'Noto Sans Lao', sans-serif; font-size: 11px; color: var(--v6-muted);
  margin-left: 3px; font-weight: 500;
}

/* ── NOTIFICATION MODAL CONTENT ── */
.notif-tabs {
  display: flex; gap: 6px;
  background: var(--v6-bg); border-radius: 11px; padding: 4px;
}
.notif-tab {
  flex: 1; padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px; font-weight: 700;
  text-align: center; cursor: pointer;
  color: var(--v6-muted);
  border: 0; background: transparent;
  font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.notif-tab.active { background: hsl(var(--card)); color: var(--v6-ink); box-shadow: var(--v6-shadow-sm); }
.notif-tab .badge {
  background: var(--v6-danger); color: #fff;
  font-size: 9px; font-weight: 800;
  padding: 1px 6px; border-radius: 99px;
  font-family: 'Noto Sans', sans-serif;
}

.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-day-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--v6-muted);
  margin: 6px 2px -4px;
}
.notif-list-empty {
  padding: 28px 18px; text-align: center;
  color: var(--v6-muted); font-size: 13px;
  background: var(--v6-bg); border-radius: 12px;
  border: 1px dashed var(--v6-line);
}
.notif-card {
  background: hsl(var(--card)); border-radius: 14px;
  padding: 14px;
  box-shadow: var(--v6-shadow-sm);
  border: 1px solid var(--v6-line);
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px;
  align-items: flex-start;
}
.notif-card.unread {
  border-color: rgba(99,102,241,0.25);
  background: linear-gradient(180deg, rgba(99,102,241,0.025), transparent 80%);
}
.notif-card.read { opacity: 0.62; background: var(--v6-bg); }
.notif-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  flex: none;
}
.notif-icon.meeting { background: rgba(99,102,241,0.13); color: var(--v6-special-deep); }
.notif-icon.alert   { background: rgba(245,158,11,0.13); color: #B45309; }
.notif-icon.training{ background: rgba(91,160,229,0.13); color: var(--v6-blue-deep); }
.notif-icon.system  { background: rgba(100,116,139,0.13); color: var(--v6-muted); }
.notif-icon .material-symbols-outlined { font-size: 22px; }
.notif-card.read .notif-icon { background: rgba(100,116,139,0.10); color: var(--v6-muted); }
.notif-body { min-width: 0; }
.notif-title {
  font-size: 13.5px; font-weight: 800; color: var(--v6-ink);
  letter-spacing: -0.005em; line-height: 1.35;
}
.notif-when {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--v6-muted); font-weight: 600;
  margin-top: 4px;
}
.notif-when .material-symbols-outlined { font-size: 13px; }
.notif-when .num { font-family: 'Noto Sans', sans-serif; }
.notif-body .desc { font-size: 12px; color: var(--v6-ink); margin-top: 6px; line-height: 1.5; }
.notif-by {
  margin-top: 8px;
  font-size: 11px; color: var(--v6-muted);
  display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.notif-by .by-chip {
  background: var(--v6-bg); padding: 2px 8px; border-radius: 99px;
  font-weight: 700; color: var(--v6-ink);
  border: 1px solid var(--v6-line);
}
.notif-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.notif-btn {
  padding: 7px 12px; border-radius: 9px;
  font-size: 11.5px; font-weight: 700;
  cursor: pointer; border: 0;
  font-family: inherit;
}
.notif-btn.primary { background: var(--v6-ink); color: #fff; }
.notif-btn.ghost { background: var(--v6-bg); color: var(--v6-ink); border: 1px solid var(--v6-line); }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--v6-special); flex: none; margin-top: 6px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .action-stack.v6 .cta-primary { animation: none !important; }
  .v6-modal-bd, .v6-modal-sheet { animation: none !important; }
}

/* ============================================================
 * MOTION LAYER — screen-in, list stagger, badge pop, tap polish
 * GPU-only (transform + opacity). Global prefers-reduced-motion
 * block at style.css:1802 already neutralises every animation
 * to 0.001ms, so no extra reduced-motion guard is needed.
 * ============================================================ */

/* --- Screen transitions ------------------------------------- */
/* Every .screen plays a soft slide-up + fade when it un-hides. */
@keyframes vksScreenIn {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}
.screen:not(.hidden) {
  animation: vksScreenIn .28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* --- List & tile stagger ------------------------------------ */
/* One keyframe — each list applies its own nth-child delays.   */
@keyframes vksItemIn {
  from { opacity: 0; transform: translate3d(0, 6px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* Home v6 tiles (hero, action-stack rows, weather strip, recent rail) */
.screen:not(.hidden) .v6-hero,
.screen:not(.hidden) .action-stack.v6 > *,
.screen:not(.hidden) .wx-strip,
.screen:not(.hidden) .recent-rail {
  animation: vksItemIn .42s cubic-bezier(0.22, 1, 0.36, 1) both;
  will-change: transform, opacity;
}
.screen:not(.hidden) .v6-hero                 { animation-delay: .04s; }
.screen:not(.hidden) .action-stack.v6 > *:nth-child(1) { animation-delay: .10s; }
.screen:not(.hidden) .action-stack.v6 > *:nth-child(2) { animation-delay: .16s; }
.screen:not(.hidden) .action-stack.v6 > *:nth-child(3) { animation-delay: .22s; }
.screen:not(.hidden) .action-stack.v6 > *:nth-child(4) { animation-delay: .28s; }
.screen:not(.hidden) .wx-strip                { animation-delay: .30s; }
.screen:not(.hidden) .recent-rail             { animation-delay: .36s; }

/* Notification cards inside the open modal — staggered fade-in */
.v6-modal-bd.active .notif-card {
  animation: vksItemIn .36s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.v6-modal-bd.active .notif-card:nth-child(1)  { animation-delay: .04s; }
.v6-modal-bd.active .notif-card:nth-child(2)  { animation-delay: .09s; }
.v6-modal-bd.active .notif-card:nth-child(3)  { animation-delay: .14s; }
.v6-modal-bd.active .notif-card:nth-child(4)  { animation-delay: .19s; }
.v6-modal-bd.active .notif-card:nth-child(5)  { animation-delay: .24s; }
.v6-modal-bd.active .notif-card:nth-child(6)  { animation-delay: .29s; }
.v6-modal-bd.active .notif-card:nth-child(7)  { animation-delay: .33s; }
.v6-modal-bd.active .notif-card:nth-child(8)  { animation-delay: .37s; }
.v6-modal-bd.active .notif-card:nth-child(n+9) { animation-delay: .40s; }

/* Recent rail cards (horizontal scroller) */
.recent-rail .recent-card {
  animation: vksItemIn .36s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.recent-rail .recent-card:nth-child(1) { animation-delay: .42s; }
.recent-rail .recent-card:nth-child(2) { animation-delay: .48s; }
.recent-rail .recent-card:nth-child(3) { animation-delay: .54s; }
.recent-rail .recent-card:nth-child(n+4) { animation-delay: .58s; }

/* History list cards — same idea, slightly tighter cadence */
.screen:not(.hidden) .history-card {
  animation: vksItemIn .32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.screen:not(.hidden) .history-card:nth-child(1) { animation-delay: .06s; }
.screen:not(.hidden) .history-card:nth-child(2) { animation-delay: .11s; }
.screen:not(.hidden) .history-card:nth-child(3) { animation-delay: .16s; }
.screen:not(.hidden) .history-card:nth-child(4) { animation-delay: .21s; }
.screen:not(.hidden) .history-card:nth-child(5) { animation-delay: .26s; }
.screen:not(.hidden) .history-card:nth-child(n+6) { animation-delay: .30s; }

/* --- Bell badge pop on unread-count increment --------------- */
@keyframes vksBadgePop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.45); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
#bellBadge.bell-pulse {
  animation: vksBadgePop .55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* --- Bell button micro-wiggle on tap ------------------------ */
@keyframes vksBellRing {
  0%   { transform: rotate(0); }
  20%  { transform: rotate(-12deg); }
  40%  { transform: rotate( 10deg); }
  60%  { transform: rotate( -6deg); }
  80%  { transform: rotate(  3deg); }
  100% { transform: rotate(0); }
}
.bell-btn:active .material-symbols-outlined,
.bell-btn.is-ringing .material-symbols-outlined {
  animation: vksBellRing .45s ease both;
  transform-origin: 50% 18%;
}

/* --- Tap feedback gap-fillers ------------------------------- */
.bell-btn        { transition: transform .12s ease; }
.bell-btn:active { transform: scale(0.92); }
.wx-strip        { transition: transform .12s ease; }
.wx-strip:active { transform: scale(0.985); }
.notif-card      { transition: transform .12s ease, background-color .18s ease; }
.notif-card:active { transform: scale(0.985); }
.notif-tab       { transition: transform .12s ease, background-color .18s ease; }
.notif-tab:active { transform: scale(0.96); }
.recent-card     { transition: transform .12s ease; }
.recent-card:active { transform: scale(0.97); }

/* --- Modal sheet — softer overshoot on entry ---------------- */
.v6-modal-sheet {
  animation: v6SlideUp .42s cubic-bezier(0.34, 1.20, 0.64, 1) both !important;
}

/* --- Reduced-motion guard for the few infinite/overshoot bits */
@media (prefers-reduced-motion: reduce) {
  #bellBadge.bell-pulse,
  .bell-btn.is-ringing .material-symbols-outlined { animation: none !important; }
  .v6-modal-sheet { animation: v6FadeIn .15s ease both !important; }
}

/* ============================================================
 * v7 TIER 1 — Sky hero, shift ring, streak chip, tab pill
 * ============================================================ */

/* ---- 1. SKY-PHASE BACKGROUND -------------------------------- */
/* Layered behind hero content. JS sets data-sky-phase on the
 * .home-hero based on real local hour. Override the existing
 * warm-only gradient with five time-of-day variants.            */
.home-hero { background: transparent; }   /* let .hero-sky drive it */
.home-hero::after { display: none; }      /* drop the legacy radial */
.hero-sky {
  position: absolute; inset: 0; z-index: 0;
  border-radius: inherit;
  background: linear-gradient(135deg,#FFE3CD 0%,#FFD4CB 60%,#F8B5A8 100%);
  transition: background 1.4s ease;
  pointer-events: none;
  overflow: hidden;
}
.hero-sky::before {  /* soft top-right glow — sun glow */
  content:''; position: absolute; right: -20px; top: -20px;
  width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 70%);
  pointer-events: none;
  animation: heroSunBreathe 6s ease-in-out infinite;
}
@keyframes heroSunBreathe { 50% { transform: scale(1.10); opacity: .85; } }

.home-hero[data-sky-phase="dawn"]    .hero-sky { background: linear-gradient(135deg,#FFD7B5 0%,#FFB59A 50%,#F58E8E 100%); }
.home-hero[data-sky-phase="morning"] .hero-sky { background: linear-gradient(135deg,#DBEEFE 0%,#BFDFFF 50%,#A8C8F0 100%); }
.home-hero[data-sky-phase="noon"]    .hero-sky { background: linear-gradient(135deg,#BFDFFF 0%,#DEEEFF 50%,#FFF1E0 100%); }
.home-hero[data-sky-phase="dusk"]    .hero-sky { background: linear-gradient(135deg,#FFC9A8 0%,#F49477 40%,#B66A88 100%); }
.home-hero[data-sky-phase="night"]   .hero-sky { background: linear-gradient(135deg,#1F2937 0%,#1E3A8A 55%,#312E81 100%); }
.home-hero[data-sky-phase="night"]   .hero-sky::before { opacity: .25; }

/* Dark phases flip ink to white */
.home-hero[data-sky-phase="night"] .hero-greet,
.home-hero[data-sky-phase="night"] .hero-name,
.home-hero[data-sky-phase="night"] .hero-countdown-lbl,
.home-hero[data-sky-phase="night"] .hero-window,
.home-hero[data-sky-phase="night"] .hero-meta,
.home-hero[data-sky-phase="dusk"]  .hero-name,
.home-hero[data-sky-phase="dusk"]  .hero-greet,
.home-hero[data-sky-phase="dusk"]  .hero-window { color: #fff !important; }
.home-hero[data-sky-phase="night"] .hero-meta .material-symbols-outlined,
.home-hero[data-sky-phase="dusk"]  .hero-meta .material-symbols-outlined { color: rgba(255,255,255,0.85); }
.home-hero[data-sky-phase="night"] .ring-track { stroke: rgba(255,255,255,0.20); }
.home-hero[data-sky-phase="night"] .ring-prog  { stroke: #fff; }
.home-hero[data-sky-phase="night"] .ring-num,
.home-hero[data-sky-phase="night"] .ring-lab { color: #fff; }
.home-hero[data-sky-phase="dusk"]  .ring-prog { stroke: #fff; }
.home-hero[data-sky-phase="dusk"]  .ring-num,
.home-hero[data-sky-phase="dusk"]  .ring-lab { color: #fff; }

/* Override the legacy data-shift-state full-card gradients so they
 * don't paint over .hero-sky. Keep avatar-dot border tweak only.    */
.home-hero[data-shift-state="active"],
.home-hero[data-shift-state="off"] { background: transparent; }

/* ---- 2. HERO COUNTDOWN ROW (ring + text) -------------------- */
.hero-cd-row {
  margin-top: 16px;
  display: grid; grid-template-columns: auto 1fr;
  gap: 14px; align-items: center;
  position: relative; z-index: 1;
}
.hero-ring {
  position: relative; width: 92px; height: 92px; flex: none;
}
.hero-ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring-track { stroke: rgba(15,23,42,0.14); stroke-width: 5; fill: none; }
.ring-prog  {
  stroke: #16A34A; stroke-width: 5; stroke-linecap: round; fill: none;
  stroke-dasharray: 251.327;
  stroke-dashoffset: 251.327;
  transition: stroke-dashoffset .9s cubic-bezier(0.22, 1, 0.36, 1),
              stroke 1.4s ease;
}
.home-hero[data-shift-state="active"] .ring-prog { stroke: #15803d; }
.home-hero[data-shift-state="pre"]    .ring-prog { stroke: #2563eb; }
.home-hero[data-shift-state="off"]    .ring-prog { stroke: #6366f1; }
.hero-ring-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1;
}
.ring-num {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 800; font-size: 22px;
  letter-spacing: -0.03em;
  color: var(--v6-ink);
  font-variant-numeric: tabular-nums;
}
.ring-lab {
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 9.5px; font-weight: 600;
  margin-top: 4px;
  color: rgba(15,23,42,0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hero-cd-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-cd-text .hero-countdown-lbl {
  font-size: 11px; font-weight: 700;
  color: rgba(15,23,42,0.6);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 0;
}
.hero-window {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 800; font-size: 24px; letter-spacing: -0.03em;
  color: var(--v6-ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.hero-window .sep { font-weight: 600; opacity: .5; margin: 0 4px; }

/* ---- 3. STREAK FLAME CHIP ----------------------------------- */
.hero-streak {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 9px 5px 7px;
  border-radius: 99px;
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 800;
  font-size: 12.5px;
  color: #B45309;
  border: 1px solid rgba(255,255,255,0.85);
  flex: none;
  font-variant-numeric: tabular-nums;
}
.hero-streak .flame {
  font-size: 14px;
  display: inline-block;
  animation: heroFlameFlicker 1.2s ease-in-out infinite alternate;
  text-shadow: 0 0 8px rgba(255,180,71,0.6);
  transform-origin: center bottom;
}
@keyframes heroFlameFlicker {
  0%   { transform: rotate(-5deg) scale(1); opacity: .92; }
  100% { transform: rotate(5deg) scale(1.08); opacity: 1; }
}
.hero-streak .num { font-weight: 800; }
.hero-streak .unit { font-family: 'Noto Sans Lao', sans-serif; font-weight: 600; font-size: 10.5px; opacity: .85; margin-left: 2px; }
.hero-streak[hidden] { display: none !important; }
.home-hero[data-sky-phase="night"] .hero-streak,
.home-hero[data-sky-phase="dusk"]  .hero-streak {
  background: rgba(255,255,255,0.20);
  color: #FFD8A4;
  border-color: rgba(255,255,255,0.30);
}

/* ---- 4. TAB BAR PILL MORPH ---------------------------------- */
.tab-bar { position: fixed; --pill-idx: 0; --pill-count: 5; }
.tab-bar .tab-pill {
  position: absolute;
  top: 4px;
  height: 38px;
  width: 50px;
  /* Center pill inside cell idx — cell width = 100% / count */
  left: calc((var(--pill-idx) + 0.5) * (100% / var(--pill-count)) - 25px);
  background: linear-gradient(135deg, hsl(var(--primary) / 0.16), hsl(var(--primary) / 0.07));
  border-radius: 14px;
  pointer-events: none;
  transition: left .42s cubic-bezier(0.34, 1.40, 0.55, 1);
  z-index: 0;
  will-change: left;
}
.tab-bar[hidden] .tab-pill { display: none; }
.tab-item { position: relative; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  .hero-streak .flame { animation: none !important; }
  .hero-sky::before { animation: none !important; }
  .ring-prog { transition-duration: 0.001ms !important; }
  .tab-bar .tab-pill { transition-duration: 0.001ms !important; }
}

/* ============================================================
 * v7 TIER 2 — Wx scene parallax · Pull-to-refresh · Recent flip · Number ticker
 * ============================================================ */

/* ---- 5. WEATHER STRIP SCENE ---- */
.wx-strip { position: relative; overflow: hidden; }
.wx-strip > .wx-strip-ic,
.wx-strip > .wx-strip-data,
.wx-strip > .wx-strip-meta { position: relative; z-index: 1; }
.wx-scene {
  position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit; overflow: hidden; z-index: 0;
  opacity: .55;
}
.wx-scene .sun, .wx-scene .moon, .wx-scene .cloud,
.wx-scene .rain, .wx-scene .star, .wx-scene .bolt { position: absolute; }

.wx-scene .sun {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #FFE08A, #F5A23E 75%);
  box-shadow: 0 0 14px rgba(255,200,90,0.55);
  top: 6px; left: 18px;
  animation: wxSunDrift 22s linear infinite;
}
@keyframes wxSunDrift { 0%{transform:translateX(0) rotate(0)} 100%{transform:translateX(40px) rotate(360deg)} }

.wx-scene .moon {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 70% 35%, #FFFFFF 0%, #DCE3F4 60%, #B5BFD7 100%);
  box-shadow: 0 0 12px rgba(220,230,255,0.45), inset -6px -2px 0 -2px rgba(40,50,80,0.5);
  top: 7px; right: 24px;
}

.wx-scene .star {
  width: 2px; height: 2px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px rgba(255,255,255,0.85);
  animation: wxStarTwinkle 2.4s ease-in-out infinite alternate;
}
@keyframes wxStarTwinkle { 0%{opacity:.3}100%{opacity:1} }

.wx-scene .cloud {
  width: 38px; height: 14px; border-radius: 99px;
  background: rgba(255,255,255,0.85);
  box-shadow:
    -10px 6px 0 -2px rgba(255,255,255,0.78),
     12px 8px 0 -3px rgba(255,255,255,0.72),
     22px 4px 0 -4px rgba(255,255,255,0.65);
  animation: wxCloudDrift 22s linear infinite;
}
.wx-scene .cloud.c1 { top: 8px; left: -50px; animation-duration: 28s; opacity: .85; }
.wx-scene .cloud.c2 { top: 22px; left: -50px; animation-duration: 36s; animation-delay: -10s; opacity: .55; transform: scale(.75); }
.wx-scene .cloud.c3 { top: 38px; left: -50px; animation-duration: 44s; animation-delay: -22s; opacity: .40; transform: scale(.6); }
@keyframes wxCloudDrift { from{transform:translateX(0)} to{transform:translateX(420px)} }

.wx-scene .rain { left: 30%; right: 5%; top: 14px; bottom: 0; }
.wx-scene .rain i {
  position: absolute; top: -10px;
  width: 1.4px; height: 9px; border-radius: 1px;
  background: linear-gradient(to bottom, rgba(170,210,255,0) 0%, rgba(170,210,255,0.85) 100%);
  animation: wxRainFall 0.85s linear infinite;
}
@keyframes wxRainFall { from{transform:translateY(0);opacity:0} 30%{opacity:1} to{transform:translateY(80px);opacity:0} }

.wx-scene .bolt {
  top: 6px; right: 35%;
  font-size: 14px; color: #FDE68A;
  text-shadow: 0 0 12px rgba(253,230,138,0.85);
  animation: wxBoltFlash 5s ease-in-out infinite;
}
@keyframes wxBoltFlash { 0%,84%,100%{opacity:0} 86%,90%{opacity:1} 92%{opacity:.4} }

/* Scene-specific tints behind the strip — soft to keep text legible */
.wx-strip[data-wx-scene="sun"]   { background: linear-gradient(135deg,#FFF8E7 0%,#FFE9C7 100%); }
.wx-strip[data-wx-scene="cloud"] { background: linear-gradient(135deg,#EAF1FB 0%,#D6E2F0 100%); }
.wx-strip[data-wx-scene="rain"]  { background: linear-gradient(135deg,#DDE8F4 0%,#B7C8DC 100%); }
.wx-strip[data-wx-scene="storm"] { background: linear-gradient(135deg,#C3CCE0 0%,#8B97B5 100%); }
.wx-strip[data-wx-scene="night"] { background: linear-gradient(135deg,#1F2B4A 0%,#0F1632 100%); }
.wx-strip[data-wx-scene="night"] .wx-strip-temp,
.wx-strip[data-wx-scene="night"] .wx-strip-cond,
.wx-strip[data-wx-scene="night"] .wx-strip-meta,
.wx-strip[data-wx-scene="night"] .wx-strip-meta b { color: #fff !important; }
.wx-strip[data-wx-scene="night"] .wx-strip-meta { border-left-color: rgba(255,255,255,0.18); }
.wx-strip[data-wx-scene="storm"] .wx-strip-temp,
.wx-strip[data-wx-scene="storm"] .wx-strip-cond,
.wx-strip[data-wx-scene="storm"] .wx-strip-meta,
.wx-strip[data-wx-scene="storm"] .wx-strip-meta b { color: #fff !important; }
.wx-strip[data-wx-scene="storm"] .wx-strip-meta { border-left-color: rgba(255,255,255,0.20); }

/* ---- 6. PULL-TO-REFRESH ---- */
.pull-refresh {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 64px;
  pointer-events: none;
  transform: translateY(-100%);
  z-index: 60;
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
}
.pull-refresh.is-pulling { transition: transform .25s cubic-bezier(0.22, 1, 0.36, 1); }
.pull-refresh.is-armed   { /* pulled past threshold but not yet released */ }
.pull-refresh.is-loading { transform: translateY(0); transition: transform .35s cubic-bezier(0.22, 1, 0.36, 1); }
.pull-refresh.is-done    { transform: translateY(-100%); transition: transform .35s cubic-bezier(0.22, 1, 0.36, 1); }

.pull-spinner {
  width: 36px; height: 36px; position: relative;
  background: rgba(255,255,255,0.94);
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(15,23,42,0.18);
  display: grid; place-items: center;
}
.pull-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.pull-track { stroke: rgba(15,23,42,0.10); stroke-width: 3; fill: none; }
.pull-arc {
  stroke: #16A34A; stroke-width: 3; stroke-linecap: round; fill: none;
  stroke-dasharray: 88; /* circumference of r=14 */
  stroke-dashoffset: 88;
  transition: stroke-dashoffset .12s linear;
}
.pull-icon { font-size: 17px; color: #16A34A; transition: opacity .15s ease, transform .25s ease; }
.pull-refresh.is-armed .pull-icon { transform: rotate(180deg); }
.pull-refresh.is-loading .pull-icon { opacity: 0; }
.pull-refresh.is-loading .pull-spinner { animation: pullSpin 0.8s linear infinite; }
.pull-refresh.is-loading .pull-arc { animation: pullArc 1.4s ease-in-out infinite; stroke-dashoffset: 22; }
@keyframes pullSpin { to { transform: rotate(360deg); } }
@keyframes pullArc {
  0%, 100% { stroke-dashoffset: 70; }
  50%      { stroke-dashoffset: 22; }
}

.pull-label {
  font-size: 11px; font-weight: 700;
  color: rgba(15,23,42,0.7);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  padding: 5px 10px; border-radius: 99px;
  box-shadow: 0 2px 6px rgba(15,23,42,0.10);
}

/* ---- 7. RECENT CARD FLIP ---- */
.recent-card { perspective: 800px; }
.recent-flip {
  position: relative;
  width: 100%; height: 100%;
  min-height: 100px;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.recent-card.flipped .recent-flip { transform: rotateY(180deg); }
.recent-face {
  display: block;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.recent-face.back {
  position: absolute; inset: 0;
  transform: rotateY(180deg);
  background: hsl(var(--card));
  border-radius: 12px;
  padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.recent-face.back .b-kind {
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--v6-muted);
}
.recent-face.back .b-name {
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 13px; font-weight: 700;
  color: var(--v6-ink); line-height: 1.25;
  flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.recent-face.back .b-when {
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 10.5px; color: var(--v6-muted);
  font-variant-numeric: tabular-nums;
}
.recent-face.back .b-cta {
  margin-top: 4px;
  background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--primary) / 0.85));
  color: #fff; border: 0;
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 11px; font-weight: 700;
  border-radius: 8px; padding: 6px 8px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer;
}
.recent-face.back .b-cta .material-symbols-outlined { font-size: 14px; }

/* Reduced-motion: skip flip + scene drift + spinner */
@media (prefers-reduced-motion: reduce) {
  .wx-scene .sun, .wx-scene .cloud, .wx-scene .star,
  .wx-scene .rain i, .wx-scene .bolt { animation: none !important; }
  .recent-flip { transition: none !important; }
  .pull-refresh.is-loading .pull-spinner { animation: none !important; }
  .pull-refresh.is-loading .pull-arc { animation: none !important; }
}

/* ============================================================
 * v7 TIER 3 — Confetti · Press depth · Skeleton shimmer · Sparkline
 * ============================================================ */

/* ---- 9. CONFETTI canvas ---- */
#confettiCanvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 999;
  opacity: 0;
  transition: opacity .25s ease;
}

/* ---- 10. PRESS DEPTH — layered iOS-grade shadows ---- */
/* Apply via the .v7-elev class. Two-layer shadow: a tight close one for
 * crispness + a soft far one for depth. On :active, both compress to
 * mimic the card pressing into the page.                              */
.v7-elev {
  box-shadow:
    0 1px 2px rgba(15,23,42,0.06),
    0 6px 20px -8px rgba(15,23,42,0.16);
  transition: box-shadow .22s ease, transform .12s ease;
}
.v7-elev:active {
  box-shadow:
    0 0.5px 1px rgba(15,23,42,0.05),
    0 1px 4px -1px rgba(15,23,42,0.10);
  transform: scale(0.985) translateY(0.5px);
}

/* Apply to the most-tapped surfaces. Don't pile on top of cards that
 * already define their own glow (CTA primary keeps its breathing
 * animation; we only deepen the secondary surfaces).                   */
.cta-special, .v6-tile, .recent-card, .wx-strip {
  box-shadow:
    0 1px 2px rgba(15,23,42,0.06),
    0 6px 18px -8px rgba(15,23,42,0.14);
  transition: box-shadow .22s ease, transform .12s ease;
}
.cta-special:active,
.v6-tile:active,
.recent-card:active,
.wx-strip:active {
  box-shadow:
    0 0.5px 1px rgba(15,23,42,0.05),
    0 1px 4px -1px rgba(15,23,42,0.09) !important;
}

/* ---- 11. RECENT RAIL SKELETON ---- */
.recent-rail .recent-skel {
  flex: 0 0 142px;
  background: hsl(var(--card)); border-radius: 12px; padding: 10px;
  box-shadow: var(--v6-shadow-sm);
  position: relative; overflow: hidden;
}
.recent-rail .recent-skel::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.55) 45%,
    rgba(255,255,255,0) 90%);
  transform: translateX(-100%);
  animation: v7Shimmer 1.4s linear infinite;
  z-index: 1;
}
@keyframes v7Shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.recent-rail .recent-skel .sk-thumb {
  height: 60px; border-radius: 8px;
  background: linear-gradient(135deg, hsl(var(--ios-gray-1)), hsl(var(--ios-gray-2)));
  margin-bottom: 8px;
}
.recent-rail .recent-skel .sk-bar {
  height: 9px; border-radius: 4px;
  background: hsl(var(--ios-gray-1));
  margin-bottom: 6px;
}
.recent-rail .recent-skel .sk-bar.short { width: 60%; }
.recent-rail .recent-skel .sk-bar.tiny  { width: 40%; height: 7px; }

/* ---- 12. HISTORY SPARKLINE ---- */
.spark-panel {
  background: linear-gradient(135deg, #fff, #F8FAFC);
  border: 1px solid var(--v6-line);
  border-radius: 14px;
  padding: 14px 14px 10px;
  margin: 0 0 14px;
  box-shadow:
    0 1px 2px rgba(15,23,42,0.04),
    0 6px 18px -10px rgba(15,23,42,0.10);
  position: relative; overflow: hidden;
}
.spark-panel[hidden] { display: none; }
.spark-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 8px;
}
.spark-title {
  display: flex; flex-direction: column;
  font-family: 'Noto Sans Lao', sans-serif;
}
.spark-eyebrow {
  font-size: 11px; font-weight: 700;
  color: var(--v6-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.spark-avg {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-size: 28px; font-weight: 800;
  color: #16A34A;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.spark-unit {
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 13px; font-weight: 600;
  color: var(--v6-muted);
  margin-left: -4px;
}
.spark-avg, .spark-unit { display: inline-block; vertical-align: baseline; }
.spark-title { display: flex; flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.spark-title .spark-eyebrow { width: 100%; margin-bottom: 2px; }
.spark-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  font-family: 'Noto Sans Lao', sans-serif;
}
.spark-trend {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 700; font-size: 12px;
  padding: 3px 8px; border-radius: 99px;
  background: rgba(15,23,42,0.06); color: var(--v6-muted);
}
.spark-trend.up   { background: rgba(22,163,74,0.12); color: #15803d; }
.spark-trend.down { background: rgba(239,68,68,0.12); color: #B91C1C; }
.spark-count { font-size: 10.5px; color: var(--v6-muted); font-variant-numeric: tabular-nums; }

.spark-svg {
  display: block; width: 100%; height: 56px;
  overflow: visible;
}
.spark-line {
  fill: none;
  stroke: #16A34A;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
  animation: sparkDraw 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.spark-fill {
  fill: url(#sparkFillGrad);
  opacity: 0;
  animation: sparkFade 0.7s ease 0.5s forwards;
}
.spark-dot {
  fill: #16A34A;
  filter: drop-shadow(0 0 4px rgba(22,163,74,0.7));
  opacity: 0;
  animation: sparkFade 0.4s ease 1.0s forwards, sparkDotPulse 1.6s ease-in-out 1.4s infinite;
}
@keyframes sparkDraw  { to { stroke-dashoffset: 0; } }
@keyframes sparkFade  { to { opacity: 1; } }
@keyframes sparkDotPulse {
  0%, 100% { transform-origin: center; r: 3; filter: drop-shadow(0 0 4px rgba(22,163,74,0.7)); }
  50%      { r: 4.5; filter: drop-shadow(0 0 8px rgba(22,163,74,0.85)); }
}

@media (prefers-reduced-motion: reduce) {
  .recent-rail .recent-skel::before { animation: none !important; }
  .spark-line, .spark-fill, .spark-dot { animation: none !important; opacity: 1; stroke-dashoffset: 0; }
  #confettiCanvas { display: none !important; }
}

/* ============================================================
 * v2 — WX MODAL TIER A : Rain banner · Hi/Lo pills · Hourly graph · PM advice
 * ============================================================ */

/* ---- ② Next-rain banner ---- */
.wxm-rain-banner {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px;
  align-items: center;
  background: linear-gradient(135deg, #3B82F6, #1E40AF);
  color: #fff;
  border-radius: 14px;
  padding: 11px 14px;
  box-shadow: 0 8px 22px -6px rgba(59,130,246,0.55);
  position: relative; overflow: hidden;
  animation: wxmBannerIn .55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.wxm-rain-banner[hidden] { display: none !important; }
.wxm-rain-banner::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(220px 120px at 85% 50%, rgba(255,255,255,0.18), transparent 65%);
}
@keyframes wxmBannerIn { from { opacity: 0; transform: translateY(-8px) scale(0.96); } }
.wxm-rain-banner .ic {
  width: 34px; height: 34px; border-radius: 11px;
  background: rgba(255,255,255,0.22);
  display: grid; place-items: center;
  position: relative; z-index: 1;
}
.wxm-rain-banner .ic .material-symbols-outlined {
  font-size: 19px;
  animation: wxmDropFall 1.4s ease-in-out infinite;
}
@keyframes wxmDropFall { 0%,100%{transform:translateY(0)} 50%{transform:translateY(2px)} }
.wxm-rain-banner .copy { position: relative; z-index: 1; }
.wxm-rain-banner .head {
  font-family: 'Noto Sans Lao', sans-serif;
  font-weight: 700; font-size: 13px; line-height: 1.25;
}
.wxm-rain-banner .sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; opacity: .88;
  margin-top: 2px; letter-spacing: 0.04em;
}
.wxm-rain-banner .pct {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 800; font-size: 22px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  position: relative; z-index: 1; line-height: 1;
}
.wxm-rain-banner .pct small {
  font-size: 0.55em; font-weight: 600; opacity: .85; margin-left: 1px;
}

/* ---- ③ Today high / low pills ---- */
.wxm-now-hilo {
  display: flex; gap: 8px; align-items: center;
  margin-top: 10px;
  position: relative; z-index: 1;
  animation: wxmHiloIn .9s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: .12s;
}
.wxm-now-hilo[hidden] { display: none !important; }
@keyframes wxmHiloIn { from { opacity: 0; transform: translateY(6px); } }
.wxm-now-hilo .pill {
  display: inline-flex; gap: 4px; align-items: center;
  background: rgba(255,255,255,0.22);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 4px 10px; border-radius: 99px;
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 700; font-size: 12px;
  font-variant-numeric: tabular-nums;
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
}
.wxm-now-hilo .pill .arrow { font-size: 11px; line-height: 1; }
.wxm-now-hilo .pill.high  { background: rgba(255,140,90,0.34); border-color: rgba(255,140,90,0.45); }
.wxm-now-hilo .pill.low   { background: rgba(140,180,255,0.34); border-color: rgba(140,180,255,0.45); }
.wxm-now-hilo .pill-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; opacity: .85; margin-left: auto; color: #fff;
}

/* ---- ① Hourly graph (replaces flat .wxm-hourly row) ---- */
.wxm-hourly-graph {
  position: relative; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 4px -2px 0;
  padding: 4px 2px 6px;
}
.wxm-hourly-graph::-webkit-scrollbar { display: none; }
.wxm-hg-inner {
  position: relative;
  /* width set inline by JS as N * cell_w */
}
.wxm-hg-svg {
  position: absolute; left: 0; top: 22px;
  height: 60px; pointer-events: none;
  z-index: 1; overflow: visible;
}
.wxm-hg-line {
  fill: none;
  stroke: #FF6B35;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: wxmLineDraw 1.4s cubic-bezier(0.22, 1, 0.36, 1) .25s forwards;
}
@keyframes wxmLineDraw { to { stroke-dashoffset: 0; } }
.wxm-hg-fill {
  fill: url(#wxmTempGrad);
  opacity: 0;
  animation: wxmFillIn .65s ease 1.05s forwards;
}
@keyframes wxmFillIn { to { opacity: 0.45; } }
.wxm-hg-dot {
  fill: #FF6B35;
  filter: drop-shadow(0 0 4px rgba(255,107,53,0.7));
  opacity: 0;
  animation: wxmFillIn .35s ease 1.4s forwards, wxmDotPulse 1.6s ease-in-out 1.8s infinite;
}
@keyframes wxmDotPulse {
  0%, 100% { r: 3.5; }
  50%      { r: 5;   filter: drop-shadow(0 0 7px rgba(255,107,53,0.9)); }
}
.wxm-hg-row {
  position: relative; z-index: 2;
  display: flex; align-items: stretch;
}
.wxm-hg-cell {
  position: relative;
  flex: 0 0 50px;
  height: 100px;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 4px 2px 0;
  text-align: center;
}
.wxm-hg-cell .h-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; font-weight: 700; color: var(--v6-muted);
  letter-spacing: 0.03em;
}
.wxm-hg-cell .h-icon {
  font-size: 18px; line-height: 1;
  margin-top: 2px;
}
.wxm-hg-cell .h-icon .material-symbols-outlined { font-size: 18px; }
.wxm-hg-cell .h-temp {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-weight: 800; font-size: 12px;
  letter-spacing: -0.02em;
  color: #FF6B35;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.wxm-hg-cell .h-rainpct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px; font-weight: 700;
  color: #2563EB;
  margin-top: 1px;
}
/* Rain bar at bottom of each cell */
.wxm-hg-cell .rain-bar {
  position: absolute; bottom: 4px;
  left: 22%; right: 22%;
  background: linear-gradient(180deg, #3B82F6, #1E40AF);
  border-radius: 3px 3px 0 0;
  transform-origin: bottom;
  animation: wxmBarRise .9s cubic-bezier(0.22, 1, 0.36, 1) 1.2s both;
  z-index: 0;
}
@keyframes wxmBarRise { from { transform: scaleY(0); } }
.wxm-hg-cell.now {
  background: linear-gradient(180deg, rgba(255,162,62,0.16), transparent 75%);
  border-radius: 9px;
}
.wxm-hg-cell.now .h-time { color: #D27530; font-weight: 800; }
.wxm-hg-cell.peak .rain-bar {
  background: linear-gradient(180deg, #EF4444, #B91C1C);
  box-shadow: 0 0 8px rgba(239,68,68,0.55);
}
.wxm-hg-cell.peak .h-rainpct { color: #DC2626; }

.wxm-graph-legend {
  display: flex; gap: 14px; justify-content: flex-end;
  padding: 4px 6px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.04em;
}
.wxm-graph-legend[hidden] { display: none !important; }
.wxm-graph-legend .lg-temp { color: #FF6B35; }
.wxm-graph-legend .lg-rain { color: #3B82F6; }

/* ---- ④ PM2.5 advice line ---- */
.wxm-extra-pm { padding-bottom: 10px; }
.wxm-extra-pm .pm-advice {
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 10.5px; line-height: 1.35;
  margin-top: 7px; padding-top: 7px;
  border-top: 1px solid rgba(0,0,0,0.06);
  color: var(--v6-muted);
  animation: wxmAdviceIn .55s ease .35s both;
}
.wxm-extra-pm .pm-advice[hidden] { display: none !important; }
@keyframes wxmAdviceIn { from { opacity: 0; } to { opacity: 1; } }
.wxm-extra-pm.adv-good      .pm-advice { color: #15803d; }
.wxm-extra-pm.adv-moderate  .pm-advice { color: #B45309; }
.wxm-extra-pm.adv-sensitive .pm-advice { color: #C2410C; }
.wxm-extra-pm.adv-unhealthy .pm-advice { color: #B91C1C; font-weight: 600; }
.wxm-extra-pm.adv-very      .pm-advice { color: #7F1D1D; font-weight: 700; }
.wxm-extra-pm.adv-hazardous .pm-advice { color: #fff; background: #7F1D1D; padding: 6px 8px; border-radius: 8px; border-top: 0; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .wxm-rain-banner .ic .material-symbols-outlined,
  .wxm-hg-line, .wxm-hg-fill, .wxm-hg-dot, .wxm-hg-cell .rain-bar { animation: none !important; }
  .wxm-hg-line { stroke-dashoffset: 0; }
  .wxm-hg-fill { opacity: 0.45; }
  .wxm-hg-dot  { opacity: 1; }
}

/* ============================================================
 * Plan screen — date-context banner (yesterday / N days ago)
 * Shown when planData.date isn't today, so inspector knows the
 * server fell back to an earlier operational date.
 * ============================================================ */
.plan-date-banner {
  background: linear-gradient(135deg, rgba(34,197,94,0.12), rgba(34,197,94,0.05));
  border: 1px solid rgba(34,197,94,0.28);
  border-radius: 11px;
  padding: 9px 12px;
  margin-bottom: 10px;
  font-family: 'Noto Sans Lao', sans-serif;
  font-size: 12px; font-weight: 700;
  color: #15803d;
  display: flex; align-items: center; gap: 7px;
  animation: planBannerIn .5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.plan-date-banner[hidden] { display: none !important; }
.plan-date-banner .material-symbols-outlined { font-size: 15px; }
.plan-date-banner .meta {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 700;
  color: #166534; opacity: .85;
  font-variant-numeric: tabular-nums;
}
@keyframes planBannerIn { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) {
  .plan-date-banner { animation: none !important; }
}

/* ============================================================
   SITES TIER A — toolbar (search + chips), rich cards
   ============================================================ */
.sites-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.sites-search {
  position: relative;
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  background: hsl(var(--card));
  border-radius: 12px;
  height: 40px;
  box-shadow: 0 0 0 0.5px var(--hairline);
}
.sites-search-icon {
  grid-column: 1;
  font-size: 20px;
  color: hsl(var(--ios-label-3));
  justify-self: center;
}
.sites-search-input {
  grid-column: 2;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 15px;
  color: hsl(var(--foreground));
  padding: 0 4px;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
.sites-search-input::placeholder { color: hsl(var(--ios-label-3)); }
.sites-search-input::-webkit-search-decoration,
.sites-search-input::-webkit-search-cancel-button { display: none; }
.sites-search-clear {
  grid-column: 3;
  width: 36px; height: 36px;
  border: 0; background: transparent;
  display: grid; place-items: center;
  color: hsl(var(--ios-label-3));
  cursor: pointer;
}
.sites-search-clear .material-symbols-outlined { font-size: 18px; }

.sites-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px 0;
  margin: -1px 0;
}
.sites-chips::-webkit-scrollbar { display: none; }
.sites-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px;
  border: 0.5px solid var(--hairline);
  background: hsl(var(--card));
  color: hsl(var(--ios-label-2));
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms, color 120ms, border-color 120ms, transform 120ms;
}
.sites-chip:active { transform: scale(0.96); }
.sites-chip.is-active {
  background: hsl(var(--primary));
  color: #fff;
  border-color: hsl(var(--primary));
}
.sites-chip-star {
  font-size: 12px;
  color: hsl(48 100% 55%);
  text-shadow: 0 0 2px rgba(0,0,0,.18);
  transform: translateY(-0.5px);
}
.sites-chip.is-active .sites-chip-star { color: #fff; }

/* When .site-card cards are present, drop the inset list wrapper */
.sites-list:has(.site-card) {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  display: grid;
  gap: 8px;
}

.site-card {
  display: grid !important;
  grid-template-columns: 48px 1fr 18px !important;
  align-items: center;
  gap: 12px;
  padding: 12px !important;
  background: hsl(var(--card));
  border: 0;
  border-radius: 14px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: 0 0 0 0.5px var(--hairline);
  transition: transform 120ms, box-shadow 120ms, background 120ms;
}
.site-card:active {
  transform: scale(0.985);
  background: hsl(var(--ios-gray-2));
}
.site-card-thumb {
  position: relative;
  width: 48px; height: 48px;
  border-radius: 12px;
  background: linear-gradient(180deg, hsl(var(--primary) / 0.12), hsl(var(--primary) / 0.04));
  display: grid; place-items: center;
  color: hsl(var(--primary));
}
.site-card-thumb .material-symbols-outlined { font-size: 24px; }
.site-card-dot {
  position: absolute;
  top: -2px; right: -2px;
  width: 12px; height: 12px;
  border-radius: 999px;
  background: hsl(var(--ios-gray-3));
  box-shadow: 0 0 0 2px hsl(var(--card));
}
.site-card-dot-today   { background: #34c759; box-shadow: 0 0 0 2px hsl(var(--card)), 0 0 8px rgba(52,199,89,0.6); }
.site-card-dot-recent  { background: #007aff; box-shadow: 0 0 0 2px hsl(var(--card)); }
.site-card-dot-overdue { background: #ff9500; box-shadow: 0 0 0 2px hsl(var(--card)); }
.site-card-dot-never   { background: #8e8e93; box-shadow: 0 0 0 2px hsl(var(--card)); }

.site-card-body { min-width: 0; display: grid; gap: 3px; }
.site-card-row {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.site-card-name {
  flex: 1 1 auto;
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: hsl(var(--foreground));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.005em;
}
.site-card-sub {
  font-size: 12px;
  color: hsl(var(--ios-label-2));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-card-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 1px; }
.site-card-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.site-card-chip .material-symbols-outlined {
  font-size: 12px;
  font-variation-settings: 'FILL' 0, 'wght' 600, 'opsz' 20;
}
.site-card-chip-today   { background: rgba(52,199,89,0.14);  color: #1f7a39; }
.site-card-chip-recent  { background: rgba(0,122,255,0.10);  color: #0a59c4; }
.site-card-chip-overdue { background: rgba(255,149,0,0.14);  color: #b46500; }
.site-card-chip-never   { background: hsl(var(--ios-gray-2));color: hsl(var(--ios-label-2)); }

.site-card-chev {
  font-size: 18px;
  color: hsl(var(--ios-label-3));
  justify-self: center;
}

.sites-search-empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 36px 12px;
  color: hsl(var(--ios-label-2));
  text-align: center;
}
.sites-search-empty .material-symbols-outlined {
  font-size: 36px;
  color: hsl(var(--ios-label-3));
}
.sites-search-empty h3 { font-size: 15px; font-weight: 700; margin: 4px 0 0; }
.sites-search-empty p  { font-size: 12px; margin: 0; }

.site-card {
  animation: siteCardIn 280ms cubic-bezier(.22, 1, .36, 1) both;
  animation-delay: calc(var(--idx, 0) * 22ms);
}
@keyframes siteCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .site-card, .sites-chip { transition: none !important; animation: none !important; }
}

/* ============================================================
   SITES MAP VIEW — full-bleed Leaflet, status ribbon, recenter FAB,
   snap-to bottom sheet. Pattern matches QC Dashboard's Page_InspectorMap.
   ============================================================ */
:root {
  --sm-z-map: 1;
  --sm-z-overlay: 600;
  --sm-z-fab: 700;
  --sm-z-sheet: 800;
}
.sites-map-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0b1320;
  animation: smMapIn 260ms cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes smMapIn {
  from { opacity: 0; transform: scale(1.015); }
  to   { opacity: 1; transform: scale(1); }
}
.sites-map-view .sm-ribbon { animation: smRibbonIn 320ms cubic-bezier(.22, 1, .36, 1) both 60ms; }
.sites-map-view .sm-fab    { animation: smFabIn   320ms cubic-bezier(.22, 1, .36, 1) both 100ms; }
.sites-map-view .sm-sheet  { animation: smSheetIn 360ms cubic-bezier(.22, 1, .36, 1) both 80ms; }
@keyframes smRibbonIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes smFabIn    { from { opacity: 0; transform: scale(0.6); }       to { opacity: 1; transform: scale(1); } }
@keyframes smSheetIn  { from { transform: translateY(100%); }              to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .sites-map-view,
  .sites-map-view .sm-ribbon,
  .sites-map-view .sm-fab,
  .sites-map-view .sm-sheet { animation: none !important; }
}
.sites-map-leaflet {
  position: absolute !important;
  inset: 0 !important;
  z-index: var(--sm-z-map) !important;
  background: #0b1320;
  touch-action: none;
}
.sites-map-leaflet .leaflet-tile { filter: saturate(0.85) brightness(0.92); }

/* Leaflet's leaflet.css sets .leaflet-container to Helvetica/Arial which
   has no Lao glyphs — strip that fallback so popups/tooltips/anything
   inside the map renders in Noto Sans Lao. Excludes icon font spans. */
.sites-map-leaflet.leaflet-container,
.sites-map-leaflet .leaflet-container,
.sm-popup,
.sm-popup .leaflet-popup-content-wrapper,
.sm-popup .leaflet-popup-content,
.sm-popup .leaflet-popup-content *:not(.material-symbols-outlined),
.sm-tooltip {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif !important;
}
/* Keep icon font intact — wins over the override above */
.sm-popup .leaflet-popup-content .material-symbols-outlined {
  font-family: 'Material Symbols Outlined' !important;
}

/* Status ribbon — top, blur backdrop */
.sm-ribbon {
  position: absolute;
  left: 12px; right: 12px;
  top: calc(env(safe-area-inset-top, 0) + 10px);
  height: 44px;
  z-index: var(--sm-z-overlay);
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 8px;
  background: rgba(20, 26, 40, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 14px;
  border: 0.5px solid rgba(255,255,255,0.08);
  padding: 0 10px 0 6px;
  box-shadow: 0 6px 22px rgba(0,0,0,0.32);
}
.sm-ribbon-back {
  width: 32px; height: 32px;
  border: 0; background: transparent;
  display: grid; place-items: center;
  color: #e7ecf6;
  cursor: pointer;
  border-radius: 999px;
}
.sm-ribbon-back:active { background: rgba(255,255,255,0.08); }
.sm-ribbon-back .material-symbols-outlined { font-size: 18px; }
.sm-ribbon-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  align-items: center;
}
.sm-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #b8c2dc;
  font-family: 'JetBrains Mono', monospace;
}
.sm-stat i {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: #8e8e93;
  flex: 0 0 8px;
}
.sm-stat b {
  color: #e7ecf6;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sm-stat em { font-style: normal; opacity: 0.65; font-size: 10px; }
.sm-stat-today   i { background: #34c759; box-shadow: 0 0 6px rgba(52,199,89,0.7); }
.sm-stat-recent  i { background: #5ac8fa; }
.sm-stat-overdue i { background: #ff9500; }
.sm-stat-never   i { background: #8e8e93; }

/* Recenter FAB — top-right */
.sm-fab {
  position: absolute;
  z-index: var(--sm-z-fab);
  width: 38px; height: 38px;
  border: 0;
  border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(20, 26, 40, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: #5ac8fa;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.32);
  border: 0.5px solid rgba(255,255,255,0.08);
}
.sm-fab:active { transform: scale(0.96); }
.sm-fab .material-symbols-outlined { font-size: 18px; }
.sm-fab-recenter {
  right: 12px;
  top: calc(env(safe-area-inset-top, 0) + 64px);
}

/* Bottom snap-to sheet */
.sm-sheet {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  z-index: var(--sm-z-sheet);
  background: rgba(15, 20, 32, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border-top: 0.5px solid rgba(255,255,255,0.10);
  color: #e7ecf6;
  display: grid;
  grid-template-rows: 22px 38px 1fr;
  height: 64px;
  transition: height 280ms cubic-bezier(.22,1,.36,1);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sm-sheet[data-snap="peek"] { height: calc(64px + env(safe-area-inset-bottom, 0)); }
.sm-sheet[data-snap="mid"]  { height: calc(45vh + env(safe-area-inset-bottom, 0)); }
.sm-sheet[data-snap="full"] { height: calc(86vh + env(safe-area-inset-bottom, 0)); }

.sm-sheet-handle {
  cursor: pointer;
  display: grid; place-items: center;
  -webkit-tap-highlight-color: transparent;
}
.sm-sheet-handle span {
  display: block;
  width: 36px; height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
}
.sm-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.sm-sheet-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  color: #e7ecf6;
}
.sm-sheet-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #8893ad;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 2px 8px;
}
.sm-sheet-list {
  overflow-y: auto;
  padding: 4px 8px 14px;
  display: grid;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}
.sm-sheet-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border: 0.5px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  color: #e7ecf6;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 120ms;
}
.sm-sheet-row:active { background: rgba(255,255,255,0.07); }
.sm-sheet-name {
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sm-sheet-ago {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: #8893ad;
  font-variant-numeric: tabular-nums;
}
.sm-sheet-row .site-route-tag {
  background: rgba(255,255,255,0.08);
  color: #e7ecf6;
}
.sm-sheet-row-nogps { opacity: 0.55; }
.sm-sheet-dot {
  width: 12px; height: 12px;
  border-radius: 999px;
  display: inline-block;
  position: relative;
}

/* Pin styles for both Leaflet markers and sheet rows */
.sm-pin-wrap { background: transparent !important; border: 0 !important; }
.sm-pin {
  position: relative;
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 999px;
  background: rgba(0,0,0,0.0);
}
.sm-pin i {
  position: absolute;
  left: 50%; top: 50%;
  width: 14px; height: 14px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.sm-pin-today   i { background: #34c759; }
.sm-pin-recent  i { background: #5ac8fa; }
.sm-pin-overdue i { background: #ff9500; }
.sm-pin-never   i { background: #8e8e93; }
.sm-pin-today::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 22px; height: 22px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: rgba(52,199,89,0.45);
  animation: smPinPulse 1.6s ease-out infinite;
}
@keyframes smPinPulse {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}
.sm-tooltip {
  background: rgba(20, 26, 40, 0.94) !important;
  color: #e7ecf6 !important;
  border: 0.5px solid rgba(255,255,255,0.10) !important;
  border-radius: 8px !important;
  padding: 5px 10px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35) !important;
}
.sm-tooltip::before { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .sm-pin-today::before { animation: none !important; }
  .sm-sheet { transition: none !important; }
}

/* Hide the bottom tab bar while map view is active — map is immersive,
   the back arrow in the ribbon returns to the list (which restores tabs). */
body.sites-map-active .tab-bar { display: none !important; }

/* Leaflet popup styled to match the dark glass theme — compact card,
   no close button (tap elsewhere to dismiss, matching QC Dashboard). */
.sm-popup .leaflet-popup-content-wrapper {
  background: rgba(20, 26, 40, 0.96);
  color: #e7ecf6;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  border: 0.5px solid rgba(255,255,255,0.10);
  padding: 0;
  overflow: hidden;
}
.sm-popup .leaflet-popup-content {
  margin: 0;
  padding: 11px 12px 10px;
  width: auto !important;
  font: inherit;
  line-height: 1.35;
}
.sm-popup .leaflet-popup-tip {
  background: rgba(20, 26, 40, 0.96);
  box-shadow: none;
  border: 0.5px solid rgba(255,255,255,0.10);
  border-top: 0;
  border-left: 0;
}

/* Entry animation — animate INNER elements only; the outer .leaflet-popup
   is positioned by Leaflet via inline transform and must not be touched. */
.sm-popup .leaflet-popup-content-wrapper {
  transform-origin: 50% 100%;
  animation: smPopWrapIn 240ms cubic-bezier(.22, 1, .36, 1) both;
}
.sm-popup .leaflet-popup-tip {
  transform-origin: 50% 0%;
  animation: smPopTipIn 240ms cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes smPopWrapIn {
  from { opacity: 0; transform: translateY(6px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
@keyframes smPopTipIn {
  from { opacity: 0; transform: rotate(45deg) scale(0.6); }
  to   { opacity: 1; transform: rotate(45deg) scale(1); }
}

.sm-pop { display: grid; gap: 6px; }
.sm-pop-row {
  display: flex; align-items: flex-start; gap: 8px;
}
.sm-pop-dot {
  width: 14px; height: 14px;
  flex: 0 0 14px;
  position: relative;
  margin-top: 2px;
}
.sm-pop-name {
  flex: 1 1 auto;
  min-width: 0;
  font-family: 'Noto Sans Lao', 'Noto Sans', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #e7ecf6;
  letter-spacing: -0.005em;
  /* Allow wrapping so long Lao names don't blow out the popup width.
     Cap to 2 lines via line-clamp; overflow ellipsises cleanly. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.sm-pop-row .site-route-tag {
  flex: 0 0 auto;
  margin-top: 1px;
}
.sm-pop-sub {
  font-size: 11.5px;
  color: #b8c2dc;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sm-pop-meta { display: flex; gap: 6px; }
.sm-pop-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.sm-pop-chip-today   { background: rgba(52,199,89,0.18);  color: #6ee08a; }
.sm-pop-chip-recent  { background: rgba(90,200,250,0.18); color: #79d4ff; }
.sm-pop-chip-overdue { background: rgba(255,149,0,0.18);  color: #ffb84a; }
.sm-pop-chip-never   { background: rgba(255,255,255,0.08);color: #b8c2dc; }

.sm-pop-actions {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 6px;
  margin-top: 4px;
}
.sm-pop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 100ms, background 120ms, color 120ms;
}
.sm-pop-btn:active { transform: scale(0.97); }
.sm-pop-btn .material-symbols-outlined { font-size: 14px; }
.sm-pop-btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #e7ecf6;
}
.sm-pop-btn-secondary:active { background: rgba(255,255,255,0.14); }
.sm-pop-btn-primary {
  background: #007aff;
  color: #fff;
}
.sm-pop-btn-primary:active { background: #0a59c4; }

@media (prefers-reduced-motion: reduce) {
  .sm-popup.leaflet-popup,
  .sm-popup .leaflet-popup-content-wrapper,
  .sm-popup .leaflet-popup-tip {
    animation: none !important;
  }
}

/* ============================================================
   NOTIFICATION DETAIL POPUP
   Opened by tapping a notification card. Shows full body +
   metadata + an explicit "Confirm Read" CTA.
   ============================================================ */
#notifDetailBackdrop { z-index: 220; }
.notif-detail-sheet { z-index: 221; max-height: 82dvh !important; }

.notif-detail-content {
  display: flex; flex-direction: column; gap: 14px;
  padding-bottom: 4px;
}

.notif-detail-hero {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(116, 255, 138, 0.08), rgba(122, 184, 255, 0.06));
  border: 1px solid rgba(15, 23, 42, 0.06);
}
.notif-detail-hero.broadcast {
  background: linear-gradient(135deg, rgba(122, 184, 255, 0.14), rgba(122, 184, 255, 0.04));
  border-color: rgba(59, 130, 201, 0.18);
}
.notif-detail-hero.route {
  background: linear-gradient(135deg, rgba(196, 168, 255, 0.16), rgba(196, 168, 255, 0.04));
  border-color: rgba(140, 100, 220, 0.20);
}
.notif-detail-hero.incident,
.notif-detail-hero.alert {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.14), rgba(255, 179, 71, 0.06));
  border-color: rgba(255, 107, 107, 0.22);
}
.notif-detail-hero.meeting {
  background: linear-gradient(135deg, rgba(116, 255, 138, 0.14), rgba(116, 255, 138, 0.04));
  border-color: rgba(46, 160, 67, 0.18);
}

.notif-detail-icon {
  width: 44px; height: 44px; border-radius: 13px;
  background: rgba(15, 23, 42, 0.06);
  display: grid; place-items: center;
}
.notif-detail-icon .material-symbols-outlined {
  font-size: 24px; color: var(--v6-ink);
}
.notif-detail-headline {
  font-size: 18px; font-weight: 800; letter-spacing: -0.01em;
  line-height: 1.25; color: var(--v6-ink);
  word-break: break-word;
}

.notif-detail-body {
  font-size: 14.5px; line-height: 1.55;
  color: var(--v6-ink);
  background: var(--v6-bg);
  border-radius: 14px;
  padding: 14px 16px;
  white-space: pre-wrap; word-break: break-word;
}

.notif-detail-meta {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--v6-bg);
  border-radius: 14px;
  padding: 6px 10px;
}
.notif-detail-row {
  display: grid; grid-template-columns: 22px auto 1fr;
  align-items: center; gap: 10px;
  padding: 9px 6px;
  font-size: 13px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}
.notif-detail-row:last-child { border-bottom: 0; }
.notif-detail-row .material-symbols-outlined {
  font-size: 18px; color: var(--v6-muted);
}
.notif-detail-row .l { color: var(--v6-muted); font-size: 12px; font-weight: 600; }
.notif-detail-row .v { color: var(--v6-ink); font-weight: 600; text-align: right; word-break: break-word; }

.notif-detail-footer {
  flex: none;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  background: hsl(var(--card));
}
.notif-detail-btn {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px;
  padding: 14px 16px;
  font-family: inherit; font-size: 15px; font-weight: 800;
  letter-spacing: 0.01em; cursor: pointer;
  transition: transform 0.12s ease, background 0.18s ease, opacity 0.18s ease;
}
.notif-detail-btn.primary {
  background: var(--v6-primary, #0a66ff); color: #fff;
}
.notif-detail-btn.primary:hover { filter: brightness(1.03); }
.notif-detail-btn.primary:active { transform: scale(0.98); }
.notif-detail-btn.primary .material-symbols-outlined { font-size: 20px; }
.notif-detail-btn.done,
.notif-detail-btn:disabled {
  background: rgba(46, 160, 67, 0.16);
  color: #1f7a3a;
  cursor: default;
  opacity: 0.95;
}
.notif-detail-btn.done .material-symbols-outlined,
.notif-detail-btn:disabled .material-symbols-outlined {
  color: #1f7a3a;
}

/* Card hover: hint that tapping opens details */
.notif-card { cursor: pointer; }
.notif-card:active { transform: scale(0.997); }

/* ===== QUICK REPLY ACTION BUTTONS (notif detail footer) ===== */
.notif-detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.notif-detail-actions.single {
  grid-template-columns: 1fr;
}
.notif-detail-actions.single .notif-detail-action {
  flex-direction: row;
  min-height: 52px;
  font-size: 15px;
  padding: 14px 16px;
}
.notif-detail-actions.single .notif-detail-action .material-symbols-outlined {
  font-size: 20px;
}
.notif-detail-action {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  background: var(--v6-bg);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  font-family: inherit; font-size: 12px; font-weight: 700;
  color: var(--v6-ink); cursor: pointer;
  transition: transform 0.12s ease, background 0.18s ease, border-color 0.18s ease;
  min-height: 70px;
}
.notif-detail-action .material-symbols-outlined { font-size: 22px; }
.notif-detail-action:active { transform: scale(0.97); }
.notif-detail-action.onit {
  background: rgba(46, 160, 67, 0.10);
  border-color: rgba(46, 160, 67, 0.28);
  color: #1f7a3a;
}
.notif-detail-action.onit:active { background: rgba(46, 160, 67, 0.18); }
.notif-detail-action.need {
  background: rgba(255, 165, 0, 0.10);
  border-color: rgba(255, 165, 0, 0.30);
  color: #b56700;
}
.notif-detail-action.need:active { background: rgba(255, 165, 0, 0.18); }
.notif-detail-action.cant {
  background: rgba(220, 53, 69, 0.08);
  border-color: rgba(220, 53, 69, 0.28);
  color: #b02a37;
}
.notif-detail-action.cant:active { background: rgba(220, 53, 69, 0.16); }

.notif-detail-responded {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  background: rgba(46, 160, 67, 0.12);
  border: 1px solid rgba(46, 160, 67, 0.30);
  border-radius: 14px;
  padding: 14px;
  font-size: 14px; font-weight: 700; color: #1f7a3a;
}
.notif-detail-responded .material-symbols-outlined { font-size: 22px; }

/* ===== PER-CATEGORY PUSH SUB-TOGGLES ===== */
.push-cat-group {
  margin: -6px 12px 8px;
  padding: 6px 8px;
  background: rgba(15, 23, 42, 0.03);
  border-radius: 12px;
  display: flex; flex-direction: column;
}
.push-cat-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}
.push-cat-row:last-child { border-bottom: 0; }
.push-cat-row .cat-icn {
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(122, 184, 255, 0.10);
  display: grid; place-items: center;
}
.push-cat-row .cat-icn .material-symbols-outlined {
  font-size: 16px; color: var(--v6-primary, #0a66ff);
}
.push-cat-row .cat-lbl {
  font-size: 13px; font-weight: 600; color: var(--v6-ink);
}
.toggle-switch.small { width: 38px; height: 22px; }
.toggle-switch.small .toggle-slider::before {
  width: 18px; height: 18px; left: 2px; top: 2px;
}
.toggle-switch.small input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

/* ===== SW UPDATE BANNER (Patrol PWA) ===== */
.sw-update-banner {
  position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top, 12px));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 16px;
  background: #0f172a; color: #fff;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
  z-index: 9000;
  animation: ubSlideIn 0.25s ease both;
  max-width: calc(100vw - 24px);
}
.sw-update-banner.hiding { animation: ubSlideOut 0.22s ease both; }
@keyframes ubSlideIn { from { transform: translate(-50%, -120%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes ubSlideOut { to { transform: translate(-50%, -120%); opacity: 0; } }
.sw-update-banner .ub-btn {
  background: #74ff8a; color: #042a0d;
  border: 0; border-radius: 8px;
  padding: 6px 12px;
  font-family: inherit; font-weight: 800; font-size: 12.5px;
  cursor: pointer;
}
.sw-update-banner .ub-btn:hover { filter: brightness(1.05); }
.sw-update-banner .ub-x {
  background: transparent; border: 0; color: #94a3b8;
  font-size: 18px; line-height: 1; cursor: pointer; padding: 4px 6px;
}
.sw-update-banner .ub-x:hover { color: #fff; }

/* ============================================================
   REST DAYS (self-service) feature
   Numbers/dates use 'Noto Sans' (.rd-num); all Lao chrome stays
   in the global Noto Sans Lao stack.
   ============================================================ */
.rd-num { font-family: 'Noto Sans', sans-serif; font-variant-numeric: tabular-nums; }

/* home entry tile */
.cta-rest { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 15px 18px; border: 1.5px solid rgba(22,163,74,.30); border-radius: 16px; background: #fff; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03); font-family: inherit; }
.cta-rest:active { transform: scale(.985); }
.action-stack .cta-rest .cta-icon { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, rgba(22,163,74,.18), rgba(22,163,74,.06)); display: grid; place-items: center; flex: none; }
.action-stack .cta-rest .cta-icon .material-symbols-outlined { color: #15803D; font-size: 24px; }
.cta-rest .cta-stack { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.cta-rest .cta-stack small { font-size: 11px; font-weight: 600; color: #64748B; }
.cta-rest .cta-stack strong { font-size: 17px; font-weight: 800; color: #0F172A; }
.cta-rest .rd-right { display: flex; align-items: center; gap: 8px; flex: none; }
.rd-new-pill { font-size: 11px; font-weight: 800; letter-spacing: .04em; color: #fff; background: #16A34A; padding: 3px 8px; border-radius: 7px; text-transform: uppercase; }
.cta-rest .rd-chev { color: #64748B; font-size: 22px; }

/* segmented control */
.rd-seg { display: flex; background: rgba(60,60,67,.06); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.rd-seg button { flex: 1; border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 600; color: #0F172A; padding: 8px; border-radius: 9px; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; transition: all .25s cubic-bezier(.34,1.56,.64,1); }
.rd-seg button .material-symbols-outlined { font-size: 18px; }
.rd-seg button.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* summary stats */
.rd-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.rd-stat { background: #fff; border: 1px solid rgba(60,60,67,.08); border-radius: 16px; padding: 13px 15px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.rd-stat .k { font-size: 12px; color: #64748B; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.rd-stat .k .material-symbols-outlined { font-size: 16px; }
.rd-stat .v { font-family: 'Noto Sans', sans-serif; font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.rd-stat .v.blue { color: #15803D; }
.rd-stat .v.amber { color: #B45309; }

/* calendar */
.rd-cal-card { background: #fff; border: 1px solid rgba(60,60,67,.08); border-radius: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); padding: 14px; margin-bottom: 14px; }
.rd-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.rd-cal-head .mo { font-size: 17px; font-weight: 800; letter-spacing: -.02em; color: #0F172A; }
.rd-cal-nav { display: flex; gap: 6px; }
.rd-cal-nav button { width: 32px; height: 32px; border-radius: 8px; background: rgba(60,60,67,.06); color: #15803D; display: grid; place-items: center; border: 0; cursor: pointer; }
.rd-dow { display: grid; grid-template-columns: repeat(7,1fr); margin-bottom: 6px; }
.rd-dow span { text-align: center; font-size: 11px; font-weight: 700; color: #64748B; }
.rd-cal { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
.rd-cell { aspect-ratio: 1; border-radius: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-family: 'Noto Sans', sans-serif; font-size: 15px; font-weight: 600; color: #0F172A; position: relative; font-variant-numeric: tabular-nums; transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.rd-cell.pad { visibility: hidden; }
.rd-cell.has { cursor: pointer; background: rgba(60,60,67,.05); }
.rd-cell.has:active { transform: scale(.9); }
.rd-cell.addable { cursor: pointer; }
.rd-cell.addable:active { transform: scale(.9); background: rgba(22,163,74,.1); }
.rd-cell.today .num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #16A34A; color: #fff; }
.rd-dots { display: flex; gap: 3px; height: 6px; }
.rd-dots i { width: 6px; height: 6px; border-radius: 50%; }
.rd-dots i.normal { background: #16A34A; }
.rd-dots i.urgent { background: #F59E0B; }
.rd-dots i.pendreq { background: #8B5CF6; }
.rd-cell.pendreq { box-shadow: inset 0 0 0 1.5px rgba(139,92,246,.55); border-radius: 10px; }
.rd-legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: #64748B; }
.rd-legend span { display: flex; align-items: center; gap: 6px; }
.rd-legend i { width: 9px; height: 9px; border-radius: 50%; }
.rd-legend i.normal { background: #16A34A; }
.rd-legend i.urgent { background: #F59E0B; }
.rd-legend i.pendreq { background: #8B5CF6; }

/* list */
.rd-list-label { font-size: 12px; font-weight: 700; color: #64748B; text-transform: uppercase; letter-spacing: .03em; margin: 2px 12px 8px; }
.rd-inset { background: #fff; border-radius: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); overflow: hidden; border: 1px solid rgba(60,60,67,.08); }
.rd-lrow { display: flex; align-items: center; gap: 12px; padding: 13px 15px; border-bottom: 1px solid rgba(60,60,67,.08); }
.rd-lrow:last-child { border-bottom: 0; }
.rd-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.rd-ico .material-symbols-outlined { font-size: 22px; }
.rd-ico.normal { background: rgba(22,163,74,.12); color: #15803D; }
.rd-ico.urgent { background: rgba(245,158,11,.16); color: #B45309; }
.rd-ico.cancel { background: rgba(60,60,67,.08); color: #64748B; }
.rd-info { flex: 1; min-width: 0; }
.rd-info .t { font-weight: 700; font-size: 15px; color: #0F172A; display: flex; align-items: center; gap: 7px; }
.rd-info .s { font-size: 12.5px; color: #64748B; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.rd-lrow.cx .t { text-decoration: line-through; color: #64748B; }
.rd-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 9999px; }
.rd-badge.normal { background: rgba(22,163,74,.13); color: #15803D; }
.rd-badge.urgent { background: rgba(245,158,11,.16); color: #B45309; }
.rd-badge.cancel { background: rgba(60,60,67,.08); color: #64748B; }
.rd-chev { color: #64748B; font-size: 20px; opacity: .7; }
.rd-empty { padding: 38px 14px; text-align: center; color: #64748B; font-size: 14px; }

/* set button */
.rd-set-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; height: 50px; margin-top: 4px; border-radius: 12px; font-size: 16px; font-weight: 700; border: 0; cursor: pointer; background: #16A34A; color: #fff; box-shadow: 0 8px 20px rgba(22,163,74,.28); }
.rd-set-btn:active { transform: scale(.98); }

/* sheet */
.rd-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.34); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 1400; }
.rd-backdrop.open { opacity: 1; pointer-events: auto; }
.rd-sheet { position: fixed; left: 50%; transform: translate(-50%, 100%); bottom: 0; width: 100%; max-width: 440px; background: #F2F2F7; border-radius: 16px 16px 0 0; transition: transform .35s cubic-bezier(.34,1.56,.64,1); z-index: 1401; padding: 6px 16px 22px; max-height: 92%; overflow-y: auto; box-shadow: 0 -10px 40px rgba(15,23,42,.18); }
.rd-sheet.open { transform: translate(-50%, 0); }
.rd-handle { width: 36px; height: 5px; border-radius: 3px; background: rgba(60,60,67,.18); margin: 6px auto 14px; }
.rd-sheet h3 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; color: #0F172A; margin-bottom: 2px; }
.rd-sheet-sub { font-size: 13px; color: #64748B; margin-bottom: 16px; }
.rd-field { margin-bottom: 14px; }
.rd-field label { display: block; font-size: 12px; font-weight: 700; color: #64748B; text-transform: uppercase; letter-spacing: .03em; margin: 0 2px 8px; }
.rd-field input, .rd-field textarea { width: 100%; background: #fff; border: 1px solid rgba(60,60,67,.18); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 15px; color: #0F172A; resize: vertical; }
.rd-field input:focus, .rd-field textarea:focus { outline: none; border-color: #16A34A; box-shadow: 0 0 0 4px rgba(22,163,74,.14); }
.rd-typesel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rd-topt { background: #fff; border: 2px solid rgba(60,60,67,.18); border-radius: 16px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .2s; }
.rd-topt .material-symbols-outlined { font-size: 24px; color: #64748B; }
.rd-topt .nm { font-weight: 700; font-size: 15px; color: #0F172A; }
.rd-topt.on.normal { border-color: #16A34A; background: rgba(22,163,74,.06); }
.rd-topt.on.normal .material-symbols-outlined, .rd-topt.on.normal .nm { color: #15803D; }
.rd-topt.on.urgent { border-color: #F59E0B; background: rgba(245,158,11,.08); }
.rd-topt.on.urgent .material-symbols-outlined, .rd-topt.on.urgent .nm { color: #B45309; }
.rd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; height: 50px; margin-top: 8px; border-radius: 12px; font-size: 16px; font-weight: 700; border: 0; cursor: pointer; }
.rd-btn.primary { background: #16A34A; color: #fff; }
.rd-btn.ghost { background: rgba(60,60,67,.06); color: #0F172A; }
.rd-btn.danger { background: rgba(220,38,38,.08); color: #DC2626; }
.rd-btn:active { transform: scale(.98); }
.rd-btn:disabled { opacity: .55; pointer-events: none; }

/* guard-rail UI: urgent note + field hint */
.rd-warn { display: flex; align-items: center; gap: 8px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.32); color: #B45309; border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.rd-warn .material-symbols-outlined { font-size: 18px; flex: none; }
.rd-hint { font-size: 12px; color: #64748B; margin: 6px 2px 0; }

/* ---- v2: assigned lane markers ---- */
.rd-badge.asg { background: rgba(14,165,233,.14); color: #0369A1; }
.rd-badge.pend { background: rgba(245,158,11,.16); color: #B45309; }
.rd-badge.moved { background: rgba(14,165,233,.14); color: #0369A1; }
.rd-hmnote { font-size: 12px; color: #0369A1; font-weight: 600; }
.rda-hm { display: flex; gap: 9px; align-items: flex-start; margin-top: 10px; background: rgba(14,165,233,.08); border: 1px solid rgba(14,165,233,.24); border-radius: 12px; padding: 11px 13px; font-size: 13px; color: #0369A1; line-height: 1.45; }
.rda-hm .material-symbols-outlined { font-size: 19px; flex: none; }
.rd-dots i.asg { box-shadow: 0 0 0 2px rgba(14,165,233,.35); }
.rd-cell.asg.has { background: rgba(14,165,233,.08); }
.rd-cell.pending { box-shadow: inset 0 0 0 1.5px rgba(245,158,11,.55); }
.rd-cell.unseen::after { content: ''; position: absolute; top: 4px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: #F59E0B; }
.rd-ico { position: relative; }
.rd-newdot { position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: #F59E0B; box-shadow: 0 0 0 2px #fff; }

/* ---- v2: assigned-day management sheet ---- */
.rda-scrim { position: fixed; inset: 0; background: rgba(15,23,42,.34); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 1400; }
.rda-scrim.open { opacity: 1; pointer-events: auto; }
.rda-sheet { position: fixed; left: 50%; transform: translate(-50%, 100%); bottom: 0; width: 100%; max-width: 440px; background: #F2F2F7; border-radius: 16px 16px 0 0; transition: transform .35s cubic-bezier(.34,1.56,.64,1); z-index: 1401; padding: 6px 16px calc(22px + env(safe-area-inset-bottom)); max-height: 92%; overflow-y: auto; box-shadow: 0 -10px 40px rgba(15,23,42,.18); }
.rda-sheet.open { transform: translate(-50%, 0); }
.rda-sheet h3 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; color: #0F172A; margin: 4px 0 2px; }
.rda-sub { font-size: 13px; color: #64748B; margin-bottom: 14px; } .rda-sub b { color: #0F172A; }
.rda-lock { display: flex; gap: 9px; align-items: flex-start; background: rgba(14,165,233,.08); border: 1px solid rgba(14,165,233,.22); border-radius: 12px; padding: 11px 13px; font-size: 13px; color: #0369A1; line-height: 1.45; }
.rda-lock .material-symbols-outlined { font-size: 19px; flex: none; }
.rda-note { margin-top: 10px; font-size: 13.5px; color: #334155; font-style: italic; padding: 0 2px; }
.rda-seen { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; margin-top: 14px; height: 46px; border: 0; border-radius: 12px; background: #0EA5E9; color: #fff; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.rda-seen:active { transform: scale(.98); }
.rda-seenchip { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; padding: 7px 12px; border-radius: 99px; background: rgba(22,163,74,.12); color: #15803D; font-size: 13px; font-weight: 700; }
.rda-seenchip .material-symbols-outlined { font-size: 17px; }
.rda-pend { margin-top: 14px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); border-radius: 12px; padding: 12px 14px; }
.rda-pend .h { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 800; color: #B45309; }
.rda-pend .h .material-symbols-outlined { font-size: 18px; }
.rda-pend .x { margin-top: 5px; font-size: 13px; color: #92400E; }
.rda-withdraw { width: 100%; margin-top: 10px; height: 44px; border: 0; border-radius: 12px; background: rgba(60,60,67,.07); color: #0F172A; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.rda-rej { display: flex; gap: 9px; align-items: flex-start; margin-top: 14px; background: rgba(220,38,38,.07); border: 1px solid rgba(220,38,38,.24); border-radius: 12px; padding: 11px 13px; font-size: 13px; color: #B91C1C; line-height: 1.45; }
.rda-rej .material-symbols-outlined { font-size: 19px; flex: none; }
.rda-sec { margin: 18px 0 10px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #64748B; }
.rda-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rda-kb { display: flex; flex-direction: column; align-items: center; gap: 4px; background: #fff; border: 2px solid rgba(60,60,67,.16); border-radius: 14px; padding: 13px; font: inherit; font-size: 14px; font-weight: 700; color: #0F172A; cursor: pointer; transition: all .2s; }
.rda-kb .material-symbols-outlined { font-size: 22px; color: #64748B; }
.rda-kb.on { border-color: #0EA5E9; background: rgba(14,165,233,.07); color: #0369A1; }
.rda-kb.on .material-symbols-outlined { color: #0EA5E9; }
.rda-input { width: 100%; margin-top: 12px; background: #fff; border: 1px solid rgba(60,60,67,.18); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 15px; color: #0F172A; resize: vertical; }
.rda-input:focus { outline: none; border-color: #0EA5E9; box-shadow: 0 0 0 4px rgba(14,165,233,.14); }
.rda-submit { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; margin-top: 14px; height: 50px; border: 0; border-radius: 12px; background: #16A34A; color: #fff; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; box-shadow: 0 8px 20px rgba(22,163,74,.24); }
.rda-submit:active { transform: scale(.98); }

/* custom in-sheet date picker (Marketing V2 xcal panel, vanilla port) */
.rd-xdate { position: relative; display: flex; align-items: center; }
.rd-xdate-disp { width: 100%; background: #fff; border: 1px solid rgba(60,60,67,.18); border-radius: 12px; padding: 12px 42px 12px 14px; font: inherit; font-family: 'Noto Sans', sans-serif; font-variant-numeric: tabular-nums; font-size: 15px; color: #0F172A; cursor: pointer; min-height: 48px; }
.rd-xdate-disp:focus { outline: none; border-color: #16A34A; box-shadow: 0 0 0 4px rgba(22,163,74,.14); }
.rd-xdate-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 8px; background: rgba(22,163,74,.12); color: #15803D; cursor: pointer; display: grid; place-items: center; }
.rd-xdate-btn .material-symbols-outlined { font-size: 18px; }
.rd-xcal { margin-top: 10px; background: #fff; border: 1px solid rgba(60,60,67,.08); border-radius: 14px; box-shadow: 0 4px 8px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04); padding: 14px; }
.rd-xcal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rd-xcal-h .mo { font-weight: 700; font-size: 15px; letter-spacing: -.01em; color: #0F172A; }
.rd-xcal-h button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(60,60,67,.06); color: #475569; cursor: pointer; display: grid; place-items: center; transition: transform .15s, background .15s; }
.rd-xcal-h button:active { transform: scale(.9); }
.rd-xcal-wd { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; margin-bottom: 2px; }
.rd-xcal-wd .wd { font-size: 10px; font-weight: 700; color: #64748B; text-align: center; padding: 2px 0 4px; }
.rd-xcal-grid { display: grid; grid-template-columns: repeat(7,1fr); grid-auto-rows: 36px; gap: 3px; }
.rd-xcal-grid .day { position: relative; border: 0; background: none; border-radius: 9px; height: 36px; width: 100%; display: grid; place-items: center; font-family: 'Noto Sans', sans-serif; font-variant-numeric: tabular-nums; font-size: 14px; color: #0F172A; cursor: pointer; transition: transform .15s, background .15s, color .15s; }
.rd-xcal-grid .day:active { transform: scale(.9); }
.rd-xcal-grid .day.empty { visibility: hidden; cursor: default; }
.rd-xcal-grid .day.today::after { content: ''; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: #16A34A; }
.rd-xcal-grid .day.sel { background: #16A34A; color: #fff; font-weight: 700; }
.rd-xcal-grid .day.today.sel::after { background: #fff; }
.rd-xcal-grid .day.dis { color: #94a3b8; opacity: .4; text-decoration: line-through; cursor: not-allowed; pointer-events: none; }
.rd-xcal-foot { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(60,60,67,.08); }
.rd-xcal-foot button { border: 0; background: none; color: #16A34A; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; padding: 4px 6px; }

/* mobile popup panel (bottom sheet + scrim) housing the calendar */
.rd-cal-scrim { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 1402; opacity: 0; pointer-events: none; transition: opacity .2s; }
.rd-cal-scrim.open { opacity: 1; pointer-events: auto; }
.rd-cal-pop { position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%); width: 100%; max-width: 440px; background: #fff; border-radius: 20px 20px 0 0; z-index: 1403; box-shadow: 0 -12px 34px rgba(20,30,60,.22); transition: transform .32s cubic-bezier(.34,1.56,.64,1); padding: 0 16px max(16px, env(safe-area-inset-bottom)); }
.rd-cal-pop.open { transform: translate(-50%, 0); }
.rd-cal-grab { width: 38px; height: 4px; border-radius: 3px; background: rgba(60,60,67,.18); margin: 9px auto 4px; }
.rd-cal-pop-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px; }
.rd-cal-pop-h span { font-size: 15px; font-weight: 800; color: #0F172A; }
.rd-cal-pop-h button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: rgba(60,60,67,.06); color: #475569; display: grid; place-items: center; cursor: pointer; }
/* inside the popup the calendar is flush (the sheet is already a card) */
.rd-cal-pop .rd-xcal { margin: 0; border: 0; box-shadow: none; padding: 4px 0 8px; background: transparent; }
.rd-cal-pop .rd-xcal-grid { grid-auto-rows: 42px; }
.rd-cal-pop .rd-xcal-grid .day { height: 42px; font-size: 15px; }

/* ===== In-app camera overlay ===== */
body.cam-lock { overflow: hidden; }
.cam-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: #000; display: none;
}
.cam-overlay.open { display: block; }
/* Stage is centered and sized to the feed aspect (set in JS). The video fills
   it exactly, so there are no internal black bars and the stamp guides anchor
   to the real image corners. Black letterbox (if any) is the overlay bg. */
.cam-stage {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%; max-height: 100%;
  width: 100%;
  aspect-ratio: 3 / 4; /* fallback until JS sets the real feed ratio */
}
.cam-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; background: #000;
  display: block;
}
.cam-flash {
  position: absolute; inset: 0; background: #fff;
  opacity: 0; pointer-events: none;
}
.cam-flash.go { animation: camFlash 320ms ease-out; }
@keyframes camFlash { 0% { opacity: .85; } 100% { opacity: 0; } }

/* Live stamp preview (mirrors the burned-in corner cards) */
.cam-stamp {
  position: absolute; pointer-events: none;
  background: rgba(7,11,20,.74);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  padding: 8px 11px;
  font-family: 'JetBrains Mono','Courier New',monospace;
  color: #fff; max-width: 60%;
}
.cam-stamp-tl { top: 12px; left: 12px; }
.cam-stamp-br { bottom: 12px; right: 12px; text-align: right; }
.cam-stamp-label { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: #74ff8a; }
.cam-stamp-val { font-size: 13px; font-weight: 700; margin-top: 2px; word-break: break-word; }
.cam-wm {
  position: absolute; top: 12px; right: 12px;
  font-family: 'Space Grotesk','Arial',sans-serif; font-weight: 800; font-size: 14px;
  color: #cfffd8; background: rgba(116,255,138,.16);
  border: 1px solid rgba(116,255,138,.45); border-radius: 7px;
  padding: 4px 9px; pointer-events: none;
}

.cam-topbar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(180deg, rgba(0,0,0,.55), transparent);
}
.cam-icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.45); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.cam-icon-btn .material-symbols-outlined { font-size: 24px; }

.cam-bottombar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 18px 22px calc(env(safe-area-inset-bottom, 0px) + 26px);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(0deg, rgba(0,0,0,.6), transparent);
}
.cam-bottom-spacer { width: 84px; }
.cam-shutter {
  width: 74px; height: 74px; border-radius: 50%;
  background: #fff; border: 5px solid rgba(255,255,255,.45);
  box-shadow: 0 0 0 2px rgba(0,0,0,.3);
  cursor: pointer; transition: transform 120ms;
}
.cam-shutter:active { transform: scale(.92); }
.cam-shutter:disabled { opacity: .5; }
.cam-done {
  min-width: 84px; height: 44px; padding: 0 16px;
  border-radius: 22px; border: 1px solid rgba(255,255,255,.5);
  background: rgba(0,0,0,.4); color: #fff;
  font-family: 'Noto Sans Lao','Noto Sans',sans-serif; font-weight: 700; font-size: 14px;
  cursor: pointer;
}

/* ===== In-app camera: review layer (Retake / Use photo) ===== */
.cam-review { display: none; }
.cam-overlay.reviewing .cam-review {
  display: block; position: absolute; inset: 0; z-index: 5; background: #000;
}
.cam-overlay.reviewing .cam-topbar,
.cam-overlay.reviewing .cam-bottombar { display: none; }
.cam-review-img {
  position: absolute; top: 0; left: 0; right: 0;
  bottom: 96px; width: 100%; height: calc(100% - 96px);
  object-fit: contain; background: #000;
}
.cam-review-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(96px + env(safe-area-inset-bottom, 0px));
  padding: 0 16px env(safe-area-inset-bottom, 0px);
  display: grid; grid-template-columns: 1fr 1.3fr; gap: 12px; align-items: center;
  background: linear-gradient(0deg, rgba(0,0,0,.85), rgba(0,0,0,.4));
}
.cam-review-btn {
  height: 56px; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-family: 'Noto Sans Lao','Noto Sans',sans-serif; font-weight: 700; font-size: 16px;
  border: 1.5px solid transparent;
}
.cam-review-btn .material-symbols-outlined { font-size: 22px; }
.cam-review-btn.retake {
  background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.35);
}
.cam-review-btn.retake:active { background: rgba(255,255,255,.16); }
.cam-review-btn.confirm {
  background: #16a34a; color: #fff; border-color: #16a34a;
  box-shadow: 0 4px 16px rgba(22,163,74,.4);
}
.cam-review-btn.confirm:active { background: #15803d; }

/* ===== Fullscreen photo viewer ===== */
.photo-viewer {
  display: none; position: fixed; inset: 0; z-index: 4200;
  background: rgba(0,0,0,.94);
  align-items: center; justify-content: center;
}
.photo-viewer.open { display: flex; }
.photo-viewer-img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
}
.photo-viewer-close {
  position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: 14px;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.photo-viewer-close .material-symbols-outlined { font-size: 26px; }

/* Hint that grid tiles are tappable */
.photo-tile { cursor: pointer; }
