/* =============================================================================
   AgenticTestari · Security Operations Center Dashboard
   Dark-first tactical aesthetic. Brand accent: RED #ff3333.
   Private code. No competitor names. No IPs/ports. No emojis in UI.
   ============================================================================= */

/* ---------- Design tokens ---------- */
:root {
  /* Brand */
  --brand: #ff3333;
  --brand-soft: rgba(255, 51, 51, 0.14);
  --brand-glow: rgba(255, 51, 51, 0.35);
  --brand-line: rgba(255, 51, 51, 0.30);

  /* Status colors (tactical) */
  --crit: #ff3344;
  --high: #ff8c42;
  --med:  #ffd166;
  --low:  #4dd2ff;
  --info: #8b9cff;
  --ok:   #3ddc97;
  --warn: #ffb454;

  /* Dark theme (default) */
  --bg:        #0a0e14;
  --bg-grad-a: #1a0808;
  --bg-grad-b: #0a0f1a;
  --surface:   #11161f;
  --surface-2: #161c27;
  --surface-3: #1c2433;
  --line:      #232c3b;
  --line-soft: #1a212c;
  --text:      #e6ecf5;
  --text-dim:  #9aa7bd;
  --text-faint:#5f6c80;
  --shadow:    0 4px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);

  /* Typography */
  --font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;

  /* Geometry */
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --gap:       16px;
  --gap-lg:    24px;

  /* Motion */
  --t-fast: 120ms ease;
  --t-med:  220ms ease;
}

/* ---------- Light theme override ---------- */
[data-theme="light"] {
  --bg:        #f4f6fa;
  --bg-grad-a: #f9ecec;
  --bg-grad-b: #eef2f7;
  --surface:   #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef1f6;
  --line:      #d9e0ea;
  --line-soft: #e6ebf2;
  --text:      #141a24;
  --text-dim:  #4a5668;
  --text-faint:#8593a8;
  --shadow:    0 2px 12px rgba(20,30,50,0.08);
  --shadow-lg: 0 8px 28px rgba(20,30,50,0.12);
  --brand-soft: rgba(255, 51, 51, 0.08);
  --brand-glow: rgba(255, 51, 51, 0.18);
  --brand-line: rgba(255, 51, 51, 0.22);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background:
    radial-gradient(1000px 420px at 12% -8%, var(--bg-grad-a) 0%, transparent 55%),
    radial-gradient(900px 380px at 88% 0%, var(--bg-grad-b) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-med), color var(--t-med);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--brand-soft); }

/* ---------- Layout primitives ---------- */
.container {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 32px);
}
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.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;
}

/* =============================================================================
   TOP BAR
   ============================================================================= */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); min-height: 60px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  font-weight: 700; color: var(--text); text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, #cc1f1f 100%);
  display: grid; place-items: center;
  box-shadow: 0 0 0 1px var(--brand-line), 0 0 18px var(--brand-glow);
  flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; color: #fff; }
.brand-name { font-size: 1.05rem; line-height: 1.1; }
.brand-name b { color: var(--brand); font-weight: 700; }
.brand-sub {
  font-size: 0.66rem; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600;
  font-family: var(--font-mono);
}

.topbar-tools {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

/* Language switch */
.lang-switch { display: flex; gap: 3px; align-items: center; }
.lang-switch button {
  background: transparent; border: 1px solid var(--line);
  color: var(--text-dim); border-radius: var(--radius-sm);
  padding: 5px 8px; font-size: 0.7rem; font-weight: 700;
  line-height: 1; transition: all var(--t-fast);
}
.lang-switch button:hover { color: var(--text); border-color: var(--text-faint); }
.lang-switch button.on {
  color: var(--brand); border-color: var(--brand-line);
  background: var(--brand-soft);
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-dim); transition: all var(--t-fast);
}
.theme-toggle:hover {
  color: var(--brand); border-color: var(--brand-line);
  background: var(--brand-soft);
}
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun  { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: none; }

/* Status pill in topbar */
.live-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(61, 220, 151, 0.10);
  border: 1px solid rgba(61, 220, 151, 0.30);
  font-size: 0.72rem; font-weight: 600; color: var(--ok);
  font-family: var(--font-mono);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 rgba(61,220,151,0.6);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(61,220,151,0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(61,220,151,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); }
}

/* =============================================================================
   COMPLIANCE STRIP (first thing customer sees)
   ============================================================================= */
.compliance-strip {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.compliance-inner {
  display: flex; align-items: center; gap: var(--gap-lg);
  padding: 12px 0; flex-wrap: wrap;
}
.compliance-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-faint); font-weight: 700; font-family: var(--font-mono);
  white-space: nowrap;
}
.compliance-badges {
  display: flex; gap: 10px; flex-wrap: wrap; flex: 1;
}
.compliance-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 13px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 0.76rem; font-weight: 600; color: var(--text-dim);
  transition: all var(--t-fast);
}
.compliance-badge:hover {
  border-color: var(--brand-line); color: var(--text);
}
.compliance-badge .cb-icon {
  width: 16px; height: 16px; color: var(--brand); flex-shrink: 0;
}
.compliance-badge .cb-check {
  width: 14px; height: 14px; color: var(--ok); flex-shrink: 0;
}

/* =============================================================================
   PAGE HEAD / HERO
   ============================================================================= */
.page-head {
  padding: var(--gap-lg) 0 var(--gap);
}
.page-head h1 {
  font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700;
  letter-spacing: -0.02em; margin-bottom: 6px;
}
.page-head h1 .accent { color: var(--brand); }
.page-head p {
  color: var(--text-dim); font-size: 0.92rem; max-width: 720px;
}
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.74rem; color: var(--text-faint);
  font-family: var(--font-mono); margin-bottom: 14px;
}
.breadcrumb span.sep { opacity: 0.5; }

/* =============================================================================
   KPI ROW
   ============================================================================= */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  margin-bottom: var(--gap-lg);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.kpi-card:hover { border-color: var(--brand-line); }
.kpi-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--kpi-accent, var(--brand));
  opacity: 0.7;
}
.kpi-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-faint); font-weight: 600; margin-bottom: 10px;
  font-family: var(--font-mono);
}
.kpi-value {
  font-size: 1.9rem; font-weight: 700; line-height: 1;
  font-family: var(--font-mono); letter-spacing: -0.02em;
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.74rem; font-weight: 600; margin-top: 8px;
  font-family: var(--font-mono);
}
.kpi-delta.up   { color: var(--ok); }
.kpi-delta.down { color: var(--crit); }
.kpi-delta.flat { color: var(--text-faint); }
.kpi-spark {
  position: absolute; bottom: 0; right: 0; left: 0; height: 32px;
  opacity: 0.5; pointer-events: none;
}

/* =============================================================================
   SECTION / PANEL system
   ============================================================================= */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.panel-title {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 0.92rem; font-weight: 700; letter-spacing: -0.01em;
}
.panel-title .pt-icon {
  width: 18px; height: 18px; color: var(--brand); flex-shrink: 0;
}
.panel-meta {
  font-size: 0.72rem; color: var(--text-faint);
  font-family: var(--font-mono);
}
.panel-body { padding: 18px; }
.panel-actions { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-dim); font-family: var(--font-mono);
}

/* Grid for main content */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--gap);
  margin-bottom: var(--gap-lg);
}

/* =============================================================================
   SECURITY OPERATIONS CENTER (main feed)
   ============================================================================= */
.soc-feed { max-height: 420px; overflow-y: auto; }
.soc-feed::-webkit-scrollbar { width: 6px; }
.soc-feed::-webkit-scrollbar-track { background: transparent; }
.soc-feed::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.soc-entry {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 12px; align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.84rem;
}
.soc-entry:last-child { border-bottom: none; }
.soc-sev {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 6px; flex-shrink: 0;
  background: var(--sev-color, var(--info));
  box-shadow: 0 0 8px var(--sev-color, var(--info));
}
.soc-time {
  font-family: var(--font-mono); font-size: 0.72rem;
  color: var(--text-faint); white-space: nowrap; margin-top: 1px;
}
.soc-text { color: var(--text); line-height: 1.4; }
.soc-text .tag {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 0.68rem; font-weight: 700; font-family: var(--font-mono);
  background: var(--brand-soft); color: var(--brand);
  margin-right: 5px; vertical-align: 1px;
}
.soc-text .target {
  font-family: var(--font-mono); color: var(--text-dim); font-size: 0.78rem;
}
.soc-agent {
  font-size: 0.72rem; color: var(--text-faint);
  font-family: var(--font-mono); white-space: nowrap;
}

/* severity color helpers */
.sev-crit { --sev-color: var(--crit); }
.sev-high { --sev-color: var(--high); }
.sev-med  { --sev-color: var(--med); }
.sev-low  { --sev-color: var(--low); }
.sev-info { --sev-color: var(--info); }

/* =============================================================================
   ATTACK SURFACE MAP (placeholder)
   ============================================================================= */
.attack-map {
  position: relative;
  min-height: 340px;
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--surface-2);
  border-radius: var(--radius);
  overflow: hidden;
}
.attack-map-svg { width: 100%; height: 100%; min-height: 340px; }
.map-legend {
  position: absolute; bottom: 12px; left: 12px;
  display: flex; flex-direction: column; gap: 5px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 0.72rem;
}
.map-legend-row { display: flex; align-items: center; gap: 7px; color: var(--text-dim); }
.map-legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.map-overlay-note {
  position: absolute; top: 12px; right: 12px;
  font-size: 0.7rem; color: var(--text-faint);
  font-family: var(--font-mono);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  padding: 4px 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* =============================================================================
   TEST RESULTS OVERVIEW
   ============================================================================= */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  margin-bottom: var(--gap-lg);
}
.sev-bar-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.sev-bar-label {
  width: 90px; font-size: 0.8rem; font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.sev-bar-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sev-bar-track {
  flex: 1; height: 22px; background: var(--surface-3);
  border-radius: 4px; overflow: hidden; position: relative;
}
.sev-bar-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.sev-bar-count {
  width: 36px; text-align: right; font-family: var(--font-mono);
  font-size: 0.82rem; font-weight: 700;
}

.findings-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.findings-table th {
  text-align: left; padding: 8px 12px;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); font-weight: 700;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
}
.findings-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft);
  color: var(--text-dim); vertical-align: middle;
}
.findings-table tr:last-child td { border-bottom: none; }
.findings-table tr:hover td { background: var(--surface-2); }
.findings-table .f-id { font-family: var(--font-mono); color: var(--text-faint); font-size: 0.76rem; }
.findings-table .f-name { color: var(--text); font-weight: 500; }

.sev-tag {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 0.66rem; font-weight: 700; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.sev-tag.crit { background: rgba(255,51,68,0.15); color: var(--crit); }
.sev-tag.high { background: rgba(255,140,66,0.15); color: var(--high); }
.sev-tag.med  { background: rgba(255,209,102,0.15); color: var(--med); }
.sev-tag.low  { background: rgba(77,210,255,0.15); color: var(--low); }
.sev-tag.info { background: rgba(139,156,255,0.15); color: var(--info); }

.status-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 600;
}
.status-tag .sd { width: 6px; height: 6px; border-radius: 50%; }
.status-open   .sd { background: var(--crit); }
.status-fixed  .sd { background: var(--ok); }
.status-verif  .sd { background: var(--info); }
.status-open   { color: var(--crit); }
.status-fixed  { color: var(--ok); }
.status-verif  { color: var(--info); }

/* =============================================================================
   AGENT STATUS GRID
   ============================================================================= */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--gap);
}
.agent-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color var(--t-fast);
  position: relative;
}
.agent-card:hover { border-color: var(--brand-line); }
.agent-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.agent-name {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.86rem; font-weight: 700;
}
.agent-icon {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; flex-shrink: 0;
}
.agent-icon svg { width: 16px; height: 16px; }
.agent-state {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.68rem; font-weight: 700; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.agent-state .as-dot { width: 7px; height: 7px; border-radius: 50%; }
.agent-active   .as-dot { background: var(--ok);   animation: pulse-dot 2s infinite; }
.agent-idle     .as-dot { background: var(--warn); }
.agent-offline  .as-dot { background: var(--text-faint); }
.agent-scanning .as-dot { background: var(--info);  animation: pulse-dot 1.5s infinite; }
.agent-active   { color: var(--ok); }
.agent-idle     { color: var(--warn); }
.agent-offline  { color: var(--text-faint); }
.agent-scanning { color: var(--info); }

.agent-task {
  font-size: 0.76rem; color: var(--text-dim); margin-bottom: 12px;
  min-height: 2.4em; line-height: 1.3;
}
.agent-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding-top: 10px; border-top: 1px solid var(--line-soft);
}
.agent-stat { font-size: 0.72rem; }
.agent-stat b {
  display: block; font-family: var(--font-mono); font-size: 0.92rem;
  color: var(--text); font-weight: 700;
}
.agent-stat span { color: var(--text-faint); }

/* progress bar in agent card */
.agent-progress {
  height: 3px; background: var(--surface-3); border-radius: 2px;
  overflow: hidden; margin-bottom: 10px;
}
.agent-progress-fill {
  height: 100%; background: var(--brand); border-radius: 2px;
  transition: width var(--t-med);
}

/* =============================================================================
   VULNERABILITY TIMELINE
   ============================================================================= */
.timeline-panel { margin-bottom: var(--gap-lg); }
.timeline-chart {
  position: relative; height: 220px; width: 100%;
}
.timeline-chart svg { width: 100%; height: 100%; }
.timeline-legend {
  display: flex; gap: var(--gap); flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.tl-legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.76rem; color: var(--text-dim);
}
.tl-legend-swatch {
  width: 14px; height: 3px; border-radius: 2px;
}

/* =============================================================================
   FOOTER
   ============================================================================= */
.dash-footer {
  border-top: 1px solid var(--line);
  padding: var(--gap-lg) 0;
  margin-top: var(--gap-lg);
}
.dash-footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--gap); flex-wrap: wrap;
  font-size: 0.78rem; color: var(--text-faint);
}
.dash-footer .footer-brand {
  display: inline-flex; align-items: center; gap: 8px;
}
.dash-footer .footer-brand b { color: var(--brand); }
.footer-meta { font-family: var(--font-mono); }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .topbar-inner { min-height: auto; padding: 10px 0; }
  .brand-sub { display: none; }
  .soc-entry { grid-template-columns: auto 1fr; }
  .soc-time, .soc-agent { grid-column: 2; }
  .findings-table { font-size: 0.76rem; }
  .findings-table th, .findings-table td { padding: 7px 8px; }
}
@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr; }
  .compliance-inner { gap: 12px; }
  .container { padding: 0 14px; }
}

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