/* ============================================================
   UPKS SARAWAK · AI COMMAND INTELLIGENCE PLATFORM
   SOVEREIGN AI DESIGN SYSTEM v4.1.0
   ============================================================ */

:root {
  --bg-deep:       #020608;
  --bg-base:       #050d12;
  --bg-card:       #071520;
  --bg-card2:      #0a1e2e;
  --bg-glass:      rgba(0,180,255,0.04);
  --border:        rgba(0,200,255,0.12);
  --border-bright: rgba(0,212,255,0.35);
  --cyan:          #00d4ff;
  --cyan-dim:      #0099cc;
  --cyan-glow:     rgba(0,212,255,0.25);
  --green:         #00ff88;
  --green-dim:     #00cc66;
  --yellow:        #ffd700;
  --orange:        #ff8c00;
  --red:           #ff3366;
  --red-dim:       #cc1133;
  --purple:        #8b5cf6;
  --pink:          #ec4899;
  --text-primary:  #e0f4ff;
  --text-sec:      #7ab8d4;
  --text-muted:    #3a6678;
  --sidebar-w:     240px;
  --topbar-h:      56px;
  --radius:        8px;
  --radius-lg:     14px;
  --font-mono:     'Courier New', monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

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

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

/* ═══════════════════════════════════════════════
   BOOT SCREEN
═══════════════════════════════════════════════ */
#boot-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-deep);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 24px;
  transition: opacity 0.8s ease;
}
#boot-screen.hidden { opacity: 0; pointer-events: none; }

.boot-logo { display: flex; align-items: center; gap: 20px; }
.boot-hex { animation: spin-slow 8s linear infinite; filter: drop-shadow(0 0 12px var(--cyan)); }
.boot-title { font-size: 28px; font-weight: 800; letter-spacing: 6px; color: var(--cyan); font-family: var(--font-mono); }
.boot-sub { font-size: 11px; letter-spacing: 3px; color: var(--text-sec); margin-top: 4px; }
.boot-ver { font-size: 10px; letter-spacing: 2px; color: var(--text-muted); margin-top: 6px; font-family: var(--font-mono); }

.boot-bar-wrap {
  width: 360px; height: 3px; background: rgba(0,212,255,0.1);
  border-radius: 2px; overflow: hidden;
}
.boot-bar {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan-dim), var(--cyan), #fff);
  border-radius: 2px; box-shadow: 0 0 10px var(--cyan);
  animation: bootload 2.8s ease forwards;
}
.boot-status { font-family: var(--font-mono); font-size: 11px; color: var(--cyan); letter-spacing: 2px; }

.boot-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

@keyframes bootload { to { width: 100%; } }
@keyframes spin-slow { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════
   LAYOUT SHELL
═══════════════════════════════════════════════ */
#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #030e17 0%, #020a10 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200; overflow-y: auto; overflow-x: hidden;
  transition: width 0.3s ease;
}
#sidebar.collapsed { width: 56px; }
#sidebar.collapsed .brand-text,
#sidebar.collapsed .nav-item span,
#sidebar.collapsed .nav-item .badge-live,
#sidebar.collapsed .sidebar-section-label,
#sidebar.collapsed .sys-status,
#sidebar.collapsed .sys-time { display: none; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px 14px 14px;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.brand-icon { flex-shrink: 0; filter: drop-shadow(0 0 8px var(--cyan)); }
.brand-name { font-size: 16px; font-weight: 800; letter-spacing: 3px; color: var(--cyan); font-family: var(--font-mono); }
.brand-sub { font-size: 9px; letter-spacing: 2px; color: var(--text-muted); margin-top: 2px; }
.sidebar-toggle {
  margin-left: auto; background: none; border: none; color: var(--text-sec);
  cursor: pointer; font-size: 14px; flex-shrink: 0;
  padding: 4px 6px; border-radius: 4px;
}
.sidebar-toggle:hover { color: var(--cyan); background: var(--bg-glass); }

.sidebar-section-label {
  padding: 10px 14px 4px;
  font-size: 9px; letter-spacing: 2.5px; color: var(--text-muted);
  font-family: var(--font-mono); font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; position: relative;
  color: var(--text-sec); transition: all 0.2s;
  cursor: pointer; white-space: nowrap; overflow: hidden;
}
.nav-item i { width: 18px; text-align: center; flex-shrink: 0; font-size: 14px; }
.nav-item span { font-size: 12px; font-weight: 500; }
.nav-item:hover { color: var(--cyan); background: rgba(0,212,255,0.06); }
.nav-item.active {
  color: var(--cyan);
  background: linear-gradient(90deg, rgba(0,212,255,0.12), transparent);
  border-left: 2px solid var(--cyan);
}
.nav-item.active::after {
  content: ''; position: absolute; right: 0; top: 0; bottom: 0;
  width: 1px; background: var(--cyan); opacity: 0.4;
}

.nav-pulse {
  margin-left: auto; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green);
  animation: pulse 2s ease infinite; flex-shrink: 0;
}
.badge-live {
  margin-left: auto; font-size: 8px; letter-spacing: 1px; font-family: var(--font-mono);
  background: rgba(255,51,102,0.2); color: var(--red); border: 1px solid var(--red);
  padding: 1px 5px; border-radius: 3px; flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto; padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 5px;
}
.sys-status { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); letter-spacing: 1px; }
.sys-time { font-family: var(--font-mono); font-size: 11px; color: var(--cyan); margin-top: 4px; }

/* ── DOTS ── */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot.green  { background: var(--green);  box-shadow: 0 0 6px var(--green);  animation: pulse 2s infinite; }
.dot.cyan   { background: var(--cyan);   box-shadow: 0 0 6px var(--cyan);   animation: pulse 2.5s infinite; }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); animation: pulse 3s infinite; }
.dot.orange { background: var(--orange); box-shadow: 0 0 6px var(--orange); animation: pulse 1.5s infinite; }
.dot.red    { background: var(--red);    box-shadow: 0 0 6px var(--red);    animation: pulse 1s infinite; }
.dot.purple { background: var(--purple); box-shadow: 0 0 6px var(--purple); animation: pulse 2s infinite; }

@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ── TOPBAR ── */
#topbar {
  position: fixed; left: var(--sidebar-w); right: 0; top: 0;
  height: var(--topbar-h);
  background: rgba(2,8,12,0.95); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; z-index: 190;
  backdrop-filter: blur(12px);
  transition: left 0.3s ease;
}
#sidebar.collapsed ~ * #topbar,
body.sidebar-collapsed #topbar { left: 56px; }

.topbar-left { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar-breadcrumb { font-size: 13px; font-weight: 700; letter-spacing: 2px; color: var(--cyan); font-family: var(--font-mono); }
.threat-level { display: flex; align-items: center; gap: 5px; font-size: 10px; letter-spacing: 1.5px; font-family: var(--font-mono); color: var(--orange); background: rgba(255,140,0,0.1); border: 1px solid rgba(255,140,0,0.25); padding: 2px 8px; border-radius: 4px; }

.topbar-center { flex: 1; overflow: hidden; }
.live-ticker { display: flex; align-items: center; gap: 10px; background: rgba(0,212,255,0.05); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; }
.ticker-label { font-size: 9px; letter-spacing: 2px; font-family: var(--font-mono); background: var(--red); color: #fff; padding: 1px 6px; border-radius: 3px; flex-shrink: 0; animation: blink 1s infinite; }
.ticker-content { font-size: 11px; color: var(--text-sec); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.5} }

.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar-stat { display: flex; flex-direction: column; align-items: center; gap: 1px; font-family: var(--font-mono); }
.topbar-stat i { color: var(--cyan); font-size: 11px; }
.topbar-stat span { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.topbar-stat small { font-size: 9px; color: var(--text-muted); letter-spacing: 1px; }
.alert-stat span { color: var(--red); }

.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; background: var(--bg-glass); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan-dim), var(--purple)); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.user-info div:first-child { font-size: 11px; font-weight: 600; }
.user-role { font-size: 9px; color: var(--text-muted); }

/* ── MAIN CONTENT ── */
#main-content {
  position: fixed;
  left: var(--sidebar-w); right: 0;
  top: var(--topbar-h); bottom: 0;
  overflow-y: auto; overflow-x: hidden;
  background: var(--bg-base);
  transition: left 0.3s ease;
}
body.sidebar-collapsed #main-content { left: 56px; }

.page-view { display: none; padding: 20px; min-height: 100%; }
.page-view.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ═══════════════════════════════════════════════
   COMMON COMPONENTS
═══════════════════════════════════════════════ */

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative; overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.card:hover { border-color: var(--border-bright); box-shadow: 0 0 20px rgba(0,212,255,0.07); }
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan-glow), transparent);
}

.card-glass {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  backdrop-filter: blur(8px);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 8px;
}
.card-title {
  font-size: 11px; font-weight: 700; letter-spacing: 2px;
  color: var(--text-sec); font-family: var(--font-mono); text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.card-title i { color: var(--cyan); }
.card-actions { display: flex; gap: 6px; }

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
  transition: all 0.3s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.stat-card-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; margin-bottom: 6px;
}
.stat-value { font-size: 28px; font-weight: 800; font-family: var(--font-mono); line-height: 1; }
.stat-label { font-size: 10px; letter-spacing: 1.5px; color: var(--text-sec); text-transform: uppercase; }
.stat-delta { font-size: 11px; display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-delta.warn { color: var(--orange); }

/* Colour themes for stat cards */
.sc-cyan  { border-top: 2px solid var(--cyan);   }
.sc-green { border-top: 2px solid var(--green);  }
.sc-red   { border-top: 2px solid var(--red);    }
.sc-yellow{ border-top: 2px solid var(--yellow); }
.sc-purple{ border-top: 2px solid var(--purple); }
.sc-orange{ border-top: 2px solid var(--orange); }

.sc-cyan   .stat-value { color: var(--cyan); }
.sc-green  .stat-value { color: var(--green); }
.sc-red    .stat-value { color: var(--red); }
.sc-yellow .stat-value { color: var(--yellow); }
.sc-purple .stat-value { color: var(--purple); }
.sc-orange .stat-value { color: var(--orange); }

.sc-cyan   .stat-card-icon { background: rgba(0,212,255,0.1); color: var(--cyan); }
.sc-green  .stat-card-icon { background: rgba(0,255,136,0.1); color: var(--green); }
.sc-red    .stat-card-icon { background: rgba(255,51,102,0.1); color: var(--red); }
.sc-yellow .stat-card-icon { background: rgba(255,215,0,0.1); color: var(--yellow); }
.sc-purple .stat-card-icon { background: rgba(139,92,246,0.1); color: var(--purple); }
.sc-orange .stat-card-icon { background: rgba(255,140,0,0.1); color: var(--orange); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; border: none;
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  text-transform: uppercase;
}
.btn-cyan   { background: rgba(0,212,255,0.15); color: var(--cyan); border: 1px solid rgba(0,212,255,0.3); }
.btn-cyan:hover { background: rgba(0,212,255,0.25); box-shadow: 0 0 16px rgba(0,212,255,0.2); }
.btn-red    { background: rgba(255,51,102,0.15); color: var(--red); border: 1px solid rgba(255,51,102,0.3); }
.btn-red:hover { background: rgba(255,51,102,0.25); }
.btn-green  { background: rgba(0,255,136,0.12); color: var(--green); border: 1px solid rgba(0,255,136,0.3); }
.btn-green:hover { background: rgba(0,255,136,0.22); }
.btn-ghost  { background: transparent; color: var(--text-sec); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--cyan); border-color: var(--cyan); }
.btn-sm { padding: 4px 10px; font-size: 10px; }
.btn-icon { padding: 7px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px; font-size: 10px;
  font-family: var(--font-mono); letter-spacing: 1px; font-weight: 600;
}
.badge-cyan   { background: rgba(0,212,255,0.12); color: var(--cyan); border: 1px solid rgba(0,212,255,0.25); }
.badge-green  { background: rgba(0,255,136,0.1); color: var(--green); border: 1px solid rgba(0,255,136,0.25); }
.badge-red    { background: rgba(255,51,102,0.1); color: var(--red); border: 1px solid rgba(255,51,102,0.25); }
.badge-yellow { background: rgba(255,215,0,0.1); color: var(--yellow); border: 1px solid rgba(255,215,0,0.25); }
.badge-orange { background: rgba(255,140,0,0.1); color: var(--orange); border: 1px solid rgba(255,140,0,0.25); }
.badge-purple { background: rgba(139,92,246,0.1); color: var(--purple); border: 1px solid rgba(139,92,246,0.25); }

/* Page Header */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.page-header-left {}
.page-h1 { font-size: 20px; font-weight: 800; letter-spacing: 2px; color: var(--text-primary); font-family: var(--font-mono); }
.page-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; letter-spacing: 1px; }
.page-header-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Progress Bars */
.progress-bar { height: 6px; background: rgba(255,255,255,0.05); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 1s ease; }
.pf-cyan   { background: linear-gradient(90deg, var(--cyan-dim), var(--cyan)); box-shadow: 0 0 8px var(--cyan-glow); }
.pf-green  { background: linear-gradient(90deg, var(--green-dim), var(--green)); }
.pf-red    { background: linear-gradient(90deg, var(--red-dim), var(--red)); }
.pf-yellow { background: linear-gradient(90deg, #cc9900, var(--yellow)); }
.pf-orange { background: linear-gradient(90deg, #cc5500, var(--orange)); }
.pf-purple { background: linear-gradient(90deg, #5b21b6, var(--purple)); }

/* Tables */
.intel-table { width: 100%; border-collapse: collapse; }
.intel-table th {
  padding: 8px 12px; text-align: left;
  font-size: 9px; letter-spacing: 2px; color: var(--text-muted);
  font-family: var(--font-mono); text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.intel-table td {
  padding: 9px 12px; font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-sec);
}
.intel-table tr:hover td { background: rgba(0,212,255,0.04); color: var(--text-primary); }
.intel-table .mono { font-family: var(--font-mono); font-size: 11px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 14px; position: relative; }
.timeline-item::before {
  content: ''; position: absolute; left: 11px; top: 22px; bottom: 0;
  width: 1px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.tl-dot { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 10px; }
.tl-content { flex: 1; }
.tl-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.tl-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.tl-body { font-size: 11px; color: var(--text-sec); margin-top: 4px; }

/* Risk Meter */
.risk-meter { display: flex; flex-direction: column; gap: 6px; }
.risk-row { display: flex; align-items: center; gap: 10px; }
.risk-label { font-size: 10px; color: var(--text-sec); width: 110px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.risk-bar-wrap { flex: 1; height: 5px; background: rgba(255,255,255,0.05); border-radius: 3px; overflow: hidden; }
.risk-val { font-size: 10px; font-family: var(--font-mono); width: 32px; text-align: right; flex-shrink: 0; }

/* Gauge */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gauge-svg { transform: rotate(-90deg); }
.gauge-val { font-size: 24px; font-weight: 800; font-family: var(--font-mono); }
.gauge-lbl { font-size: 9px; letter-spacing: 2px; color: var(--text-muted); text-transform: uppercase; }

/* Chart containers */
.chart-wrap { position: relative; }
.chart-wrap canvas { max-width: 100%; }

/* Map Canvas */
.map-canvas {
  width: 100%; height: 100%;
  background: #020e1a;
  border-radius: var(--radius);
  position: relative; overflow: hidden;
}
.map-canvas canvas { width: 100% !important; height: 100% !important; }

/* Alert Items */
.alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 8px;
  border: 1px solid transparent;
}
.alert-item.critical { background: rgba(255,51,102,0.07); border-color: rgba(255,51,102,0.2); }
.alert-item.warning  { background: rgba(255,140,0,0.07); border-color: rgba(255,140,0,0.2); }
.alert-item.info     { background: rgba(0,212,255,0.05); border-color: rgba(0,212,255,0.15); }
.alert-item.success  { background: rgba(0,255,136,0.05); border-color: rgba(0,255,136,0.15); }
.alert-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 13px; }
.alert-item.critical .alert-icon { background: rgba(255,51,102,0.15); color: var(--red); }
.alert-item.warning .alert-icon  { background: rgba(255,140,0,0.15); color: var(--orange); }
.alert-item.info .alert-icon     { background: rgba(0,212,255,0.1); color: var(--cyan); }
.alert-item.success .alert-icon  { background: rgba(0,255,136,0.1); color: var(--green); }
.alert-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.alert-meta  { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.alert-body  { font-size: 11px; color: var(--text-sec); margin-top: 3px; }

/* Agent Cards */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px; position: relative; overflow: hidden;
  transition: all 0.3s;
}
.agent-card:hover { border-color: var(--border-bright); transform: translateY(-2px); }
.agent-card.online  { border-top: 2px solid var(--green); }
.agent-card.busy    { border-top: 2px solid var(--yellow); }
.agent-card.standby { border-top: 2px solid var(--cyan); }

.agent-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.agent-avatar { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; position: relative; }
.agent-avatar::after {
  content: ''; position: absolute; bottom: -2px; right: -2px;
  width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bg-card);
}
.agent-card.online  .agent-avatar::after { background: var(--green); }
.agent-card.busy    .agent-avatar::after { background: var(--yellow); animation: pulse 1s infinite; }
.agent-card.standby .agent-avatar::after { background: var(--cyan); }

.agent-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.agent-role { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.agent-status-text { font-size: 10px; font-family: var(--font-mono); margin-top: 8px; padding: 6px 10px; background: rgba(0,0,0,0.2); border-radius: 6px; }
.agent-tasks { margin-top: 10px; font-size: 11px; color: var(--text-sec); }
.agent-actions { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.agent-log { margin-top: 10px; font-size: 10px; font-family: var(--font-mono); color: var(--text-muted); max-height: 60px; overflow: hidden; }
.agent-log div { padding: 1px 0; }

/* Vessel / Entity Rows */
.entity-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  border: 1px solid transparent; margin-bottom: 6px;
  cursor: pointer; transition: all 0.2s;
}
.entity-row:hover { background: rgba(0,212,255,0.05); border-color: var(--border); }
.entity-icon { width: 30px; height: 30px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.entity-name { font-size: 12px; font-weight: 600; flex: 1; }
.entity-meta { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); }
.entity-status { font-size: 10px; display: flex; align-items: center; gap: 4px; }

/* Heatmap grid */
.heatmap-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.hm-cell {
  aspect-ratio: 1; border-radius: 3px;
  transition: all 0.5s;
}

/* Score Ring */
.score-ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.score-ring { position: relative; width: 80px; height: 80px; }
.score-ring svg { transform: rotate(-90deg); }
.score-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; font-family: var(--font-mono); }
.score-lbl { font-size: 9px; letter-spacing: 1.5px; color: var(--text-muted); text-transform: uppercase; }

/* ═══════════════════════════════════════════════
   MAP CANVAS (Geospatial)
═══════════════════════════════════════════════ */
.geo-map-container {
  width: 100%; height: 420px;
  background: #020e1a; border-radius: var(--radius-lg);
  border: 1px solid var(--border); position: relative; overflow: hidden;
}
.geo-map-container canvas { width: 100% !important; height: 100% !important; }

.map-overlay-controls {
  position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 10;
}
.map-btn {
  width: 32px; height: 32px; border-radius: 6px;
  background: rgba(2,14,26,0.9); border: 1px solid var(--border);
  color: var(--text-sec); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all 0.2s;
}
.map-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.map-btn.active { color: var(--cyan); background: rgba(0,212,255,0.1); border-color: var(--cyan); }

.map-legend {
  position: absolute; bottom: 12px; left: 12px;
  background: rgba(2,14,26,0.9); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 5px;
}
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--text-sec); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.map-info-panel {
  position: absolute; top: 12px; left: 12px;
  background: rgba(2,14,26,0.9); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; font-family: var(--font-mono); font-size: 10px;
}
.map-info-panel div { color: var(--text-muted); margin-bottom: 2px; }
.map-info-panel span { color: var(--cyan); }

/* ═══════════════════════════════════════════════
   NOTIFICATION PANEL
═══════════════════════════════════════════════ */
#notif-panel {
  position: fixed; right: -340px; top: var(--topbar-h); bottom: 0;
  width: 330px; background: var(--bg-card); border-left: 1px solid var(--border);
  z-index: 300; transition: right 0.3s ease; overflow-y: auto;
}
#notif-panel.open { right: 0; }
.notif-header {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700;
  letter-spacing: 2px; font-family: var(--font-mono); color: var(--cyan);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
#notif-close { margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; }
.notif-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; gap: 10px; cursor: pointer; transition: background 0.2s;
}
.notif-item:hover { background: rgba(0,212,255,0.04); }
.notif-i-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.notif-i-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.notif-i-time  { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.notif-i-body  { font-size: 11px; color: var(--text-sec); margin-top: 3px; }

/* ═══════════════════════════════════════════════
   AI FLOAT BUTTON
═══════════════════════════════════════════════ */
#ai-float { position: fixed; bottom: 24px; right: 24px; z-index: 400; }
#ai-float-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, #005577, #002244);
  border: 1px solid var(--cyan); color: var(--cyan);
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: all 0.3s;
  box-shadow: 0 0 20px rgba(0,212,255,0.3);
}
#ai-float-btn:hover { transform: scale(1.1); box-shadow: 0 0 30px rgba(0,212,255,0.5); }
.ai-float-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 1px solid rgba(0,212,255,0.3);
  animation: ring-pulse 2s ease infinite;
}
@keyframes ring-pulse { 0%,100%{transform:scale(1);opacity:0.6} 50%{transform:scale(1.15);opacity:0.1} }

/* ═══════════════════════════════════════════════
   AI CHAT MODAL
═══════════════════════════════════════════════ */
#ai-chat-modal {
  position: fixed; right: 82px; bottom: 24px;
  width: 360px; height: 500px;
  background: var(--bg-card); border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg); z-index: 500;
  display: none; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6), 0 0 30px rgba(0,212,255,0.1);
  animation: slideUp 0.3s ease;
}
#ai-chat-modal.open { display: flex; }
@keyframes slideUp { from{transform:translateY(20px);opacity:0} to{transform:translateY(0);opacity:1} }

.chat-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.chat-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan-dim), var(--purple)); display: flex; align-items: center; justify-content: center; font-size: 15px; }
.chat-agent-name { font-size: 12px; font-weight: 700; color: var(--cyan); }
.chat-agent-status { font-size: 10px; color: var(--green); font-family: var(--font-mono); }
.chat-close { margin-left: auto; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 10px; font-size: 12px; line-height: 1.5; }
.chat-msg.ai { background: rgba(0,212,255,0.08); border: 1px solid rgba(0,212,255,0.15); color: var(--text-primary); align-self: flex-start; border-top-left-radius: 2px; }
.chat-msg.user { background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.2); color: var(--text-primary); align-self: flex-end; border-top-right-radius: 2px; }
.chat-msg .msg-time { font-size: 9px; color: var(--text-muted); margin-top: 4px; font-family: var(--font-mono); }
.chat-input-wrap { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-input {
  flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text-primary); font-size: 12px; padding: 7px 14px;
  outline: none; font-family: inherit;
}
.chat-input:focus { border-color: var(--cyan); }
.chat-send { width: 32px; height: 32px; border-radius: 50%; background: rgba(0,212,255,0.15); border: 1px solid var(--cyan); color: var(--cyan); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.chat-send:hover { background: rgba(0,212,255,0.3); }

/* ═══════════════════════════════════════════════
   SPECIFIC PAGE COMPONENTS
═══════════════════════════════════════════════ */

/* Executive Dashboard */
.exec-hero {
  background: linear-gradient(135deg, #020e1a 0%, #031525 50%, #050d12 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; margin-bottom: 16px;
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between;
}
.exec-hero::before {
  content: ''; position: absolute; top: -40px; right: -40px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,212,255,0.08) 0%, transparent 70%);
}
.exec-title { font-size: 24px; font-weight: 800; letter-spacing: 3px; font-family: var(--font-mono); }
.exec-sub { font-size: 12px; color: var(--text-sec); margin-top: 6px; letter-spacing: 1px; }
.exec-datetime { font-family: var(--font-mono); font-size: 22px; color: var(--cyan); font-weight: 300; }
.exec-date-sub { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 4px; }

/* Command Center */
.cmd-map-wrap {
  height: 460px; position: relative;
  background: #020e1a; border-radius: var(--radius-lg);
  border: 1px solid var(--border); overflow: hidden;
}
.cmd-map-wrap canvas { width: 100% !important; height: 100% !important; }
.cmd-overlay-stats {
  position: absolute; bottom: 12px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 8px; pointer-events: none;
}
.cmd-stat-pill {
  background: rgba(2,14,26,0.9); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 12px;
  display: flex; align-items: center; gap: 6px; font-size: 11px; font-family: var(--font-mono);
}

/* Disaster */
.flood-indicator {
  background: linear-gradient(180deg, rgba(0,50,100,0.2) 0%, rgba(0,30,80,0.5) 100%);
  border: 1px solid rgba(0,150,255,0.3);
  border-radius: var(--radius); padding: 12px; text-align: center;
}
.flood-level { font-size: 36px; font-weight: 800; font-family: var(--font-mono); }
.flood-warning { animation: pulse 1.5s infinite; }

/* Maritime */
.vessel-blip {
  position: absolute; transform: translate(-50%, -50%);
  width: 10px; height: 10px; border-radius: 50%;
  cursor: pointer; transition: all 0.3s;
}
.vessel-blip::before {
  content: ''; position: absolute; inset: -4px;
  border-radius: 50%; border: 1px solid currentColor;
  animation: vessel-ping 2s ease infinite;
}
@keyframes vessel-ping { 0%{transform:scale(1);opacity:0.8} 100%{transform:scale(2.5);opacity:0} }

/* KPI Gauges */
.kpi-gauge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; text-align: center;
}
.kpi-val { font-size: 32px; font-weight: 800; font-family: var(--font-mono); line-height: 1; margin: 8px 0 4px; }
.kpi-lbl { font-size: 10px; letter-spacing: 2px; color: var(--text-muted); text-transform: uppercase; }
.kpi-sub { font-size: 11px; color: var(--text-sec); margin-top: 6px; }

/* Resource map */
.resource-list { display: flex; flex-direction: column; gap: 8px; }
.resource-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: rgba(0,0,0,0.15);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: all 0.2s;
}
.resource-item:hover { border-color: var(--cyan); background: rgba(0,212,255,0.04); }
.resource-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.resource-name { font-size: 12px; font-weight: 600; }
.resource-meta { font-size: 10px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 2px; }
.resource-bar-mini { width: 60px; height: 4px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden; margin-top: 4px; }

/* AI Chat (Assistant page) */
.assistant-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; height: calc(100vh - var(--topbar-h) - 60px); }
.assistant-sidebar { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.assistant-main { display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.asst-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.asst-msg-ai { display: flex; gap: 10px; align-items: flex-start; }
.asst-msg-user { display: flex; gap: 10px; align-items: flex-start; flex-direction: row-reverse; }
.asst-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.asst-bubble { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 12px; line-height: 1.6; }
.asst-msg-ai .asst-bubble { background: rgba(0,212,255,0.06); border: 1px solid rgba(0,212,255,0.15); border-top-left-radius: 2px; }
.asst-msg-user .asst-bubble { background: rgba(139,92,246,0.1); border: 1px solid rgba(139,92,246,0.2); border-top-right-radius: 2px; }
.asst-input-wrap { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; }
.asst-input { flex: 1; background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary); font-size: 13px; padding: 10px 14px; min-height: 44px; max-height: 120px; resize: none; outline: none; font-family: inherit; }
.asst-input:focus { border-color: var(--cyan); }
.asst-send { padding: 10px 16px; background: rgba(0,212,255,0.12); border: 1px solid var(--cyan); color: var(--cyan); border-radius: 8px; cursor: pointer; font-size: 13px; transition: all 0.2s; }
.asst-send:hover { background: rgba(0,212,255,0.25); }

/* Scanning effect */
.scan-line {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  animation: scan 3s linear infinite; pointer-events: none;
}
@keyframes scan { 0%{top:0%} 100%{top:100%} }

/* Glow effects */
.glow-cyan   { text-shadow: 0 0 10px var(--cyan); }
.glow-green  { text-shadow: 0 0 10px var(--green); }
.glow-red    { text-shadow: 0 0 10px var(--red); }
.glow-yellow { text-shadow: 0 0 10px var(--yellow); }

/* Number counter */
.counter { display: inline-block; transition: all 0.5s; }

/* Typing indicator */
.typing-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); animation: tdot 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdot { 0%,80%,100%{transform:scale(0);opacity:0.3} 40%{transform:scale(1);opacity:1} }

/* Animated scan rings */
.scan-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(0,212,255,0.3);
  animation: expand-ring 3s ease-out infinite;
  pointer-events: none;
}
@keyframes expand-ring { 0%{transform:scale(0.5);opacity:0.8} 100%{transform:scale(3);opacity:0} }

/* Weather card */
.weather-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.weather-city {
  flex-shrink: 0; background: var(--bg-card2);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; text-align: center; min-width: 90px;
}
.weather-city-name { font-size: 10px; color: var(--text-muted); margin-bottom: 4px; letter-spacing: 1px; }
.weather-temp { font-size: 20px; font-weight: 800; font-family: var(--font-mono); }
.weather-desc { font-size: 9px; color: var(--text-sec); margin-top: 3px; }
.weather-icon { font-size: 18px; margin: 4px 0; }

/* Scrollable content area */
.scroll-area { overflow-y: auto; }
.scroll-area-h { overflow-x: auto; }

/* Incident list */
.incident-row {
  display: grid; grid-template-columns: 26px 1fr auto auto auto;
  align-items: center; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid rgba(255,255,255,0.03);
  cursor: pointer; transition: background 0.2s;
}
.incident-row:hover { background: rgba(0,212,255,0.04); }
.inc-sev { width: 8px; height: 8px; border-radius: 50%; }

/* Responsive */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .assistant-layout { grid-template-columns: 1fr; }
}

/* Utility */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-cyan   { color: var(--cyan); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-orange { color: var(--orange); }
.text-purple { color: var(--purple); }
.text-muted  { color: var(--text-muted); }
.text-sec    { color: var(--text-sec); }
.text-mono   { font-family: var(--font-mono); }
.text-sm     { font-size: 11px; }
.text-xs     { font-size: 10px; }
.font-bold   { font-weight: 700; }
.text-right  { text-align: right; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full      { width: 100%; }
.hidden      { display: none !important; }
.opacity-0   { opacity: 0; }
.pointer     { cursor: pointer; }
.relative    { position: relative; }
.overflow-hidden { overflow: hidden; }
.rounded { border-radius: var(--radius); }
.section-gap { margin-top: 20px; }
