/* ============================================================================
   SVARAJYA SMART RENEWAL — CONSUMER EXPERIENCE DESIGN SYSTEM (PRODUCTION)
   - Official Svarajya Crest + Sovereign Forest-Navy + Mudra Gold + Warm Ivory
   - Apple Wallet scannable cards · Modern Document Scanner · Headspace calm
   - Mobile-first ergonomics (>=44px targets, 320px–430px) + Deliberate Desktop
   - Zero external font requests (strict CSP & offline local-first)
   ============================================================================ */

:root {
  /* Sovereign Svarajya Consumer Palette (WCAG 2.2 AA Verified) */
  --sv-forest: #15362F;           /* Primary sovereign dark anchor (13.4:1 on white) */
  --sv-forest-deep: #0E2520;      /* Deep scanner / dark hero depth */
  --sv-navy: #1B3652;             /* Official Svarajya Blue harmony */
  --sv-jade: #24574A;             /* Interactive forest green (8.1:1 with white) */
  --sv-jade-soft: #EAF1ED;        /* Soft sage medallion & callout surface */
  --sv-gold: #C6A24F;             /* Official Mudra Gold accent */
  --sv-gold-soft: #E5CE94;        /* Soft luminous gold on dark */
  --sv-gold-text: #846016;        /* Accessible gold text on ivory/white (5.1:1) */
  --sv-gold-tint: #FAF4E4;
  --sv-clay: #9E522A;             /* Warm Matka Clay — due soon / attention (5.6:1) */
  --sv-clay-tint: #FDF2E9;
  --sv-crimson: #B42318;
  --sv-crimson-tint: #FEF3F2;

  /* Warm Ivory & Parchment Surfaces */
  --sv-ivory: #FAF8F3;            /* Primary calm canvas */
  --sv-parchment: #F2EEE4;        /* Recessed panel surface */
  --sv-white: #FFFFFF;
  --sv-border: #E2E7E1;           /* Restrained organic hairline border */
  --sv-border-strong: #B8C4BC;    /* High-contrast input border (>=3:1 vs white) */

  /* Ink Hierarchy */
  --sv-ink: #1A2B27;              /* Rich deep ink (14.8:1 on ivory) */
  --sv-ink-2: #435550;            /* Secondary body (7.4:1 on ivory) */
  --sv-ink-muted: #586964;        /* Muted captions (5.4:1 on white/ivory) */

  /* Self-Contained Typography Stacks (Zero External Network Requests) */
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Iowan Old Style', 'Palatino Linotype', Georgia, 'Times New Roman', serif;
  --font-devanagari: 'Kohinoor Devanagari', 'Noto Sans Devanagari', 'Devanagari Sangam MN', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Radii & Shadows */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 28px;
  --r-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(21, 54, 47, 0.04);
  --shadow-card: 0 4px 18px rgba(21, 54, 47, 0.055), 0 1px 2px rgba(21, 54, 47, 0.04);
  --shadow-hero: 0 22px 44px -14px rgba(14, 37, 32, 0.34), 0 4px 12px rgba(14, 37, 32, 0.12);
  --shadow-hover: 0 12px 28px rgba(21, 54, 47, 0.10), 0 2px 6px rgba(21, 54, 47, 0.05);

  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --touch: 44px;
}

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

html, body {
  max-width: 100%;
  overflow-x: clip;
  background-color: var(--sv-ivory);
  color: var(--sv-ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html[lang="mr"] body {
  font-family: var(--font-devanagari);
  line-height: 1.65;
}

html[lang="mr"] .hero-headline,
html[lang="mr"] .screen-headline,
html[lang="mr"] h1,
html[lang="mr"] h2 {
  font-family: var(--font-devanagari);
  letter-spacing: 0;
  line-height: 1.32;
}

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

/* Accessibility: high-contrast focus ring */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--sv-gold);
  outline-offset: 2px;
}

/* Accessible Visually Hidden & Skip Link (Modern Web Guidance) */
.visually-hidden:where(:not(:focus-within, :active)),
.sr-only {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  background: var(--sv-forest);
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: var(--r-pill);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-hero);
}

/* ============================================================================
   APP SHELL — MOBILE-FIRST + DELIBERATE DESKTOP ARCHITECTURE
   ============================================================================ */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 90% 42% at 50% -8%, rgba(198, 162, 79, 0.11), transparent 72%),
    var(--sv-ivory);
}

.app-shell.immersive-dark {
  background: linear-gradient(180deg, #13312A 0%, #0D221D 100%);
  color: #F4F7F5;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 248, 243, 0.90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 231, 225, 0.72);
}

.app-shell.immersive-dark .top-bar {
  background: rgba(19, 49, 42, 0.88);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.top-bar-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: left;
  color: inherit;
}

.brand-crest {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(21, 54, 47, 0.18));
  flex-shrink: 0;
}

.brand-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.brand-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: var(--sv-forest);
}
.app-shell.immersive-dark .brand-name { color: #F4F7F5; }

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--sv-gold-text);
  letter-spacing: 0.02em;
}
.app-shell.immersive-dark .brand-sub { color: var(--sv-gold-soft); }

.lang-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--sv-border-strong);
  background: var(--sv-white);
  color: var(--sv-ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s var(--ease-spring), border-color 0.2s, background 0.2s;
}
.lang-pill:hover { border-color: var(--sv-forest); background: var(--sv-jade-soft); }
.lang-pill:active { transform: scale(0.97); }
.app-shell.immersive-dark .lang-pill {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
  color: #FFFFFF;
}

.workspace-layout {
  flex: 1;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.desktop-rail { display: none; }

.screen-stage {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 18px 28px 18px;
  scroll-margin-top: 84px;
  overflow-wrap: break-word;
  animation: fadeSlideUp 0.34s var(--ease-spring);
}

.loading-shell {
  text-align: center;
  padding: 56px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--sv-ink-muted);
}

.app-footer {
  text-align: center;
  padding: 12px 18px 18px 18px;
}
.app-shell.immersive-dark .app-footer { display: none; }

.text-muted {
  color: var(--sv-ink-muted);
  font-size: 13px;
}

/* Calm 4-Tab Native Bottom Navigation (Sticky bottom — zero overlap) */
.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 45;
  margin-top: auto;
  background: rgba(250, 248, 243, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--sv-border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) 8px;
}
.app-shell.immersive-dark .bottom-nav,
.app-shell.hide-bottom-nav .bottom-nav { display: none; }

.bottom-nav-inner {
  max-width: 460px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 50px;
  background: none;
  border: none;
  color: var(--sv-ink-muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: color 0.18s, background 0.18s;
}
.nav-tab.active {
  color: var(--sv-forest);
  font-weight: 700;
}
.nav-tab.active .tab-icon-wrap {
  background: var(--sv-jade-soft);
}
.tab-icon-wrap {
  width: 44px;
  height: 28px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.nav-tab svg { width: 20px; height: 20px; }

/* ============================================================================
   TYPOGRAPHY & LAYOUT UTILITIES
   ============================================================================ */
.kicker {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sv-ink-muted);
  letter-spacing: 0.01em;
}

.hero-headline {
  font-size: clamp(30px, 8vw, 42px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.028em;
  color: var(--sv-ink);
  margin-top: 6px;
}

.screen-headline {
  font-size: clamp(24px, 6.4vw, 32px);
  font-weight: 800;
  line-height: 1.16;
  letter-spacing: -0.022em;
  color: var(--sv-ink);
}

.section-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--sv-ink);
}

.subtitle {
  font-size: 15px;
  color: var(--sv-ink-2);
  line-height: 1.5;
  margin-top: 6px;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.stack { display: flex; flex-direction: column; gap: 18px; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ============================================================================
   SCULPTURAL DARK HERO CARDS (Sovereign Forest + Mudra Gold)
   ============================================================================ */
.hero-dark-card {
  border-radius: var(--r-xl);
  padding: 22px 20px 20px 20px;
  background: linear-gradient(155deg, #194238 0%, #122E27 55%, #162B3D 100%);
  color: #FFFFFF;
  box-shadow: var(--shadow-hero);
  border: 1px solid rgba(198, 162, 79, 0.24);
  position: relative;
  overflow: hidden;
}
.hero-dark-card::after {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(198, 162, 79, 0.22), transparent 70%);
  pointer-events: none;
}

/* Illustrated Scan-Document Graphic */
.hero-scan-art {
  width: 120px;
  height: 120px;
  margin: 0 auto 12px auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-scan-halo {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}
.hero-scan-sheet {
  width: 72px;
  height: 90px;
  border-radius: 10px;
  background: #FAF8F3;
  padding: 12px 10px;
  transform: rotate(-6deg);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 2;
  animation: softFloat 4.8s ease-in-out infinite;
}
.hero-sheet-line {
  height: 6px;
  border-radius: 4px;
  background: #D0DBD5;
  margin-bottom: 8px;
}
.hero-sheet-line.head {
  width: 48%;
  height: 7px;
  background: var(--sv-forest);
  margin-bottom: 11px;
}
.hero-scan-beam {
  position: absolute;
  left: 14px;
  right: 14px;
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent, #A7F3D0, var(--sv-gold-soft), #A7F3D0, transparent);
  box-shadow: 0 0 16px 4px rgba(167, 243, 208, 0.45);
  z-index: 3;
  animation: heroBeam 3.2s ease-in-out infinite;
}
.hero-scan-bracket {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(229, 206, 148, 0.78);
  border-radius: 3px;
  z-index: 4;
}
.hero-scan-bracket.tl { top: 20px; left: 16px; border-right: none; border-bottom: none; }
.hero-scan-bracket.tr { top: 20px; right: 16px; border-left: none; border-bottom: none; }
.hero-scan-bracket.bl { bottom: 20px; left: 16px; border-right: none; border-top: none; }
.hero-scan-bracket.br { bottom: 20px; right: 16px; border-left: none; border-top: none; }

.hero-gold-seal {
  position: absolute;
  bottom: 12px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, #D5B567 0%, var(--sv-gold) 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}

/* Countdown Hero Card (Dashboard & Details) */
.countdown-hero {
  border-radius: var(--r-xl);
  padding: 24px 22px;
  background: linear-gradient(145deg, #183E35 0%, #112C26 60%, #162B3D 100%);
  color: #FFFFFF;
  box-shadow: var(--shadow-hero);
  border: 1px solid rgba(198, 162, 79, 0.24);
}
.countdown-big {
  font-size: clamp(36px, 10vw, 50px);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.028em;
  margin-top: 6px;
}
.countdown-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  margin: 18px 0 12px 0;
}
.countdown-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sv-gold), var(--sv-gold-soft));
  transition: width 0.4s var(--ease-spring);
}

/* ============================================================================
   BUTTONS & AIRY ACTION TILES (All >= 48px touch targets)
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 13px 20px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-align: center;
  transition: transform 0.16s var(--ease-spring), box-shadow 0.2s, background 0.2s, opacity 0.2s;
}
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled {
  background: #D6E0DB !important;
  color: #5D706A !important;
  border-color: transparent !important;
  cursor: not-allowed;
  box-shadow: none !important;
}

.btn-white-hero {
  background: #FFFFFF;
  color: var(--sv-forest);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}
.btn-white-hero:hover:not(:disabled) { background: #FCFBF8; transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(145deg, #1E4D40 0%, var(--sv-forest) 100%);
  color: #FFFFFF;
  box-shadow: 0 8px 20px rgba(21, 54, 47, 0.22);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 26px rgba(21, 54, 47, 0.30);
}

.btn-secondary {
  background: var(--sv-white);
  color: var(--sv-ink);
  border-color: var(--sv-border-strong);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--sv-forest);
  background: var(--sv-jade-soft);
}

.btn-danger,
.btn-danger-soft {
  background: var(--sv-crimson-tint);
  color: var(--sv-crimson);
  border-color: rgba(180, 35, 24, 0.28);
}
.btn-danger:hover:not(:disabled),
.btn-danger-soft:hover:not(:disabled) {
  background: #FEE4E2;
  border-color: var(--sv-crimson);
}

.btn-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid transparent;
  color: var(--sv-jade);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.btn-text:hover {
  background: var(--sv-jade-soft);
  color: var(--sv-forest);
}
.btn-text.danger-link {
  color: var(--sv-crimson);
}
.btn-text.danger-link:hover {
  background: var(--sv-crimson-tint);
}

/* Two Airy Side-by-Side Action Tiles */
.tile-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 92px;
  padding: 16px 12px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--sv-border);
  background: var(--sv-white);
  color: var(--sv-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform 0.18s var(--ease-spring), border-color 0.2s, box-shadow 0.2s;
}
.action-tile:hover {
  border-color: var(--sv-forest);
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}
.action-tile svg { color: var(--sv-jade); width: 24px; height: 24px; flex-shrink: 0; }

/* ============================================================================
   CARDS, APPLE WALLET RECORDS & REVIEW DATE CARDS
   ============================================================================ */
.surface-card,
.panel {
  background: var(--sv-white);
  border: 1px solid var(--sv-border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.doc-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--sv-white);
  border: 1px solid var(--sv-border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s, border-color 0.2s;
}
.doc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--sv-border-strong);
}

.doc-icon-medallion {
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: var(--sv-jade-soft);
  color: var(--sv-forest);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.doc-card-title { font-size: 16px; font-weight: 700; color: var(--sv-ink); }
.doc-card-date { font-size: 13.5px; color: var(--sv-ink-muted); margin-top: 2px; }
.doc-card-status { font-size: 13px; font-weight: 700; margin-top: 4px; }

/* Elevated Review & Obligation Cards */
.review-date-card,
.obligation-card {
  background: var(--sv-white);
  border: 1.5px solid var(--sv-border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.22s, background 0.22s, box-shadow 0.22s;
}

.review-date-card.confirmed,
.obligation-card.confirmed {
  border-color: var(--sv-jade);
  background: #F9FCFA;
  box-shadow: 0 6px 20px rgba(36, 87, 74, 0.09);
}

.review-date-card.unconfirmed,
.obligation-card.unconfirmed {
  border-color: rgba(198, 162, 79, 0.65);
}

.review-date-big {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--sv-ink);
  margin: 4px 0 10px 0;
}

/* SR-103 / SR-104: Coverage Separation, Historical Dates & Inline Ambiguity */
.review-date-card.coverage-od {
  border-left: 4px solid var(--sv-jade);
}
.review-date-card.coverage-tp {
  border-left: 4px solid var(--sv-navy);
}
.coverage-helper-note {
  font-size: 12.5px;
  color: var(--sv-ink-muted);
  margin-bottom: 8px;
}
.pill-tp {
  background: #E9EFF6;
  color: var(--sv-navy);
}
.pill-hist {
  background: #ECEAE3;
  color: var(--sv-ink-2);
}
.review-date-card.ambiguous-card {
  border-color: #D97706;
  background: #FFFDF7;
}
.review-date-card.historical-card {
  background: #FAF8F4;
  border-color: var(--sv-border-strong);
  box-shadow: none;
}
.review-date-card.historical-card.retained {
  border-color: var(--sv-jade);
  background: #F6FAF7;
}
.historical-section {
  margin-top: 8px;
  padding: 16px;
  border-radius: 20px;
  background: var(--sv-parchment);
  border: 1px dashed var(--sv-border-strong);
}
.inline-ambiguity-box {
  margin: 8px 0 10px;
  padding: 12px;
  border-radius: 14px;
  background: #FEF7E8;
  border: 1px solid rgba(217, 119, 6, 0.35);
  color: #78350F;
  font-size: 13px;
}
.ambig-alt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.ambig-alt-chip {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1.5px solid #D97706;
  background: var(--sv-white);
  color: #78350F;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ambig-alt-chip.selected,
.ambig-alt-chip:hover {
  background: #D97706;
  color: #FFFFFF;
}
.historical-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.historical-actions-row .btn-sm {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 13px;
}
.historical-detail-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--sv-white);
  border: 1px solid var(--sv-border);
  font-size: 12.5px;
  color: var(--sv-ink-2);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--sv-jade);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s;
}
.icon-btn:hover { background: var(--sv-jade-soft); }
.app-shell.immersive-dark .icon-btn { color: #FFFFFF; }
.app-shell.immersive-dark .icon-btn:hover { background: rgba(255, 255, 255, 0.14); }

/* Badges & Pills */
.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}
.pill-sage, .badge-normal { background: var(--sv-jade-soft); color: var(--sv-forest); }
.pill-gold { background: var(--sv-gold-tint); color: var(--sv-gold-text); }
.pill-clay, .badge-soon, .badge-today { background: var(--sv-clay-tint); color: var(--sv-clay); }
.badge-expired { background: var(--sv-crimson-tint); color: var(--sv-crimson); }

/* Alerts & Reassurance Callouts */
.reassurance-pill {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  border-radius: var(--r-md);
  background: var(--sv-jade-soft);
  color: var(--sv-forest);
  font-size: 14px;
  line-height: 1.48;
}

.alert-warn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--sv-clay-tint);
  color: var(--sv-clay);
  border: 1px solid rgba(158, 82, 42, 0.24);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
}

.alert-error {
  background: var(--sv-crimson-tint);
  color: var(--sv-crimson);
  border: 1px solid rgba(180, 35, 24, 0.25);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
}

.alert-success {
  background: var(--sv-jade-soft);
  color: var(--sv-forest);
  border: 1px solid rgba(36, 87, 74, 0.24);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
}

.privacy-footer-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--sv-ink-2);
  font-size: 14px;
  font-weight: 500;
  padding-top: 4px;
  text-align: center;
}

/* ============================================================================
   IMMERSIVE CAMERA SCANNER & FILE DROPZONE
   ============================================================================ */
.camera-frame-box {
  position: relative;
  border-radius: 26px;
  background: rgba(8, 22, 19, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.camera-frame-box video {
  width: 100%;
  height: 100%;
  min-height: 300px;
  object-fit: cover;
  display: block;
}

.cam-bracket {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 3px solid #A8CFAF;
  border-radius: 12px;
  pointer-events: none;
  z-index: 3;
  animation: bracketBreath 2.8s ease-in-out infinite;
}
.cam-bracket.tl { top: 18px; left: 18px; border-right: none; border-bottom: none; border-bottom-left-radius: 0; border-top-right-radius: 0; }
.cam-bracket.tr { top: 18px; right: 18px; border-left: none; border-bottom: none; border-bottom-right-radius: 0; border-top-left-radius: 0; }
.cam-bracket.bl { bottom: 18px; left: 18px; border-right: none; border-top: none; border-top-left-radius: 0; border-bottom-right-radius: 0; }
.cam-bracket.br { bottom: 18px; right: 18px; border-left: none; border-top: none; border-top-right-radius: 0; border-bottom-left-radius: 0; }

.cam-laser {
  position: absolute;
  left: 16px;
  right: 16px;
  height: 3px;
  pointer-events: none;
  z-index: 3;
  background: linear-gradient(90deg, transparent, #BBF7D0, var(--sv-gold-soft), #BBF7D0, transparent);
  box-shadow: 0 0 24px 7px rgba(134, 239, 172, 0.42);
  animation: scanSweep 2.8s ease-in-out infinite;
}

.shutter-ring {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.94);
  background: transparent;
  padding: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s var(--ease-spring);
}
.shutter-ring::after {
  content: '';
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #FFFFFF;
}
.shutter-ring:active { transform: scale(0.92); }

.file-dropzone {
  border: 2px dashed var(--sv-border-strong);
  border-radius: var(--r-lg);
  background: var(--sv-ivory);
  padding: 28px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s, background 0.2s;
}
.file-dropzone:hover,
.file-dropzone:focus-within {
  border-color: var(--sv-forest);
  background: var(--sv-jade-soft);
}
.file-dropzone input[type="file"] {
  max-width: 100%;
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--sv-ink-2);
  min-height: var(--touch);
  cursor: pointer;
}

/* ============================================================================
   FORMS, CHIPS, PROGRESS & SOURCE TEXT DRAWER (Modern Web Guidance)
   ============================================================================ */
.sparkle-medallion {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--sv-jade-soft);
  color: var(--sv-forest);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label,
.field-label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--sv-ink-2);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea,
.input-box {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--sv-border-strong);
  background: var(--sv-white);
  color: var(--sv-ink);
  font: inherit;
  font-size: max(1rem, 1em);
  transition: border-color 0.18s, box-shadow 0.18s;
}

input:focus,
select:focus,
textarea:focus,
.input-box:focus {
  border-color: var(--sv-forest);
  box-shadow: 0 0 0 4px rgba(21, 54, 47, 0.1);
}

input:user-invalid,
select:user-invalid {
  border-color: var(--sv-crimson);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 6px 2px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--sv-ink);
}

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-width: 22px;
  accent-color: var(--sv-forest);
  cursor: pointer;
  flex-shrink: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.select-chip {
  min-height: var(--touch);
  padding: 8px 16px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--sv-border-strong);
  background: var(--sv-white);
  color: var(--sv-ink-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}
.select-chip.active {
  background: var(--sv-forest);
  border-color: var(--sv-forest);
  color: #FFFFFF;
}

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--sv-parchment);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sv-forest), var(--sv-jade), var(--sv-gold));
  border-radius: 999px;
  transition: width 0.35s var(--ease-spring);
}

/* Completion Seal */
.seal-circle {
  width: 84px;
  height: 84px;
  margin: 4px auto 8px auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #1E4D40 0%, var(--sv-forest) 100%);
  border: 3px solid var(--sv-gold);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 32px rgba(21, 54, 47, 0.28);
  animation: sealStamp 0.55s var(--ease-spring) forwards;
}

/* Collapsible OCR Source Text Drawer — Zero Horizontal Overflow Guaranteed */
details.source-drawer,
details.historical-info-drawer {
  border: 1px solid var(--sv-border);
  border-radius: var(--r-md);
  background: var(--sv-white);
  padding: 10px 14px;
}
details.source-drawer summary,
details.historical-info-drawer summary {
  list-style: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--sv-jade);
  cursor: pointer;
}
details.source-drawer summary::-webkit-details-marker,
details.historical-info-drawer summary::-webkit-details-marker {
  display: none;
}
.drawer-summary-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.drawer-chevron {
  display: inline-flex;
  transition: transform 0.2s ease;
}
details[open] > summary .drawer-chevron {
  transform: rotate(90deg);
}
pre#extracted-text {
  width: 100%;
  max-width: 100%;
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 180px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--sv-parchment);
  padding: 12px;
  border-radius: 10px;
  color: var(--sv-ink-2);
}
.privacy-source-note {
  font-size: 12px;
  color: var(--sv-ink-muted);
  margin-top: 6px;
}
pre#extracted-text:empty {
  display: none;
}

/* Admin KPI & Charts */
.admin-container {
  width: 100%;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.kpi-card {
  background: var(--sv-white);
  border: 1px solid var(--sv-border);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.kpi-num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
  color: var(--sv-forest);
  margin-top: 6px;
}
.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--sv-parchment);
  overflow: hidden;
  margin-top: 6px;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sv-forest), var(--sv-jade));
  transition: width 0.35s var(--ease-spring);
}

/* Deliberate Desktop Two-Column Split Grids + Mobile-First Landing Ordering */
.desktop-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.landing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  grid-template-areas:
    "head"
    "hero"
    "actions";
}
.landing-head { grid-area: head; }
.landing-hero { grid-area: hero; }
.landing-actions { grid-area: actions; }

/* ============================================================================
   KEYFRAMES & REDUCED MOTION
   ============================================================================ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes softFloat {
  0%, 100% { transform: rotate(-6deg) translateY(0); }
  50% { transform: rotate(-5deg) translateY(-5px); }
}
@keyframes heroBeam {
  0%, 100% { top: 24%; opacity: 0.3; }
  50% { top: 72%; opacity: 1; }
}
@keyframes scanSweep {
  0% { top: 14%; opacity: 0.25; }
  15%, 85% { opacity: 1; }
  100% { top: 84%; opacity: 0.25; }
}
@keyframes bracketBreath {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}
@keyframes sealStamp {
  0% { transform: scale(1.35) rotate(-8deg); opacity: 0; }
  70% { transform: scale(0.95) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

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

/* ============================================================================
   RESPONSIVE BREAKPOINTS (320px, 768px Tablet, 1024px–1440px Deliberate Desktop)
   ============================================================================ */
@media (max-width: 1023px) {
  .landing-grid {
    gap: 12px;
  }
  .hero-headline {
    font-size: clamp(26px, 7.2vw, 32px);
    margin-top: 4px;
  }
  .landing-head .subtitle {
    margin-top: 4px;
    font-size: 14px;
  }
  .hero-dark-card {
    padding: 18px 16px 16px 16px;
  }
  .hero-scan-art {
    width: 96px;
    height: 96px;
    margin: 0 auto 10px auto;
  }
  .hero-scan-sheet {
    width: 58px;
    height: 74px;
    padding: 10px 8px;
  }
  .hero-gold-seal {
    width: 30px;
    height: 30px;
    bottom: 6px;
    right: 8px;
  }
  .action-tile {
    min-height: 74px;
    padding: 10px;
    gap: 6px;
  }
  .landing-actions.stack {
    gap: 10px;
  }
  .app-footer {
    padding: 6px 16px 10px 16px;
  }
}

@media (max-width: 350px) {
  .screen-stage { padding: 12px 12px 24px 12px; }
  .hero-dark-card { padding: 16px 14px; }
  .action-tile { font-size: 13px; padding: 10px 8px; }
  .top-bar-inner { padding: 10px 12px; }
  .lang-pill { padding: 0 12px; font-size: 12.5px; }
}

@media (min-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .screen-stage { max-width: 700px; padding: 22px 28px 36px 28px; }
}

@media (min-width: 1024px) {
  .bottom-nav { display: none; }
  .workspace-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 32px;
    padding: 24px 28px 40px 28px;
  }
  .desktop-rail {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 232px;
    flex-shrink: 0;
    position: sticky;
    top: 86px;
    background: var(--sv-white);
    border: 1px solid var(--sv-border);
    border-radius: var(--r-lg);
    padding: 14px;
    box-shadow: var(--shadow-card);
  }
  .app-shell.immersive-dark .desktop-rail {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.14);
  }
  .rail-item {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: var(--touch);
    padding: 8px 12px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    color: var(--sv-ink-2);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.16s, color 0.16s;
  }
  .app-shell.immersive-dark .rail-item { color: #D7E5E0; }
  .rail-item:hover { background: var(--sv-jade-soft); color: var(--sv-forest); }
  .app-shell.immersive-dark .rail-item:hover { background: rgba(255, 255, 255, 0.12); color: #FFFFFF; }
  .rail-item.active { background: var(--sv-forest); color: #FFFFFF; }
  .app-shell.immersive-dark .rail-item.active { background: var(--sv-gold); color: var(--sv-forest-deep); }
  .rail-item svg { width: 18px; height: 18px; flex-shrink: 0; }

  .screen-stage { max-width: 920px; padding: 0; }
  .desktop-split { grid-template-columns: 1.05fr 0.95fr; gap: 28px; align-items: start; }
  .desktop-split.balanced { grid-template-columns: 1fr 1fr; }
  .landing-grid {
    grid-template-columns: 1.05fr 0.95fr;
    column-gap: 32px;
    row-gap: 22px;
    align-items: start;
    grid-template-areas:
      "head hero"
      "actions hero";
  }
}
