/* ==========================================================================
   RailRaksha — Tactical Mission Interface v4.5
   Fusion of 'Sleek Tactical' & 'Midnight Protocol' Design Systems
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700;800&family=Noto+Sans+Telugu:wght@400;500;600;700&display=swap');

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg-primary:          #050505;
  --bg-secondary:        #0A0E1A;
  --bg-tertiary:         #101524;
  --bg-card:             rgba(10, 14, 26, 0.75);
  --bg-card-solid:       #0A0E1A;
  --bg-card-hover:       rgba(20, 28, 48, 0.85);
  --bg-glass:            rgba(10, 10, 10, 0.72);
  --bg-input:            #050811;
  --bg-elevated:         #121829;

  /* Tactical Color Palette */
  --color-brand:         #10B981; /* Cyber-Emerald Primary */
  --color-brand-soft:    rgba(16, 185, 129, 0.12);
  --color-emerald:       #10B981;
  --color-emerald-soft:  rgba(16, 185, 129, 0.12);
  --color-emerald-glow:  rgba(16, 185, 129, 0.4);

  --color-violet:        #A855F7; /* Cyber-Violet Telemetry & AI */
  --color-violet-soft:   rgba(168, 85, 247, 0.12);
  --color-violet-glow:   rgba(168, 85, 247, 0.4);

  --color-amber:         #F59E0B; /* Safety-Amber Caution */
  --color-warning:       #F59E0B;
  --color-warning-soft:  rgba(245, 158, 11, 0.12);
  --color-warning-glow:  rgba(245, 158, 11, 0.4);

  --color-danger:        #EF4444; /* Laser-Coral Critical Alert */
  --color-danger-soft:   rgba(239, 68, 68, 0.14);
  --color-danger-glow:   rgba(239, 68, 68, 0.5);

  --color-success:       #10B981;
  --color-success-soft:  rgba(16, 185, 129, 0.12);

  --color-info:          #06B6D4;
  --color-info-soft:     rgba(6, 182, 212, 0.12);

  /* Typography */
  --text-primary:        #F8FAFC;
  --text-secondary:      #94A3B8;
  --text-muted:          #64748B;
  --text-sub:            #64748B;

  /* Glowing Rims & Borders */
  --border:              rgba(255, 255, 255, 0.1);
  --border-strong:       rgba(255, 255, 255, 0.18);
  --border-emerald:      rgba(16, 185, 129, 0.45);
  --border-violet:       rgba(168, 85, 247, 0.45);
  --border-amber:        rgba(245, 158, 11, 0.45);
  --border-danger:       rgba(239, 68, 68, 0.55);

  /* Radii */
  --radius-xs:           4px;
  --radius-sm:           8px;
  --radius-md:           12px;
  --radius-lg:           16px;
  --radius-xl:           24px;
  --radius-pill:         9999px;

  /* Shadows */
  --shadow-sm:           0 2px 8px rgba(0, 0, 0, 0.6);
  --shadow-md:           0 4px 16px rgba(0, 0, 0, 0.7);
  --shadow-lg:           0 8px 32px rgba(0, 0, 0, 0.85);
  --shadow-xl:           0 16px 48px rgba(0, 0, 0, 0.95);
  --shadow-glow-green:   0 0 24px rgba(16, 185, 129, 0.3);
  --shadow-glow-violet:  0 0 24px rgba(168, 85, 247, 0.3);
  --shadow-glow-red:     0 0 32px rgba(239, 68, 68, 0.5);
  --shadow-glow-amber:   0 0 24px rgba(245, 158, 11, 0.3);

  /* Motion */
  --ease-out:            cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:         cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition:          all 0.22s cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --nav-height:          68px;
  --header-height:       60px;
  --safe-bottom:         env(safe-area-inset-bottom, 0px);
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes spinSlow { 100% { transform: rotate(360deg); } }
@keyframes spinReverse { 100% { transform: rotate(-360deg); } }
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 14px rgba(16, 185, 129, 0.3); opacity: 0.9; }
  50%      { box-shadow: 0 0 28px rgba(16, 185, 129, 0.65); opacity: 1; }
}
@keyframes pulseDanger {
  0%, 100% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.4); border-color: rgba(239, 68, 68, 0.6); }
  50%      { box-shadow: 0 0 44px rgba(239, 68, 68, 0.85); border-color: rgba(239, 68, 68, 0.95); }
}
@keyframes ripple {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  100% { box-shadow: 0 0 0 24px rgba(239, 68, 68, 0); }
}
@keyframes scanLaser {
  0%   { top: 0; opacity: 0.8; }
  50%  { top: 100%; opacity: 1; }
  100% { top: 0; opacity: 0.8; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  overflow: hidden;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Noto Sans Telugu', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: fixed;
}

.telugu { font-family: 'Noto Sans Telugu', 'Geist', 'Inter', sans-serif; }
.mono   { font-family: 'JetBrains Mono', monospace; }

button {
  cursor: pointer;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  transition: var(--transition);
  user-select: none;
}
button:active { transform: scale(0.97); }

input, select, textarea {
  font-family: inherit;
  outline: none;
  border: none;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--color-emerald);
  outline-offset: 2px;
}

/* ── App Shell ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: transparent;
}

/* ── Top Header ───────────────────────────────────────────────────────────── */
#header {
  height: var(--header-height);
  background: rgba(8, 12, 20, 0.88);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  position: relative;
  z-index: 30;
  flex-shrink: 0;
}

#header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
}

#header .logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.4));
  flex-shrink: 0;
}

#header .logo-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#header .logo-text .brand {
  font-family: 'Geist', sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-primary);
  text-transform: uppercase;
  line-height: 1.1;
}

#header .logo-text .sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  color: var(--color-emerald);
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-spacer { flex: 1; }

#gps-label {
  background: rgba(10, 14, 26, 0.9);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 10px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
#gps-label svg { width: 12px; height: 12px; color: var(--color-emerald); }

#btn-settings {
  width: 34px;
  height: 34px;
  background: rgba(10, 14, 26, 0.9);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
#btn-settings:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-emerald);
}
#btn-settings svg { width: 18px; height: 18px; }

/* ── Main Scroll Area ─────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 24px);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
#main-content::-webkit-scrollbar { display: none; }

/* ── Screen Sections ──────────────────────────────────────────────────────── */
.screen {
  display: none;
  animation: fadeInUp var(--transition) forwards;
}
.screen.active { display: block; }

/* ── Section Header ───────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-header h2 {
  font-family: 'Geist', sans-serif;
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.section-header h2 svg {
  width: 20px;
  height: 20px;
  color: var(--color-emerald);
}
.badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.badge-ok   { background: var(--color-emerald-soft); color: #6EE7B7; border: 1px solid var(--border-emerald); }
.badge-warn { background: var(--color-violet-soft);  color: #D8B4FE; border: 1px solid var(--border-violet); }

/* ── HUD Corner Accents ───────────────────────────────────────────────────── */
.hud-corner {
  position: absolute;
  width: 10px;
  height: 10px;
  pointer-events: none;
}
.hud-corner-tl { top: -1px; left: -1px; border-top: 2px solid var(--color-emerald); border-left: 2px solid var(--color-emerald); }
.hud-corner-tr { top: -1px; right: -1px; border-top: 2px solid var(--color-emerald); border-right: 2px solid var(--color-emerald); }
.hud-corner-bl { bottom: -1px; left: -1px; border-bottom: 2px solid var(--color-emerald); border-left: 2px solid var(--color-emerald); }
.hud-corner-br { bottom: -1px; right: -1px; border-bottom: 2px solid var(--color-emerald); border-right: 2px solid var(--color-emerald); }

.module-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  opacity: 0.8;
}

/* ── Screen 1: Status Hero Radar ([SEC-01]) ───────────────────────────────── */
.track-status-hero {
  border-radius: var(--radius-lg);
  padding: 22px 16px;
  text-align: center;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  background: var(--bg-glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  transition: all 0.3s var(--ease-out);
}

.track-status-hero.status-clear {
  border-color: var(--border-emerald);
  box-shadow: var(--shadow-glow-green);
  background: radial-gradient(ellipse at 50% 20%, rgba(16, 185, 129, 0.14) 0%, rgba(5, 5, 5, 0.9) 75%);
}

.track-status-hero.status-caution {
  border-color: var(--border-amber);
  box-shadow: var(--shadow-glow-amber);
  background: radial-gradient(ellipse at 50% 20%, rgba(245, 158, 11, 0.16) 0%, rgba(5, 5, 5, 0.9) 75%);
}

.track-status-hero.status-danger {
  border-color: var(--border-danger);
  box-shadow: var(--shadow-glow-red);
  background: radial-gradient(ellipse at 50% 20%, rgba(239, 68, 68, 0.25) 0%, rgba(5, 5, 5, 0.95) 75%);
  animation: pulseDanger 1.2s ease-in-out infinite alternate;
}

.status-icon-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  position: relative;
}

.status-icon-ring svg {
  width: 36px;
  height: 36px;
  position: relative;
  z-index: 5;
}

.status-clear .status-icon-ring {
  background: var(--color-emerald-soft);
  border: 1px solid var(--border-emerald);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
  animation: pulseGlow 2.5s ease-in-out infinite;
}
.status-clear .status-icon-ring svg { color: var(--color-emerald); }

.status-caution .status-icon-ring {
  background: var(--color-warning-soft);
  border: 1px solid var(--border-amber);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}
.status-caution .status-icon-ring svg { color: var(--color-warning); }

.status-danger .status-icon-ring {
  background: var(--color-danger-soft);
  border: 2px solid var(--color-danger);
  box-shadow: 0 0 32px rgba(239, 68, 68, 0.7);
  animation: ripple 1.4s ease-out infinite;
}
.status-danger .status-icon-ring svg { color: var(--color-danger); }

.status-label {
  font-family: 'Geist', sans-serif;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.status-clear   .status-label { color: #34D399; }
.status-caution .status-label { color: #FCD34D; }
.status-danger  .status-label { color: #F87171; text-shadow: 0 0 16px rgba(239, 68, 68, 0.7); }

.status-sublabel {
  font-family: 'JetBrains Mono', 'Inter', sans-serif;
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Work Session Mega Button ─────────────────────────────────────────────── */
.session-mega-btn {
  width: 100%;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: var(--bg-glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: var(--transition);
}

.session-mega-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.session-mega-btn.session-on {
  border-color: var(--border-emerald);
  box-shadow: var(--shadow-glow-green);
  background: radial-gradient(ellipse at 20% 50%, rgba(16, 185, 129, 0.18) 0%, rgba(10, 14, 26, 0.9) 80%);
}

.session-mega-btn.session-danger {
  border-color: var(--border-danger);
  box-shadow: var(--shadow-glow-red);
  background: radial-gradient(ellipse at 20% 50%, rgba(239, 68, 68, 0.25) 0%, rgba(10, 14, 26, 0.9) 80%);
}

.smb-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}
.session-on .smb-icon {
  background: var(--color-emerald-soft);
  border-color: var(--border-emerald);
  color: var(--color-emerald);
}
.session-danger .smb-icon {
  background: var(--color-danger-soft);
  border-color: var(--border-danger);
  color: var(--color-danger);
}
.smb-icon svg { width: 22px; height: 22px; }

.smb-content { flex: 1; min-width: 0; }

.smb-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  flex-shrink: 0;
}
.smb-status-dot.dot-on   { background: var(--color-emerald); box-shadow: 0 0 8px var(--color-emerald); }
.smb-status-dot.dot-off  { background: var(--text-muted); }
.smb-status-dot.dot-crit { background: var(--color-danger); box-shadow: 0 0 10px var(--color-danger); animation: pulseDanger 0.8s infinite; }
.smb-status-dot.dot-warn { background: var(--color-warning); box-shadow: 0 0 8px var(--color-warning); }

.smb-title {
  font-family: 'Geist', sans-serif;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: var(--text-primary);
  text-transform: uppercase;
}

.smb-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.smb-right {
  flex-shrink: 0;
  text-align: right;
  display: none;
}
.smb-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 800;
  color: var(--color-emerald);
  line-height: 1;
}
.smb-timer-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ── Live Distance Panel ──────────────────────────────────────────────────── */
.live-distance-panel {
  display: none;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
}
.live-distance-panel.visible { display: block; }

.ldp-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ldp-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--color-violet-soft);
  border: 1px solid var(--border-violet);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-violet);
  flex-shrink: 0;
}
.ldp-icon svg { width: 20px; height: 20px; }

.ldp-content { flex: 1; min-width: 0; }
.ldp-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ldp-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  margin: 2px 0;
}
.dist-safe    { color: #34D399; }
.dist-prepare { color: #FCD34D; }
.dist-warn    { color: #FB923C; }
.dist-crit    { color: #F87171; text-shadow: 0 0 12px rgba(239, 68, 68, 0.6); }

.ldp-sub {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ldp-badge {
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.4px;
}
.ldp-badge.live  { background: var(--color-violet-soft); color: #D8B4FE; border: 1px solid var(--border-violet); }
.ldp-badge.sched { background: var(--color-emerald-soft); color: #6EE7B7; border: 1px solid var(--border-emerald); }

/* ── Sync Status Bar ──────────────────────────────────────────────────────── */
.sync-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: rgba(10, 14, 26, 0.65);
  border: 1px solid var(--border);
}
.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sync-dot.online  { background: var(--color-emerald); box-shadow: 0 0 6px var(--color-emerald); }
.sync-dot.offline { background: var(--text-muted); }

.sync-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-secondary);
  flex: 1;
  margin-left: 8px;
}
#btn-refresh-trains {
  padding: 4px;
  color: var(--text-secondary);
  border-radius: 4px;
}
#btn-refresh-trains:hover { color: var(--color-emerald); }

/* ── Freight Info Card ────────────────────────────────────────────────────── */
.freight-info-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.07);
  border: 1px solid rgba(245, 158, 11, 0.25);
  margin-bottom: 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.fi-icon { color: var(--color-warning); flex-shrink: 0; margin-top: 1px; }
.fi-icon svg { width: 16px; height: 16px; }

/* ── Trains Section Title ─────────────────────────────────────────────────── */
.trains-section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  margin: 14px 0 10px;
  text-transform: uppercase;
}

/* ── Train List & Cards ───────────────────────────────────────────────────── */
#train-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.train-card {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--bg-glass);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.train-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.train-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-emerald);
}

.train-card.alert-caution::before  { background: var(--color-amber); }
.train-card.alert-warn::before     { background: #FB923C; }
.train-card.alert-critical::before { background: var(--color-danger); box-shadow: 0 0 10px var(--color-danger); }
.train-card.alert-passed::before   { background: var(--text-muted); }

.train-dir-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
  min-width: 48px;
}
.dir-down { background: rgba(59, 130, 246, 0.15); color: #93C5FD; border: 1px solid rgba(59, 130, 246, 0.3); }
.dir-up   { background: rgba(16, 185, 129, 0.15); color: #6EE7B7; border: 1px solid rgba(16, 185, 129, 0.3); }

.train-info {
  flex: 1;
  min-width: 0;
}
.train-name {
  font-family: 'Geist', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 5px;
}
.train-name svg { width: 15px; height: 15px; flex-shrink: 0; }

.train-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

.train-route {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.train-timing {
  text-align: right;
  flex-shrink: 0;
  min-width: 72px;
}
.time-to-arrival {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  color: var(--color-emerald);
}
.train-card.alert-caution .time-to-arrival { color: var(--color-amber); }
.train-card.alert-warn .time-to-arrival    { color: #FB923C; }
.train-card.alert-critical .time-to-arrival{ color: var(--color-danger); }
.train-card.alert-passed .time-to-arrival  { color: var(--text-muted); }

.time-unit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}
.scheduled-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Screen 2: Track Defect Photo Capture ─────────────────────────────────── */
.photo-capture-zone {
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  background: var(--bg-glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

.capture-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-emerald-soft);
  border: 1px solid var(--border-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: var(--color-emerald);
}
.capture-icon svg { width: 24px; height: 24px; }

.capture-title {
  font-family: 'Geist', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.capture-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.capture-options {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.capture-btn {
  flex: 1;
  max-width: 140px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.capture-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-emerald);
}
.capture-btn svg { width: 16px; height: 16px; color: var(--color-emerald); }

#captured-image-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: none;
  border: 1px solid var(--border);
}

/* ── Screen 2: Defect Analysis Card ───────────────────────────────────────── */
.defect-analysis-card {
  display: none;
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.defect-analysis-card.visible { display: block; }

.analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.ai-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-violet);
  background: var(--color-violet-soft);
  border: 1px solid var(--border-violet);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}
.analysis-title {
  font-family: 'Geist', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.defect-type-badge {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: 'Geist', sans-serif;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.severity-critical { background: var(--color-danger-soft); color: #FCA5A5; border: 1px solid var(--border-danger); }
.severity-high     { background: var(--color-warning-soft); color: #FCD34D; border: 1px solid var(--border-amber); }
.severity-medium   { background: var(--color-info-soft); color: #67E8F9; border: 1px solid var(--border); }
.severity-low      { background: var(--color-emerald-soft); color: #6EE7B7; border: 1px solid var(--border-emerald); }

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12.5px;
}
.detail-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.detail-value {
  color: var(--text-primary);
  font-weight: 600;
}

.defect-action-section {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 12px;
}
.recommended-action {
  font-size: 12.5px;
  font-weight: 700;
  color: #FCA5A5;
  line-height: 1.5;
}

.defect-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.defect-thumb { flex-shrink: 0; }
.defect-info { flex: 1; min-width: 0; }
.defect-name {
  font-family: 'Geist', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.defect-loc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.defect-status-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}
.dstatus-reported { background: var(--color-warning-soft); color: #FCD34D; border: 1px solid var(--border-amber); }
.dstatus-fixed    { background: var(--color-emerald-soft); color: #6EE7B7; border: 1px solid var(--border-emerald); }

/* ── Screen 3: Gang Diary ─────────────────────────────────────────────────── */
.diary-date-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.diary-date-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-emerald-soft);
  border: 1px solid var(--border-emerald);
  color: var(--color-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.diary-date-icon svg { width: 18px; height: 18px; }

.diary-date-info { flex: 1; min-width: 0; }
.diary-date-text {
  font-family: 'Geist', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}
.diary-gang-info {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.attendance-card {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.attendance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.attendance-title {
  font-family: 'Geist', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.attendance-title svg { color: var(--color-emerald); }
.attendance-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 800;
  color: var(--color-emerald);
}
.attendance-count span { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.attendance-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 10px 0 6px;
}
.attendance-bar-fill {
  height: 100%;
  background: var(--color-emerald);
  border-radius: inherit;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
  transition: width 0.3s var(--ease-out);
}
.attendance-sub { font-size: 11.5px; color: var(--text-secondary); }

.voice-record-btn {
  width: 100%;
  padding: 16px 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1.5px solid var(--border-emerald);
  box-shadow: var(--shadow-glow-green);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  margin-bottom: 12px;
  transition: var(--transition);
}
.mic-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-emerald-soft);
  border: 1px solid var(--border-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-emerald);
  flex-shrink: 0;
}
.mic-circle svg { width: 22px; height: 22px; }
.voice-record-info { flex: 1; text-align: left; }
.voice-title {
  font-family: 'Geist', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}
.voice-sub {
  font-family: 'Noto Sans Telugu', 'Inter', sans-serif;
  font-size: 12px;
  color: var(--color-emerald);
  margin-top: 2px;
}

.voice-record-btn.recording {
  border-color: var(--border-danger);
  box-shadow: var(--shadow-glow-red);
  background: radial-gradient(ellipse at 20% 50%, rgba(239, 68, 68, 0.2) 0%, rgba(10, 14, 26, 0.9) 80%);
}
.voice-record-btn.recording .mic-circle {
  background: var(--color-danger-soft);
  border-color: var(--border-danger);
  color: var(--color-danger);
  animation: pulseDanger 1s infinite alternate;
}

.transcription-card {
  display: none;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.transcription-card.visible { display: block; }
.transcription-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.transcription-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.diary-entry-card {
  display: none;
  padding: 18px 16px;
  border-radius: var(--radius-lg);
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid var(--border-emerald);
  margin-bottom: 14px;
}
.diary-entry-card.visible { display: block; }
.diary-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.dei-title {
  font-family: 'Geist', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--color-emerald);
}
.dei-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.diary-field {
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.df-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.df-value {
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.5;
}

/* ── Screen 4: Weather & Track Vulnerability ──────────────────────────────── */
.weather-hero {
  display: flex;
  gap: 16px;
  padding: 18px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  backdrop-filter: blur(40px);
  border: 1px solid var(--border-amber);
  box-shadow: var(--shadow-glow-amber);
  margin-bottom: 14px;
}
.weather-icon-large {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--color-warning-soft);
  border: 1px solid var(--border-amber);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-amber);
}
.weather-icon-large svg { width: 28px; height: 28px; }

.weather-main { flex: 1; min-width: 0; }
.weather-location {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.weather-temp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 32px;
  font-weight: 900;
  color: var(--color-amber);
  line-height: 1.1;
  margin: 3px 0 1px;
}
.weather-desc {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.weather-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 8px;
}
.weather-stat { text-align: center; }
.ws-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.ws-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

.risk-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.risk-card.risk-high   { border-color: var(--border-danger); background: rgba(239, 68, 68, 0.08); }
.risk-card.risk-medium { border-color: var(--border-amber);  background: rgba(245, 158, 11, 0.08); }
.risk-card.risk-low    { border-color: var(--border-emerald);background: rgba(16, 185, 129, 0.08); }

.risk-icon { flex-shrink: 0; width: 28px; height: 28px; }
.risk-icon svg { width: 24px; height: 24px; }
.risk-content { flex: 1; min-width: 0; }
.risk-title {
  font-family: 'Geist', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.risk-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
}
.risk-action {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--color-brand);
  line-height: 1.4;
}

/* ── Screen 5: PW Manual Voice Assistant ──────────────────────────────────── */
.manual-search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 12px;
}
.search-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  margin-right: 8px;
}
.search-icon svg { width: 16px; height: 16px; }

#manual-search-input {
  flex: 1;
  background: transparent;
  padding: 12px 0;
  color: var(--text-primary);
  font-size: 13px;
}

#btn-manual-search {
  padding: 0 16px;
  border-radius: var(--radius-md);
  background: var(--color-emerald);
  color: #050505;
  font-family: 'Geist', sans-serif;
  font-weight: 800;
  font-size: 13px;
}
#btn-voice-search {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}
#btn-voice-search:hover { color: var(--color-emerald); border-color: var(--border-emerald); }
#btn-voice-search svg { width: 18px; height: 18px; }

.manual-answer-card {
  display: none;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: rgba(10, 14, 26, 0.9);
  border: 1px solid var(--border-emerald);
  margin-bottom: 14px;
}
.manual-answer-card.visible { display: block; }
.maa-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ai-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-violet);
  background: var(--color-violet-soft);
  border: 1px solid var(--border-violet);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}
.maa-title {
  font-family: 'Geist', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
}
.maa-body {
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 8px;
}
.maa-source {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--color-emerald);
}

.quick-rules-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.rule-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  cursor: pointer;
  transition: var(--transition);
}
.rule-card:hover {
  border-color: var(--border-emerald);
  background: var(--bg-card-hover);
}
.rc-category {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-emerald);
  margin-bottom: 3px;
}
.rc-title {
  font-family: 'Geist', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.rc-preview {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
}
.rc-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Generic Buttons & Empty States ───────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--color-emerald);
  color: #050505;
  font-family: 'Geist', sans-serif;
  font-weight: 800;
  font-size: 13.5px;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}
.btn-primary svg { width: 18px; height: 18px; }

.btn-secondary {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: 'Geist', sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-secondary svg { width: 18px; height: 18px; }

.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row > button { flex: 1; }

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}
.es-icon { margin-bottom: 8px; }
.es-title {
  font-family: 'Geist', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.es-sub { font-size: 11.5px; }

/* ── Emergency Siren Banner ───────────────────────────────────────────────── */
#emergency-banner {
  display: none;
  background: #DC2626;
  color: white;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(220, 38, 38, 0.8);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  animation: pulseDanger 0.8s infinite alternate;
}
#emergency-banner.active {
  display: flex;
  align-items: center;
  gap: 12px;
}
.emergency-icon { flex-shrink: 0; }
.emergency-icon svg { width: 32px; height: 32px; }
.emergency-title {
  font-family: 'Geist', sans-serif;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.5px;
}
.emergency-subtitle { font-size: 11.5px; opacity: 0.9; }

/* ── Floating Bottom Navigation ───────────────────────────────────────────── */
#bottom-nav {
  height: var(--nav-height);
  background: rgba(8, 12, 20, 0.88);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: space-around;
  position: absolute;
  bottom: calc(10px + var(--safe-bottom));
  left: 10px;
  right: 10px;
  z-index: 35;
  padding: 0 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.85);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  padding: 6px 0;
  border-radius: var(--radius-md);
  position: relative;
  min-height: 48px;
}
.nav-btn .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}
.nav-btn .nav-icon svg { width: 20px; height: 20px; }
.nav-btn .nav-label {
  font-family: 'JetBrains Mono', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.nav-btn.active { color: var(--text-primary); }
.nav-btn.active .nav-icon {
  transform: translateY(-2px) scale(1.1);
  color: var(--color-emerald);
}
.nav-btn.active .nav-label {
  color: var(--color-emerald);
  font-weight: 700;
}
.nav-btn::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 16px;
  height: 2px;
  background: var(--color-emerald);
  border-radius: var(--radius-pill);
  transform: scaleX(0);
  opacity: 0;
  transition: var(--transition);
}
.nav-btn.active::after {
  transform: scaleX(1);
  opacity: 1;
}

/* ── Settings Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 120;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open,
.modal-overlay.active {
  display: flex;
  animation: fadeInUp 0.2s var(--ease-out);
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  background: #0A0E1A;
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}
.modal-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  margin: 0 auto 16px;
}
.modal-title {
  font-family: 'Geist', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-title svg { color: var(--color-emerald); }

.setting-group {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.setting-group-label {
  font-family: 'Geist', sans-serif;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--color-emerald);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.setting-group-label svg { width: 14px; height: 14px; }

.setting-item { margin-bottom: 12px; }
.setting-item label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}
.setting-item input, .setting-item select {
  width: 100%;
  background: #050811;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 13px;
}
.setting-item input:focus, .setting-item select:focus {
  border-color: var(--color-emerald);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.btn-save-settings {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--color-emerald);
  color: #050505;
  font-family: 'Geist', sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
}

/* ── Analyzing Overlay ────────────────────────────────────────────────────── */
.analyzing-overlay {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;           /* lets touches pass through — app stays usable */
  z-index: 150;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 26px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}
.analyzing-overlay.active { display: flex; }
.spinner-ring {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(16, 185, 129, 0.2);
  border-top-color: var(--color-emerald);
  border-radius: 50%;
  animation: spinSlow 0.9s linear infinite;
}
.analyzing-text {
  font-family: 'Geist', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}
.analyzing-sub { font-size: 11px; color: var(--text-muted); }

/* ── Toast Notification ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-40px);
  background: #0D1322;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.85);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease-spring);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ==========================================================================
   RAILRAKSHA V2 TRACK SAFETY & RADAR HUD SYSTEM
   ========================================================================== */

/* Telemetry Sub-Bar */
.top-telemetry-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: var(--radius-sm, 6px);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
  text-transform: uppercase;
}
.badge-status svg { width: 12px; height: 12px; }
.badge-ok     { color: var(--color-emerald); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.3); }
.badge-manual { color: var(--color-info);    background: rgba(6, 182, 212, 0.1);  border-color: rgba(6, 182, 212, 0.3); }
.badge-warn   { color: var(--color-warning); background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); }
.badge-bad    { color: var(--color-danger);  background: rgba(239, 68, 68, 0.1);  border-color: rgba(239, 68, 68, 0.3); }
.badge-info   { color: var(--color-info);    background: rgba(6, 182, 212, 0.1);  border-color: rgba(6, 182, 212, 0.3); }

/* 1-Tap Tactile Track Selector */
.track-selector-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 0.85fr;
  gap: 8px;
  margin-bottom: 12px;
}
.track-btn {
  display: grid;
  gap: 3px;
  place-content: center;
  text-align: center;
  min-height: 60px;
  padding: 8px 6px;
  background: var(--bg-card-solid);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md, 8px);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  touch-action: manipulation;
}
.track-btn b {
  font-family: 'Geist', sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}
.track-btn span {
  font-size: 11.5px;
  color: var(--text-muted);
}
.track-btn[aria-checked="true"] {
  background: var(--color-info);
  border-color: var(--color-info);
  color: #04121A;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.4);
}
.track-btn[aria-checked="true"] b {
  color: #03141C;
}
.track-btn[aria-checked="true"] span {
  color: #063442;
  font-weight: 700;
}

/* Status Band */
.status-band {
  border-radius: var(--radius-lg, 12px);
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--bg-card-solid);
  border: 2px solid var(--border);
  transition: all 0.3s var(--ease-out);
}
.status-band-content {
  text-align: center;
}
.status-en {
  font-family: 'Geist', sans-serif;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.status-te {
  font-family: 'Noto Sans Telugu', sans-serif;
  font-size: 17px;
  font-weight: 700;
  margin-top: 2px;
}

body[data-level="NONE"] .status-band,
body[data-level="AMBIENT"] .status-band {
  border-color: var(--color-emerald);
  color: var(--color-emerald);
  background: radial-gradient(ellipse at 50% 30%, rgba(16, 185, 129, 0.12) 0%, rgba(10, 14, 26, 0.95) 80%);
}
body[data-level="PREPARE"] .status-band {
  border-color: var(--color-warning);
  color: var(--color-warning);
  background: radial-gradient(ellipse at 50% 30%, rgba(245, 158, 11, 0.14) 0%, rgba(10, 14, 26, 0.95) 80%);
}
body[data-level="WARN"] .status-band {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: #1A1204;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.5);
}
body[data-level="CRITICAL"] .status-band {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #FFFFFF;
  box-shadow: 0 0 32px rgba(239, 68, 68, 0.7);
  animation: haloThreat 1s steps(2, jump-none) infinite;
}
@keyframes haloThreat {
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0.4); }
}
body[data-level="CRITICAL"] {
  box-shadow: inset 0 0 0 5px var(--color-danger);
}

/* Primary Threat Card */
.primary-threat-card {
  border-radius: var(--radius-lg, 12px);
  padding: 18px 18px 14px;
  margin-bottom: 12px;
  background: var(--bg-card-solid);
  border: 2px solid var(--border-danger);
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.25);
  animation: threatPulse 2s ease-in-out infinite alternate;
}
@keyframes threatPulse {
  0% { border-color: rgba(239, 68, 68, 0.4); }
  100% { border-color: rgba(239, 68, 68, 0.9); }
}
.threat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.threat-id-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.threat-alert-pill {
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--color-danger);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
}
.threat-train-no {
  font-family: 'Geist', sans-serif;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}
.threat-line-badge {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 800;
  color: var(--color-info);
  border: 1px solid rgba(6, 182, 212, 0.3);
}
.threat-source-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.threat-source-badge[data-state="ok"] {
  color: var(--color-emerald);
}
.threat-source-badge[data-state="warn"] {
  color: var(--color-warning);
}
.threat-train-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.threat-telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
  background: rgba(0, 0, 0, 0.4);
  padding: 12px 14px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.threat-cell {
  text-align: left;
}
.threat-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  color: var(--color-danger);
  letter-spacing: -0.02em;
}
body[data-level="WARN"] .threat-num {
  color: var(--color-warning);
}
.threat-unit {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
}
.threat-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}
.threat-speed {
  font-weight: 700;
  color: var(--text-secondary);
}
.threat-more-count {
  color: var(--color-warning);
  font-weight: 700;
}

/* Acknowledge Button */
.ack-btn {
  width: 100%;
  min-height: 56px;
  margin-bottom: 12px;
  background: #F1F5F9;
  color: #0B0F19;
  border: 2px solid #F1F5F9;
  border-radius: var(--radius-lg, 12px);
  font-family: 'Geist', sans-serif;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.2);
  transition: transform 0.1s var(--ease-out);
}
.ack-btn:active {
  transform: scale(0.98);
}

/* Dual-Rail Live Radar */
.radar-card {
  border-radius: var(--radius-lg, 12px);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-card-solid);
  border: 1.5px solid var(--border);
}
.radar-header, .radar-scale {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.radar-scale {
  margin-top: 6px;
  margin-bottom: 0;
}
.radar-worker-coord {
  color: var(--color-info);
  font-weight: 800;
}
.you-tag {
  color: var(--color-info);
  font-weight: 800;
}
.radar-canvas-wrap {
  background: rgba(0, 0, 0, 0.45);
  border-radius: var(--radius-md, 8px);
  padding: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.radar-svg {
  width: 100%;
  height: 120px;
  display: block;
}
.rail {
  stroke: #334155;
  stroke-width: 6;
}
body[data-track="UP"] .rail.up,
body[data-track="DN"] .rail.dn,
body[data-track="BOTH"] .rail {
  stroke: var(--color-info);
}
.ring {
  stroke: #334155;
  stroke-dasharray: 4 6;
  stroke-width: 1.5;
}
.ring.crit {
  stroke: var(--color-danger);
  stroke-width: 2;
}
.worker {
  fill: var(--color-info);
}
.rt path {
  fill: var(--text-muted);
}
.rt text {
  fill: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  text-anchor: middle;
  font-weight: 800;
}
.rt .env {
  stroke-width: 10;
  stroke: currentColor;
  opacity: 0.35;
}
.rt[data-active="false"] {
  opacity: 0.45;
}
.lvl-PREPARE { color: var(--color-warning); }
.lvl-PREPARE path { fill: var(--color-warning); }
.lvl-WARN { color: var(--color-warning); }
.lvl-WARN path { fill: var(--color-warning); }
.lvl-CRITICAL { color: var(--color-danger); }
.lvl-CRITICAL path { fill: var(--color-danger); }

/* Beat Selector Card */
.beat-selector-card {
  margin-bottom: 12px;
}
.beat-toggle-btn {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: var(--radius-md, 8px);
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: 'Geist', sans-serif;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.beat-toggle-btn span:first-of-type {
  flex: 1;
  text-align: left;
  margin-left: 8px;
}
.beat-panel {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  padding: 10px;
  margin-top: 6px;
}
.beat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}
.beat {
  display: grid;
  gap: 1px;
  place-content: center;
  text-align: center;
  min-height: 56px;
  padding: 6px 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
}
.beat b {
  font-size: 15px;
  font-weight: 800;
}
.beat span {
  font-family: 'Noto Sans Telugu', sans-serif;
  font-size: 11px;
  color: var(--text-secondary);
}
.beat i {
  font-style: normal;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  color: var(--text-muted);
}
.beat:active {
  background: var(--color-info);
  color: #000;
}
.nudge-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.nudge-btn {
  min-height: 40px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Corridor Traffic List */
.traffic-section {
  margin-bottom: 12px;
}
.traffic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.traffic-title {
  font-family: 'Geist', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.traffic-refresh-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ambient-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  background: var(--border);
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
}
.ambient-list li {
  display: grid;
  grid-template-columns: 4.5em 1.2fr auto 3.5em;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  background: var(--bg-card-solid);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--text-primary);
}
.ambient-list li[data-active="false"] {
  color: var(--text-muted);
  opacity: 0.65;
}
.ambient-list .empty {
  display: block;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}
.bg-warning {
  background: var(--color-warning);
  color: #1A1204;
  padding: 12px;
  border-radius: var(--radius-md, 8px);
  font-size: 12px;
  font-weight: 700;
  margin: 8px 0;
}
