/* ═══════════════════════════════════════════════════════════════════════════
   DDRiVE-M  ·  AI Disaster Resilience Platform  ·  Mobile-First CSS
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Orbitron:wght@400;700;900&display=swap');

/* ── CUSTOM PROPERTIES ─────────────────────────────────────────────────────── */
:root {
  --bg-deep:       #060a0f;
  --bg-dark:       #080e17;
  --bg-card:       #0d1a26;
  --bg-input:      #0a1520;
  --bg-row:        #0d1520;
  --border:        #1a3352;
  --border-mid:    #1e3a5f;
  --text-primary:  #c8d8e8;
  --text-muted:    #4a7a9b;
  --text-dim:      #2a5a7b;
  --cyan:          #00d4ff;
  --cyan-dim:      #00b8d9;
  --green:         #10b981;
  --orange:        #ff6b35;
  --red:           #ff3366;
  --amber:         #f59e0b;
  --purple:        #a855f7;
  --teal:          #06b6d4;
  --yellow:        #ffdd00;
  --sidebar-w:     220px;
  --topbar-h:      52px;
  --bottomnav-h:   60px;
  --radius-sm:     2px;
  --radius:        4px;
  --radius-lg:     6px;
  --transition:    0.2s ease;
  --font-mono:     'IBM Plex Mono', 'Courier New', monospace;
  --font-display:  'Orbitron', sans-serif;
  --shadow-glow:   0 0 40px rgba(0,212,255,0.15);
  --shadow-card:   0 2px 20px rgba(0,0,0,0.4);
}

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

html { font-size: 14px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-mono);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Scan-line texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,212,255,0.012) 2px,
    rgba(0,212,255,0.012) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── SCROLLBAR ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

/* ── SKIP LINK (Accessibility) ─────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 8px 16px;
  background: var(--cyan);
  color: var(--bg-deep);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  z-index: 10000;
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { top: 0; }

/* ── KEYFRAMES ─────────────────────────────────────────────────────────────── */
@keyframes pulse        { 0%,100%{opacity:1}  50%{opacity:0.25} }
@keyframes pulse-dot    { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.4);opacity:0.5} }
@keyframes fade-in      { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }
@keyframes slide-right  { from{transform:translateX(-100%);opacity:0} to{transform:none;opacity:1} }
@keyframes slide-up     { from{transform:translateY(100%);opacity:0} to{transform:none;opacity:1} }
@keyframes slide-in-r   { from{transform:translateX(100%);opacity:0} to{transform:none;opacity:1} }
@keyframes radar-spin   { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
@keyframes spin         { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
@keyframes blink        { 0%,49%{opacity:1} 50%,100%{opacity:0} }
@keyframes shimmer      { from{background-position:-200% 0} to{background-position:200% 0} }
@keyframes bar-grow     { from{width:0} to{width:var(--target-w)} }

.pulse         { animation: pulse 2s infinite; }
.pulse-dot     { animation: pulse-dot 1.5s infinite; }
.fade-in       { animation: fade-in 0.4s ease forwards; }
.slide-right   { animation: slide-right 0.35s ease forwards; }
.slide-up      { animation: slide-up 0.35s ease forwards; }
.slide-in-r    { animation: slide-in-r 0.3s ease forwards; }
.blink         { animation: blink 1s step-end infinite; }
.spin          { animation: spin 1s linear infinite; }

/* ── LAYOUT ────────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Bar */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 200;
  gap: 8px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── OFFICIAL LOGO — Circular Masking System ─────────────────────────────── */

/*
 * Core circular mask — applied to every logo instance via clip-path + border-radius.
 * Uses both clip-path:circle() AND border-radius:50% + overflow:hidden for
 * maximum cross-browser support (Safari, Chrome, Firefox, Edge).
 * The SVG clipPath approach is also embedded via .logo-svg-mask for large displays.
 */

/* Hidden SVG defs — provides the reusable <clipPath> for SVG-level masking */
.logo-svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Shared image treatment */
.logo-img {
  display: block;
  object-fit: cover;
  object-position: center;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: high-quality;
}

/* Small circular logo — topbar (34px) */
.logo-circle-sm {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  clip-path: circle(50% at 50% 50%);
  -webkit-clip-path: circle(50% at 50% 50%);
  border: 1.5px solid rgba(0, 212, 255, 0.55);
  box-shadow:
    0 0 0 2px rgba(0, 212, 255, 0.12),
    0 0 12px rgba(0, 212, 255, 0.25),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  flex-shrink: 0;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.logo-circle-sm:hover {
  box-shadow:
    0 0 0 3px rgba(0, 212, 255, 0.22),
    0 0 20px rgba(0, 212, 255, 0.4);
  transform: scale(1.04);
}

/* Medium circular logo — loader screen (64px) */
.logo-circle-md {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  clip-path: circle(50% at 50% 50%);
  -webkit-clip-path: circle(50% at 50% 50%);
  border: 2px solid rgba(0, 212, 255, 0.6);
  box-shadow:
    0 0 0 4px rgba(0, 212, 255, 0.1),
    0 0 24px rgba(0, 212, 255, 0.35),
    0 0 48px rgba(0, 212, 255, 0.15);
  flex-shrink: 0;
}

/* Large circular logo — about/info panels (80px) */
.logo-circle-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  clip-path: circle(50% at 50% 50%);
  -webkit-clip-path: circle(50% at 50% 50%);
  border: 2px solid rgba(0, 212, 255, 0.55);
  box-shadow:
    0 0 0 5px rgba(0, 212, 255, 0.08),
    0 0 32px rgba(0, 212, 255, 0.3),
    0 0 64px rgba(0, 212, 255, 0.1);
  flex-shrink: 0;
}

/* Animated glow ring — loader screen pulse */
@keyframes logo-glow-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(0, 212, 255, 0.1),
      0 0 24px rgba(0, 212, 255, 0.35),
      0 0 48px rgba(0, 212, 255, 0.15);
  }
  50% {
    box-shadow:
      0 0 0 8px rgba(0, 212, 255, 0.18),
      0 0 40px rgba(0, 212, 255, 0.55),
      0 0 80px rgba(0, 212, 255, 0.25);
  }
}
.logo-circle-md.animate-glow {
  animation: logo-glow-pulse 2.4s ease-in-out infinite;
}

/* Fallback: if img fails to load, show branded text placeholder */
.logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--cyan), #0044cc);
  font-family: var(--font-display);
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
  user-select: none;
}
.logo-circle-sm.logo-fallback { font-size: 14px; width: 34px; height: 34px; }
.logo-circle-md.logo-fallback { font-size: 28px; width: 64px; height: 64px; }
.logo-circle-lg.logo-fallback { font-size: 34px; width: 80px; height: 80px; }

/* Topbar logo container — transparent background now that real img is used */
.topbar-logo {
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: transparent;
}

.topbar-title { display: flex; flex-direction: column; }
.topbar-name {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 3px;
  line-height: 1;
}
.topbar-sub {
  font-size: 8px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-top: 2px;
}

.topbar-badges {
  display: none;
  align-items: center;
  gap: 6px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-clock {
  display: none;
  flex-direction: column;
  align-items: flex-end;
}
.clock-time {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--cyan);
  line-height: 1;
}
.clock-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-bell {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  border-radius: var(--radius);
  transition: color var(--transition);
}
.topbar-bell:hover, .topbar-bell:focus { color: var(--red); outline: 1px solid var(--border); }

.bell-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--border), #0d2040);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition);
}
.topbar-avatar:hover { border-color: var(--cyan); }

/* Hamburger */
.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.hamburger:focus { outline: 1px solid var(--cyan); }
.hamburger span {
  display: block;
  width: 20px; height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
  transition: all 0.3s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); background: var(--cyan); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); background: var(--cyan); }

/* Body area below topbar */
#layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* Sidebar overlay (mobile) */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.visible { display: block; }

/* Sidebar */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 160;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
#sidebar.open { transform: translateX(0); }

.sidebar-section { padding: 12px 8px; }
.sidebar-section + .sidebar-section { border-top: 1px solid var(--border); }

.sidebar-label {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 2px;
  padding: 4px 8px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: #5a8aab;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  letter-spacing: 0.5px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all var(--transition);
  min-height: 44px; /* accessibility touch target */
}
.nav-btn:hover {
  background: rgba(0,212,255,0.08);
  color: var(--cyan);
}
.nav-btn.active {
  background: rgba(0,212,255,0.12);
  color: var(--cyan);
  border-left-color: var(--cyan);
}
.nav-btn:focus {
  outline: 1px solid var(--cyan);
  outline-offset: -1px;
}

.nav-icon { flex-shrink: 0; }

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
}
.status-label { font-size: 10px; color: var(--text-muted); }
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* Main content */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--bottomnav-h) + 12px);
  min-height: calc(100vh - var(--topbar-h));
  background: var(--bg-deep);
}

/* Module container */
.module {
  padding: 16px 14px;
  animation: fade-in 0.4s ease forwards;
}

/* Bottom navigation (mobile only) */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding: 0 4px;
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.5px;
  border-radius: var(--radius);
  transition: color var(--transition);
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}
.bottom-nav-btn.active { color: var(--cyan); }
.bottom-nav-btn:focus { outline: 1px solid var(--cyan); }

/* ── TYPOGRAPHY ────────────────────────────────────────────────────────────── */
.display-title {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  letter-spacing: 2px;
  line-height: 1.2;
}
.section-label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* ── CARDS ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}
.card:hover { border-color: rgba(0,212,255,0.28); }
.card-body { padding: 14px; }

/* ── BADGES / TAGS ─────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 9px;
  letter-spacing: 1px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag-cyan    { background: rgba(0,212,255,0.1);  color: var(--cyan);   border: 1px solid rgba(0,212,255,0.3); }
.tag-green   { background: rgba(16,185,129,0.12); color: var(--green);  border: 1px solid rgba(16,185,129,0.3); }
.tag-red     { background: rgba(255,51,102,0.12); color: var(--red);    border: 1px solid rgba(255,51,102,0.3); }
.tag-amber   { background: rgba(245,158,11,0.12); color: var(--amber);  border: 1px solid rgba(245,158,11,0.3); }
.tag-purple  { background: rgba(168,85,247,0.12); color: var(--purple); border: 1px solid rgba(168,85,247,0.3); }
.tag-teal    { background: rgba(6,182,212,0.12);  color: var(--teal);   border: 1px solid rgba(6,182,212,0.3); }

/* ── BUTTONS ───────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--cyan);
  color: var(--bg-deep);
  border: none;
  padding: 9px 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-transform: uppercase;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--cyan-dim); transform: translateY(-1px); }
.btn-primary:focus { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-outline {
  background: transparent;
  color: var(--cyan);
  border: 1px solid rgba(0,212,255,0.35);
  padding: 7px 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-transform: uppercase;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-outline:hover { background: rgba(0,212,255,0.1); border-color: var(--cyan); }
.btn-outline:focus { outline: 2px solid var(--cyan); outline-offset: 2px; }

.btn-sm { padding: 5px 12px; font-size: 9px; min-height: 28px; }

/* ── FORM ELEMENTS ─────────────────────────────────────────────────────────── */
.input-field {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
  min-height: 38px;
}
.input-field::placeholder { color: var(--text-muted); }
.input-field:focus { border-color: rgba(0,212,255,0.5); }

textarea.input-field { resize: vertical; min-height: 70px; line-height: 1.5; }

/* ── PROGRESS BAR ──────────────────────────────────────────────────────────── */
.progress-track {
  background: var(--bg-input);
  border-radius: 2px;
  height: 4px;
  overflow: hidden;
  width: 100%;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.8s ease;
}

/* ── GRID HELPERS ──────────────────────────────────────────────────────────── */
.grid-auto    { display: grid; gap: 12px; }
.grid-2       { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3       { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4       { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.col-span-2   { grid-column: span 2; }
.row-span-2   { grid-row: span 2; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }

/* ── STAT CARD ──────────────────────────────────────────────────────────────── */
.stat-card { padding: 16px; }
.stat-card .stat-label { font-size: 9px; color: var(--text-muted); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 8px; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1; }
.stat-card .stat-sub   { font-size: 10px; color: var(--text-muted); margin-top: 5px; }
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── ALERT BANNER ──────────────────────────────────────────────────────────── */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: rgba(255,51,102,0.07);
  border: 1px solid rgba(255,51,102,0.3);
}
.alert-text { font-size: 11px; color: #ff6688; flex: 1; line-height: 1.5; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex-shrink: 0; }

/* ── PHASE GRID ─────────────────────────────────────────────────────────────── */
.phase-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.phase-btn-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 44px;
}
.phase-btn-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.phase-btn-card:focus { outline: 1px solid var(--cyan); }
.phase-num { font-family: var(--font-display); font-size: 16px; font-weight: 900; line-height: 1; }
.phase-icon-wrap {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px auto;
}
.phase-label { font-size: 9px; font-weight: 600; color: var(--text-primary); letter-spacing: 0.5px; }

/* ── HAZARD FEED ITEMS ─────────────────────────────────────────────────────── */
.hazard-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.hazard-item:last-child { border-bottom: none; }
.hazard-info { flex: 1; min-width: 0; }
.hazard-name { font-size: 11px; color: var(--text-primary); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hazard-meta { font-size: 9px; color: var(--text-muted); margin-top: 2px; }
.hazard-intensity { text-align: right; min-width: 50px; }
.hazard-pct { font-size: 9px; color: var(--text-muted); margin-bottom: 2px; }

/* ── LGU COMPLIANCE ITEMS ──────────────────────────────────────────────────── */
.lgu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.lgu-item:last-child { border-bottom: none; }
.lgu-info { flex: 1; min-width: 0; }
.lgu-name { font-size: 11px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lgu-meta { font-size: 9px; color: var(--text-muted); }
.lgu-compliance { min-width: 80px; }
.compliance-header { display: flex; justify-content: space-between; margin-bottom: 3px; }
.compliance-label { font-size: 9px; color: var(--text-muted); }
.compliance-value { font-size: 9px; font-weight: 700; }

/* ── RADAR SVG ──────────────────────────────────────────────────────────────── */
.radar-wrap {
  position: relative;
  width: 180px; height: 180px;
  margin: 0 auto 14px;
}
.radar-svg { position: absolute; top: 0; left: 0; }

/* ── RISK TABLE ─────────────────────────────────────────────────────────────── */
.risk-table { width: 100%; border-collapse: collapse; }
.risk-table th {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1px;
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.risk-table td {
  padding: 9px 8px;
  font-size: 11px;
  border-bottom: 1px solid var(--bg-row);
  vertical-align: middle;
}
.risk-score { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.trend-up   { color: var(--red); }
.trend-down { color: var(--green); }
.trend-stable { color: var(--amber); }

/* ── RISK MATRIX ────────────────────────────────────────────────────────────── */
.risk-matrix { display: grid; grid-template-columns: repeat(5,1fr); gap: 3px; }
.risk-cell {
  height: 26px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: #000;
}

/* ── CONTROL CARD ───────────────────────────────────────────────────────────── */
.control-card { padding: 16px; }
.control-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.control-type { font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.control-count { font-family: var(--font-display); font-size: 24px; font-weight: 900; opacity: 0.5; }
.control-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.control-item:last-child { border-bottom: none; }
.control-dot-wrap {
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.control-dot { width: 5px; height: 5px; border-radius: 50%; }
.control-text { font-size: 10px; color: var(--text-primary); flex: 1; }

/* ── ESSENTIAL ITEM ──────────────────────────────────────────────────────────── */
.essential-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.essential-item:last-child { border-bottom: none; }
.essential-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(168,85,247,0.1);
  border: 1px solid rgba(168,85,247,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  color: var(--purple);
}
.essential-info { flex: 1; min-width: 0; }
.essential-name { font-size: 10px; color: var(--text-primary); }
.essential-score { text-align: right; min-width: 55px; }
.essential-pct  { font-family: var(--font-display); font-size: 13px; font-weight: 700; }

/* ── AGENCY CARD ────────────────────────────────────────────────────────────── */
.agency-card { background: var(--bg-input); border-radius: var(--radius-sm); padding: 10px; border: 1px solid var(--border); }
.agency-name { font-size: 11px; font-weight: 700; color: var(--cyan); }
.agency-type { font-size: 9px; color: var(--text-muted); margin: 4px 0; }
.agency-stat { font-size: 9px; color: var(--text-primary); }
.agency-stat span { color: var(--cyan); }

/* ── CHAT PANEL ─────────────────────────────────────────────────────────────── */
#chat-panel {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 12px);
  right: 12px;
  width: calc(100vw - 24px);
  max-width: 380px;
  height: 500px;
  background: var(--bg-card);
  border: 1px solid rgba(0,212,255,0.35);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  z-index: 300;
  box-shadow: var(--shadow-glow);
  animation: slide-up 0.3s ease forwards;
}
#chat-panel.hidden { display: none; }

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-title { font-size: 11px; font-weight: 700; color: var(--cyan); letter-spacing: 1px; }
.chat-sub { font-size: 9px; color: var(--text-muted); }
.chat-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-close:hover { color: var(--red); }
.chat-close:focus { outline: 1px solid var(--cyan); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg { max-width: 88%; padding: 8px 11px; border-radius: var(--radius-sm); font-size: 11px; line-height: 1.6; word-break: break-word; }
.chat-msg.user    { align-self: flex-end; background: rgba(0,212,255,0.15); border: 1px solid rgba(0,212,255,0.3); }
.chat-msg.ai      { align-self: flex-start; background: var(--bg-input); border: 1px solid var(--border); }
.chat-msg.system  { align-self: flex-start; background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: var(--green); }
.chat-msg.typing  { align-self: flex-start; background: var(--bg-input); border: 1px solid var(--border); }

.chat-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.chat-input { flex: 1; font-size: 11px; }

/* ── COMMAND CHAT ───────────────────────────────────────────────────────────── */
.cmd-messages { height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.cmd-msg { background: var(--bg-input); border-radius: var(--radius-sm); padding: 8px 10px; border: 1px solid var(--border); }
.cmd-msg-header { display: flex; justify-content: space-between; margin-bottom: 3px; }
.cmd-from { font-size: 10px; font-weight: 700; color: var(--teal); }
.cmd-time { font-size: 9px; color: var(--text-muted); }
.cmd-text { font-size: 10px; color: var(--text-primary); line-height: 1.5; }

/* ── SIMULATION ─────────────────────────────────────────────────────────────── */
.sim-param { background: var(--bg-input); border-radius: var(--radius-sm); padding: 10px; border: 1px solid var(--border); }
.sim-param-label { font-size: 9px; color: var(--text-muted); margin-bottom: 4px; }
.sim-param-value { font-size: 13px; font-weight: 700; color: var(--cyan); }

.kpi-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kpi-item:last-child { border-bottom: none; }
.kpi-info { flex: 1; }
.kpi-name { font-size: 11px; color: var(--text-primary); margin-bottom: 4px; }
.kpi-grade { font-family: var(--font-display); font-size: 18px; font-weight: 900; min-width: 36px; text-align: right; }

/* ── DOC ITEM ──────────────────────────────────────────────────────────────── */
.doc-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.doc-item:last-child { border-bottom: none; }
.doc-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 11px; font-weight: 700; color: var(--text-primary); }
.doc-desc { font-size: 9px; color: var(--text-muted); margin-top: 2px; }

/* ── LGU TABLE ──────────────────────────────────────────────────────────────── */
.lgu-table-wrap { overflow-x: auto; }
.lgu-table { width: 100%; min-width: 540px; border-collapse: collapse; }
.lgu-table th {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.lgu-table td {
  padding: 12px;
  border-bottom: 1px solid var(--bg-row);
  vertical-align: middle;
}
.lgu-table tr:hover td { background: rgba(0,212,255,0.03); }

/* ── PARTICIPANTS ────────────────────────────────────────────────────────────── */
.participant { display: flex; align-items: center; gap: 7px; padding: 4px 0; }
.participant-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.participant-name { font-size: 10px; }

/* ── MODULE HEADER ──────────────────────────────────────────────────────────── */
.module-header { margin-bottom: 18px; }
.module-header-inner { display: flex; align-items: center; gap: 10px; }
.module-accent { width: 4px; border-radius: 2px; flex-shrink: 0; }
.module-title { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: #fff; letter-spacing: 2px; }
.module-subtitle { font-size: 10px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }

/* ── INLINE SPINNER ─────────────────────────────────────────────────────────── */
.spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(245,158,11,0.2);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ── AI ANALYSIS BOX ─────────────────────────────────────────────────────────── */
.ai-box {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-primary);
}

/* ── SCORE BOX ──────────────────────────────────────────────────────────────── */
.score-box {
  padding: 12px;
  border-radius: var(--radius-sm);
  text-align: center;
}
.score-label { font-size: 9px; font-weight: 700; margin-bottom: 6px; letter-spacing: 1px; }
.score-value { font-family: var(--font-display); font-size: 30px; font-weight: 900; }
.score-sub   { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* ── VIDEO CONF AREA ─────────────────────────────────────────────────────────── */
.video-placeholder {
  background: #050d14;
  border-radius: var(--radius-sm);
  height: 110px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 10px;
}

/* ── SMS CARD ────────────────────────────────────────────────────────────────── */
.sms-delivered {
  margin-top: 10px;
  background: rgba(16,185,129,0.06);
  border-radius: var(--radius-sm);
  padding: 10px;
  border: 1px solid rgba(16,185,129,0.2);
}

/* ── SHARED DOC ITEM ─────────────────────────────────────────────────────────── */
.shared-doc { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.shared-doc:last-child { border-bottom: none; }
.doc-type-badge {
  width: 28px; height: 28px;
  border-radius: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 700;
  color: var(--teal);
  flex-shrink: 0;
}

/* ── OFFLINE BANNER ──────────────────────────────────────────────────────────── */
#offline-banner {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--amber);
  color: var(--bg-deep);
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  z-index: 500;
  display: none;
  white-space: nowrap;
}
#offline-banner.visible { display: block; }

/* ── ARIA LIVE ──────────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS  ·  Mobile-first approach
   ══════════════════════════════════════════════════════════════ */

/* ── TABLET (≥ 640px) ─────────────────────────────────────────── */
@media (min-width: 640px) {
  .module { padding: 18px 16px; }
  .topbar-badges { display: flex; }
  .phase-grid { grid-template-columns: repeat(7, 1fr); }
  .grid-2-sm { grid-template-columns: 1fr 1fr; }
  .grid-3-sm { grid-template-columns: 1fr 1fr 1fr; }
}

/* ── DESKTOP (≥ 1024px) ──────────────────────────────────────── */
@media (min-width: 1024px) {
  :root { --bottomnav-h: 0px; }

  #topbar { padding: 0 20px; }
  .topbar-clock { display: flex; }

  #sidebar {
    transform: none;
    position: fixed;
  }

  #sidebar-overlay { display: none !important; }

  #layout { margin-left: var(--sidebar-w); }

  #main-content { padding-bottom: 20px; }

  .module { padding: 24px; }

  #bottom-nav { display: none; }

  #chat-panel {
    bottom: 20px;
    right: 20px;
    width: 380px;
  }

  .hamburger { display: none; }
}

/* ── WIDE DESKTOP (≥ 1280px) ─────────────────────────────────── */
@media (min-width: 1280px) {
  .module { padding: 24px 28px; }
}

/* ── HIGH CONTRAST FOCUS ─────────────────────────────────────── */
@media (forced-colors: active) {
  .btn-primary, .btn-outline, .nav-btn, .phase-btn-card {
    border: 2px solid ButtonText;
  }
}

/* ── REDUCED MOTION ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .pulse, .pulse-dot { animation: none; opacity: 1; }
}
