/* ==========================================================================
   Threat Intel Platform — Unified Theme
   Inspired by OpenCTI / Microsoft Defender design language
   ========================================================================== */

/* ── Variables — KESTREL design system (blue-slate ground, signal-amber accent) ── */
/* DARK-ONLY: this platform ships a single dark theme. There is deliberately no
   light theme, no prefers-color-scheme branch and no [data-theme]/.light hooks. */
:root {
  --bg-app:      #0e141f;
  --bg-surface:  #111826;
  --bg-card:     #161d2b;
  --bg-card-soft:#141b28;
  --bg-hover:    #1d2636;
  --bg-input:    #111826;
  --bg-stripe:   #18202f;

  --border:        rgba(233, 238, 246, 0.09);
  --border-bright: rgba(233, 238, 246, 0.17);
  --border-input:  rgba(233, 238, 246, 0.17);

  --text-primary:   #e9eef6;
  --text-secondary: #9aa5b8;
  --text-muted:     #7c87a0;

  /* Signal amber — brand, active nav, links and primary actions ONLY.
     Never used for severity, charts or status. */
  --accent:      #e8a33d;
  --accent-ink:  #f0b45c;
  --accent-dim:  rgba(232, 163, 61, 0.13);
  --accent-glow: rgba(232, 163, 61, 0.22);

  --blue:        #4c8fe0;
  --blue-bright: #4f8cff;  /* single source for the brighter accent-blue used by AI/workspace chrome */
  --blue-glow:   rgba(76, 143, 224, 0.16);
  --cyan:        #45b3c4;
  --green:       #3fb868;
  --red:         #e5484d;
  --yellow:      #d9a83b;
  --purple:      #8878e8;
  --orange:      #ed7a3c;

  /* Severity scale — reserved for threat/status meaning only.
     Do not use these (or red/orange/yellow) for decoration. */
  --sev-critical: #e5484d;
  --sev-high:     #ed7a3c;
  --sev-medium:   #d9a83b;
  /* Brightened from #7a8ba6/#7c87a0 to clear WCAG-AA (4.5:1) on the tinted
     .badge-low/.badge-info chip backgrounds, where the originals fell to ~4.0:1. */
  --sev-low:      #98a6be;
  --sev-info:     #9aa5b8;

  /* Neutral accent for entity-type identity (icons carry the meaning, not color) */
  --neutral-chip-bg:     rgba(233, 238, 246, 0.07);
  --neutral-chip-border: rgba(233, 238, 246, 0.16);

  --font-data: 'Cascadia Code', 'Consolas', 'SF Mono', 'JetBrains Mono', monospace;

  --sidebar-w:   240px;
  --sidebar-w-rail: 64px;
  --topbar-h:    56px;

  --radius-sm:   4px;
  --radius:      6px;
  --radius-lg:   10px;

  --shadow-card:     0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.18);
  --shadow-elevated: 0 16px 40px rgba(0,0,0,0.36), 0 0 0 1px var(--border-bright);

  --transition: 0.18s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.55;
}
a { color: var(--accent-ink); text-decoration: none; }

/* Keyboard focus: mouse/pointer focus stays ring-free, keyboard focus gets a
   clear amber ring on buttons, links, tabs, pagination and inputs alike. */
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Atmospheric grid and responsive spotlight: visual context without UI noise. */
.ambient-grid { position:fixed; inset:0; z-index:-1; overflow:hidden; pointer-events:none; background-image:linear-gradient(rgba(120,150,190,.025) 1px,transparent 1px),linear-gradient(90deg,rgba(120,150,190,.025) 1px,transparent 1px); background-size:40px 40px; mask-image:linear-gradient(to bottom,black,transparent 78%); }
.ambient-grid span { position:absolute; border-radius:999px; opacity:.45; }
.ambient-grid span:nth-child(1) { width:34rem;height:34rem;right:-12rem;top:-16rem;background:radial-gradient(circle,var(--blue-glow),transparent 70%); }
.ambient-grid span:nth-child(2) { width:28rem;height:28rem;left:18%;bottom:-20rem;background:radial-gradient(circle,var(--accent-dim),transparent 70%); }
.ambient-grid span:nth-child(3) { width:18rem;height:18rem;left:var(--pointer-x,65%);top:var(--pointer-y,25%);transform:translate(-50%,-50%);background:radial-gradient(circle,rgba(76,143,224,.09),transparent 72%);transition:left .6s ease-out,top .6s ease-out; }

.card,.kpi-card { position:relative;overflow:clip;background-image:linear-gradient(145deg,rgba(255,255,255,.018),transparent 42%);transition:border-color var(--transition),transform var(--transition),box-shadow var(--transition); }
.card::before,.kpi-card::before { content:"";position:absolute;inset:0 auto auto 0;width:100%;height:1px;background:linear-gradient(90deg,transparent,rgba(255,255,255,.16),transparent);pointer-events:none; }
.card:hover,.kpi-card:hover { transform:translateY(-2px);box-shadow:0 12px 34px rgba(0,0,0,.24); }
.page-header h1 { text-wrap:balance; }
.page-header p { max-width:76ch; }

/* Reusable evidence/file attachment primitive. */
.attachment-group { display:flex;gap:10px;overflow-x:auto;padding:2px 2px 8px;scroll-snap-type:x proximity; }
.attachment { min-width:220px;display:grid;grid-template-columns:36px minmax(0,1fr) auto;align-items:center;gap:10px;padding:10px;border:1px solid var(--border);border-radius:var(--radius-lg);background:rgba(17,24,38,.72);scroll-snap-align:start;transition:border-color var(--transition),background var(--transition); }
.attachment:hover { border-color:var(--border-bright);background:var(--bg-hover); }
.attachment-media { width:36px;height:36px;display:grid;place-items:center;border:1px solid var(--border);border-radius:var(--radius);background:var(--neutral-chip-bg);color:var(--text-secondary); }
.attachment-media svg { width:17px;height:17px; }
.attachment-content { min-width:0; }
.attachment-title { overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:600;color:var(--text-primary); }
.attachment-description { font:10px/1.5 var(--font-data);color:var(--text-muted); }
.attachment-action { width:28px;height:28px;display:grid;place-items:center;border:0;border-radius:var(--radius);background:transparent;color:var(--text-muted);cursor:pointer; }
.attachment-action:hover { background:var(--neutral-chip-bg);color:var(--text-primary); }
.attachment[data-state="processing"] .attachment-title { background:linear-gradient(90deg,var(--text-muted),var(--text-primary),var(--text-muted));background-size:200% 100%;color:transparent;background-clip:text;animation:attachment-shimmer 1.5s linear infinite; }
.attachment[data-state="error"] { border-color:rgba(229,72,77,.45); }
@keyframes attachment-shimmer { to { background-position:-200% 0; } }
.ui-reveal { opacity:0;transform:translateY(10px); }
.ui-reveal.is-visible { animation:ui-reveal .52s cubic-bezier(.2,.75,.25,1) both;animation-delay:var(--reveal-delay,0ms); }
@keyframes ui-reveal { to { opacity:1;transform:none; } }
@media (prefers-reduced-motion:reduce) { .ambient-grid span:nth-child(3),.card,.kpi-card{transition:none}.card:hover,.kpi-card:hover{transform:none}.ui-reveal,.ui-reveal.is-visible{opacity:1;transform:none;animation:none}.attachment[data-state="processing"] .attachment-title{animation:none;color:var(--text-secondary);background:none} }
.ambient-grid { z-index: 0; }
.app-shell, .auth-shell { position: relative; z-index: 1; }
a:hover { color: #f6c577; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }

/* Unified "eyebrow" label — small uppercase kicker above workspace headings.
   Single source for the former .workspace-eyebrow / .core-eyebrow / .ai-eyebrow. */
.eyebrow { display:inline-flex; align-items:center; gap:8px; font-size:10px; font-weight:700; letter-spacing:.14em; text-transform:uppercase; color:var(--blue-bright); }
.eyebrow > span:empty { flex:0 0 auto; width:6px; height:6px; border-radius:50%; background:var(--green); box-shadow:0 0 12px var(--green); }

/* ── App Shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 30px; height: 30px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-icon svg { width: 16px; height: 16px; color: var(--accent); }

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sidebar-brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-section {
  padding: 14px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Collapsible sidebar groups ── */
.sidebar-group + .sidebar-group {
  border-top: 1px solid var(--border);
}

.sidebar-section-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  padding: 13px 16px 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color var(--transition);
}

.sidebar-section-btn:hover { color: var(--text-secondary); }

.sidebar-section-btn-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sidebar-group-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sidebar-group-dot.blue,
.sidebar-group-dot.cyan,
.sidebar-group-dot.green,
.sidebar-group-dot.orange,
.sidebar-group-dot.slate  { background: var(--text-muted); opacity: 0.7; }

.sidebar-section-btn .chevron {
  width: 12px; height: 12px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: transform var(--transition);
}

.sidebar-group.collapsed .sidebar-section-btn .chevron { transform: rotate(-90deg); }

.sidebar-group-body {
  display: flex;
  flex-direction: column;
}

.sidebar-group.collapsed .sidebar-group-body { display: none; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: all var(--transition);
  position: relative;
}

.sidebar-nav a svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-left-color: var(--border-bright);
}

.sidebar-nav a:hover svg { opacity: 1; }

.sidebar-nav a.active {
  color: var(--accent-ink);
  background: var(--accent-dim);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-nav a.active svg { opacity: 1; color: var(--accent-ink); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.user-pill:hover { border-color: var(--border-bright); }

.user-avatar {
  width: 28px; height: 28px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-ink);
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-pill svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }

.user-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
  display: none;
  z-index: 300;
}

.user-dropdown.open { display: block; }

.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.user-dropdown a:hover { background: var(--bg-hover); color: var(--red); }
.user-dropdown a svg { width: 14px; height: 14px; }

/* ── Main Wrapper ── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.topbar-hamburger:hover { color: var(--text-primary); }
.topbar-hamburger svg { width: 20px; height: 20px; }

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-breadcrumb span { color: var(--text-secondary); }
.topbar-breadcrumb .sep { color: var(--text-muted); }

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--green);
  font-weight: 500;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}

/* ── Content Area ── */
.content {
  flex: 1;
  width: 100%;
  max-width: none;
  padding: 28px clamp(20px, 2.2vw, 36px) 36px;
}

.content-narrow {
  max-width: 1280px;
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-header p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.card-header h2, .card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header .card-icon {
  width: 28px; height: 28px;
  background: var(--accent-dim);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.card-header .card-icon svg { width: 14px; height: 14px; color: var(--accent-ink); }

.card-body { padding: 20px; }

.card + .card { margin-top: 20px; }

/* ── Stat Cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color var(--transition);
  min-width: 0;
}

.stat-card:hover { border-color: var(--border-bright); }

.stat-card-alert {
  border-color: rgba(229,72,77,0.35);
  background: linear-gradient(180deg, rgba(229,72,77,0.07), var(--bg-card) 70%);
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue  { background: rgba(76,143,224,0.14); color: var(--blue); }
.stat-icon.cyan  { background: rgba(69,179,196,0.12); color: var(--cyan); }
.stat-icon.green { background: rgba(63,184,104,0.12); color: var(--green); }
.stat-icon.red   { background: rgba(229,72,77,0.12); color: var(--red); }
.stat-icon.yellow{ background: rgba(217,168,59,0.12); color: var(--yellow); }
.stat-icon.purple{ background: rgba(136,120,232,0.12); color: var(--purple); }
.stat-icon.orange{ background: rgba(237,122,60,0.12); color: var(--orange); }
.stat-icon.neutral { background: var(--neutral-chip-bg); color: var(--text-secondary); }

/* Hero metric — the one number the eye should land on first */
.stat-card-hero {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(232,163,61,0.10), var(--bg-card) 62%);
  border-color: rgba(232,163,61,0.35);
}
.stat-card-hero .stat-icon { width: 52px; height: 52px; }
.stat-card-hero .stat-icon svg { width: 26px; height: 26px; }
.stat-card-hero .stat-value {
  font-size: 34px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card-hero .stat-label { font-size: 12px; }
.stat-card-hero .stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}
@media (max-width: 640px) {
  .stat-card-hero { grid-column: span 1; }
}

.stat-info { min-width: 0; }
.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 16px;
  animation: slideDown 0.2s ease;
}

.alert[hidden] { display: none; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

.alert-success {
  background: rgba(61, 220, 155, 0.10);
  border-color: rgba(61, 220, 155, 0.3);
  color: var(--green);
}

.alert-error {
  background: rgba(255, 107, 107, 0.10);
  border-color: rgba(255, 107, 107, 0.3);
  color: var(--red);
}

.alert-info {
  background: rgba(91, 157, 255, 0.10);
  border-color: rgba(91, 157, 255, 0.3);
  color: var(--blue);
}

.alert-warning {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--yellow);
}

/* ── Toasts (transient flash messages, moved here by app.js) ── */
.toast-stack {
  position: fixed;
  top: calc(var(--topbar-h) + 14px);
  right: 20px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(400px, calc(100vw - 40px));
  pointer-events: none;
}

.toast-stack .alert {
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-left: 3px solid currentColor;
  box-shadow: var(--shadow-elevated);
  padding-right: 36px;
  position: relative;
  pointer-events: auto;
  animation: toastIn 0.28s cubic-bezier(0.21, 1.02, 0.55, 1);
}

.toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  font-family: inherit;
}

.toast-close:hover { opacity: 1; }

.toast-out {
  opacity: 0 !important;
  transform: translateX(14px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: none; }
}

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.form-grid-full { grid-column: 1 / -1; }

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

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder { color: var(--text-muted); }

select option { background: var(--bg-card); }

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-bar svg {
  width: 15px; height: 15px;
  color: var(--text-muted);
  margin-left: 10px;
  flex-shrink: 0;
}

.search-bar input {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 8px 12px;
  flex: 1;
}

/* Checkboxes */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-label:hover { color: var(--text-primary); }

.checkbox-label input[type="checkbox"] {
  width: 15px; height: 15px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn svg { width: 14px; height: 14px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #17202f;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover {
  background: #f0b45c;
  border-color: #f0b45c;
  color: #17202f;
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-bright);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: rgba(229,72,77,0.1);
  color: var(--red);
  border-color: rgba(229,72,77,0.3);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* Form actions bar */
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* Field-level help text (prefer this over post-submit flash for guidance) */
.field-help {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Grouped sections inside longer forms */
.form-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  max-width: 100%;
  background: rgba(0,0,0,0.16);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

thead tr {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Click-to-sort headers (wired up by app.js) */
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text-secondary); }
thead th .sort-ind {
  display: inline-block;
  margin-left: 5px;
  font-size: 8px;
  opacity: 0.9;
  vertical-align: middle;
}

/* Right-aligned numeric columns */
th.num, td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:nth-child(even) { background: var(--bg-stripe); }
tbody tr:nth-child(even):hover { background: var(--bg-hover); }

tbody td {
  padding: 11px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
  max-width: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

tbody td.compact,
tbody td.actions,
tbody td.date-cell,
tbody td.status-cell {
  width: 1%;
  white-space: nowrap;
  overflow-wrap: normal;
}

tbody td.nowrap { white-space: nowrap; overflow-wrap: normal; }
tbody td.wrap { white-space: normal; }

.table-wide table { min-width: 980px; }
.table-xwide table { min-width: 1180px; }
.table-compact tbody td { white-space: nowrap; overflow-wrap: normal; }
.table-compact tbody td.wrap { white-space: normal; overflow-wrap: anywhere; }

td .id-cell {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

td .monospace {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--text-primary);
  background: var(--neutral-chip-bg);
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

td .mono-hash {
  font-family: var(--font-data);
  font-size: 11.5px;
  color: var(--text-primary);
  background: var(--neutral-chip-bg);
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  display: inline-block;
  max-width: min(520px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background var(--transition);
}

td .mono-hash:hover { background: rgba(233,238,246,0.12); }

/* Empty state */
.table-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

.table-empty svg {
  width: 36px; height: 36px;
  margin: 0 auto 10px;
  display: block;
  opacity: 0.4;
}

.table-empty p { font-size: 13px; }

.table-empty .empty-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.table-empty .empty-hint {
  font-size: 12px;
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.5;
}

.table-empty .btn { margin-top: 14px; }

/* ── Skeleton shimmer (lazy-load placeholders) ── */
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(233,238,246,0.07);
  border-radius: 4px;
  height: 12px;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(238,242,250,0.09), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge svg { width: 11px; height: 11px; flex-shrink: 0; }

.badge-green  { background: rgba(63,184,104,0.14); color: var(--green); }
.badge-red    { background: rgba(229,72,77,0.14); color: var(--red); }
.badge-blue   { background: rgba(76,143,224,0.14); color: var(--blue); }
.badge-yellow { background: rgba(217,168,59,0.14); color: var(--yellow); }
.badge-purple { background: rgba(136,120,232,0.14); color: var(--purple); }
.badge-gray   { background: rgba(255,255,255,0.07); color: var(--text-muted); }
.badge-cyan   { background: rgba(69,179,196,0.12); color: var(--cyan); }
.badge-orange { background: rgba(237,122,60,0.14); color: var(--orange); }

/* Entity-type badge: neutral chip + icon; the icon shape distinguishes, not color */
.badge-type {
  background: var(--neutral-chip-bg);
  border: 1px solid var(--neutral-chip-border);
  color: var(--text-secondary);
}

/* Severity badges — the ONLY sanctioned use of the warm scale */
.badge-critical { background: rgba(229,72,77,0.14);   color: var(--sev-critical); }
.badge-high     { background: rgba(237,122,60,0.13);  color: var(--sev-high); }
.badge-medium   { background: rgba(217,168,59,0.13);  color: var(--sev-medium); }
.badge-low      { background: rgba(122,139,166,0.14); color: var(--sev-low); }
.badge-info     { background: rgba(124,135,160,0.12); color: var(--sev-info); }

/* ── Expired rows ── */
tr.row-expired td {
  opacity: 0.55;
}

/* ── Empty cell placeholder ── */
.cell-empty {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── URL cell truncation ── */
.url-cell {
  max-width: min(560px, 100%);
  display: inline-block;
  overflow-wrap: anywhere;
  white-space: normal;
  vertical-align: bottom;
}

/* ── Copy-to-clipboard active flash ── */
.mono-hash.copy-active,
.copyable.copy-active {
  background: rgba(63,184,104,0.22) !important;
  color: var(--green) !important;
  transition: background 0.15s ease, color 0.15s ease;
}

/* ── Action buttons cell ── */
.action-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* ── Section Divider ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-divider span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Auth Layout ── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-shell::before {
  content: '';
  position: absolute;
  top: -200px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(232,163,61,0.07) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
}

.auth-card-header {
  padding: 28px 32px 24px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.auth-logo {
  width: 48px; height: 48px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

.auth-logo svg { width: 26px; height: 26px; color: var(--accent); }

.auth-card-header h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-card-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.auth-card-body { padding: 28px 32px; }

.auth-card-body .form-group { margin-bottom: 16px; }

.auth-card-body .btn { width: 100%; margin-top: 6px; padding: 10px; }

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Inline Table Form (remove buttons inside table rows) ── */
.inline-form { display: inline; }
.inline-form .btn { display: inline-flex; }

/* ── Permissions Grid ── */
.perm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.tag-chip {
  --tag-color: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--tag-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--tag-color) 45%, transparent);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tag-color);
  box-shadow: 0 0 6px color-mix(in srgb, var(--tag-color) 60%, transparent);
}

.tag-remove {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  padding: 0 0 0 2px;
}

.tag-remove:hover { color: var(--red); }

.tag-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-form select { min-width: 140px; }

.tag-form .btn {
  flex-shrink: 0;
}

input[type="color"] {
  width: 42px;
  height: 34px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--bg-input);
  padding: 3px;
  cursor: pointer;
}

/* Shodan map */
.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.map-canvas {
  height: clamp(420px, 55vh, 680px);
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
}

.shodan-filter-form {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) repeat(4, minmax(150px, 1fr)) auto auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.shodan-filter-form .search-bar,
.shodan-filter-form select {
  min-width: 0;
  width: 100%;
}

.leaflet-container {
  background: var(--bg-surface);
  color: #111827;
}

.asset-row {
  cursor: pointer;
}

.asset-row:hover td {
  color: var(--text-primary);
}

.details-json {
  margin-top: 8px;
  max-height: 260px;
  overflow: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--text-secondary);
  font-size: 11px;
  white-space: pre-wrap;
}

.code-block {
  margin-top: 8px;
  max-height: 340px;
  overflow: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.ioc-detail-row td {
  background: rgba(255,255,255,0.04);
  padding: 0;
  white-space: normal;
}

.ioc-detail-panel {
  border-top: 1px solid var(--border);
  padding: 18px;
  background: linear-gradient(180deg, rgba(232,163,61,0.04), rgba(0,0,0,0.05));
}

.ioc-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}

.ioc-detail-grid section {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0,0,0,0.18);
}

.ioc-detail-grid h4 {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-primary);
}

.ioc-detail-list {
  display: grid;
  grid-template-columns: minmax(82px, auto) minmax(0, 1fr);
  gap: 8px 10px;
  margin: 0;
  font-size: 12px;
}

.ioc-detail-list dt {
  color: var(--text-muted);
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

.ioc-detail-list dd {
  margin: 0;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
  min-width: 0;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

.ioc-detail-list dt:last-of-type,
.ioc-detail-list dd:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.ioc-source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ioc-source-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
}

.ioc-source-item strong {
  font-size: 12px;
  color: var(--text-primary);
}

.ioc-source-item span,
.ioc-source-item small {
  font-size: 11px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.ioc-copy-template {
  min-height: 130px;
  margin-bottom: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  resize: vertical;
}

/* ── Responsive Sidebar Toggle ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
}

/* ── Dashboard Grid ── */
.dashboard-stats {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch;
}

.dashboard-panel {
  min-height: 100%;
}

/* ── Dashboard split layout (main column + side rail, sized independently) ── */
.dashboard-split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.dashboard-main,
.dashboard-rail {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.dashboard-rail .card-body,
.dashboard-rail .table-empty { padding-top: 16px; padding-bottom: 16px; }

@media (max-width: 1200px) {
  .dashboard-split { grid-template-columns: 1fr; }
}

.dashboard-panel-sm {
  grid-column: span 3;
}

.dashboard-panel-md {
  grid-column: span 4;
}

.dashboard-panel-lg {
  grid-column: span 6;
}

.dashboard-panel-xl {
  grid-column: span 8;
}

.dashboard-panel-full {
  grid-column: 1 / -1;
}

.dashboard-panel .table-wrap {
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.dashboard-panel table {
  min-width: 0;
}

.dashboard-panel tbody td {
  white-space: nowrap;
  overflow-wrap: normal;
}

.dashboard-panel tbody td:first-child,
.dashboard-panel tbody td.wrap {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (min-width: 1600px) {
  .dashboard-stats {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .shodan-filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shodan-filter-form .search-bar {
    grid-column: 1 / -1;
  }
}

/* ── Toolbar (search + actions) ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar .search-bar { min-width: 240px; }

/* ── Tab bar (server-rendered <a href="?tab=..."> links, no JS) ── */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  cursor: pointer;
  background: none;
  border-left: none; border-right: none; border-top: none;
  font-family: inherit;
}

.tab-item:hover { color: var(--text-primary); }

.tab-item.active {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}

/* JS-driven tab panels (IOC detail panel) share the same look */
.ioc-detail-tabpanel[hidden] { display: none; }

/* ── Filter bar (row of pre-styled .btn links/buttons) ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Pill-shaped quick-filter chips ── */
.filter-chip-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  border: 1px solid var(--border-bright);
  background: var(--bg-hover);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  font-family: inherit;
  transition: all var(--transition);
}

.filter-chip:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

.filter-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ── Simple form row (wraps .form-group children in a flex row) ── */
.form-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.form-row:last-child { margin-bottom: 0; }
.form-row .form-group { flex: 1; min-width: 160px; }
.flex-2 { flex: 2; }

/* ── Two-column card grid (charts, comparisons) ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

/* ── Popout input component (button reveals a form) ── */
.inline-details summary {
  list-style: none;
  cursor: pointer;
}
.inline-details summary::-webkit-details-marker { display: none; }

.inline-details summary::after {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--transition);
  opacity: 0.7;
}

.inline-details[open] summary::after { transform: rotate(-135deg); }

.inline-details[open] > *:not(summary) {
  margin-top: 10px;
}

.inline-details .card-body,
.inline-details > form {
  padding: 16px;
  background: var(--bg-card-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Utility ── */
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.ml-8  { margin-left: 8px; }
.p-0   { padding: 0; }
.p-16  { padding: 16px; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.text-sm    { font-size: 12px; }
.monofont   { font-family: 'Consolas', monospace; }
.w-full     { width: 100%; }
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.gap-8      { gap: 8px; }
.gap-12     { gap: 12px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-240px);
    width: 240px;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  .main-wrapper { margin-left: 0; }

  .topbar-hamburger { display: flex; }

  .content { padding: 16px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .form-grid { grid-template-columns: 1fr; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-panel-sm,
  .dashboard-panel-md,
  .dashboard-panel-lg,
  .dashboard-panel-xl,
  .dashboard-panel-full {
    grid-column: 1 / -1;
  }

  .ioc-detail-grid { grid-template-columns: 1fr; }

  .shodan-filter-form { grid-template-columns: 1fr; }

  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .stat-grid { grid-template-columns: 1fr; }
  .dashboard-stats { grid-template-columns: 1fr; }
  .auth-card-header, .auth-card-body { padding-left: 20px; padding-right: 20px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .search-bar { min-width: 0; }
}

/* ==========================================================================
   KESTREL shell additions — TLP ribbon, topbar omnisearch, collapsible rail
   ========================================================================== */

/* ── TLP classification ribbon ── */
.tlp-ribbon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(90deg, rgba(232,163,61,0.14), rgba(232,163,61,0.04) 30%, rgba(232,163,61,0.04) 70%, rgba(232,163,61,0.14));
  border-bottom: 1px solid var(--border);
  padding: 4px 16px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.tlp-ribbon .tlp-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ── Topbar omnisearch ── */
.topbar-search {
  flex: 1;
  max-width: 520px;
  min-width: 160px;
  height: 34px;
  border-radius: 8px;
}

.topbar-search input { min-width: 0; }

.topbar-search kbd {
  font-family: var(--font-data);
  font-size: 10px;
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.topbar .topbar-title { flex: 0 0 auto; }
.topbar-spacer { flex: 1; }

/* ── Sidebar collapse toggle (desktop only) ── */
.sidebar-collapse-btn {
  display: none;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
}

.sidebar-collapse-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.sidebar-collapse-btn svg {
  width: 16px; height: 16px;
  transition: transform var(--transition);
}

@media (min-width: 901px) {
  .sidebar-collapse-btn { display: inline-flex; }

  body.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

  body.sidebar-collapsed .main-wrapper { margin-left: var(--sidebar-w-rail); }

  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-w-rail);
  }

  body.sidebar-collapsed .sidebar-brand {
    padding: 18px 0;
    justify-content: center;
    gap: 0;
  }

  body.sidebar-collapsed .sidebar-brand-text { display: none; }

  /* group headers hide; icon lists always visible; hairline separators remain */
  body.sidebar-collapsed .sidebar-section-btn { display: none; }
  body.sidebar-collapsed .sidebar-group .sidebar-group-body { display: flex; }
  body.sidebar-collapsed .sidebar-group { padding: 6px 0; }

  body.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
    font-size: 0;            /* hides the raw text node */
  }

  body.sidebar-collapsed .sidebar-nav a svg {
    width: 17px; height: 17px;
  }

  /* badge collapses to a corner dot */
  body.sidebar-collapsed .sidebar-nav a .nav-badge {
    position: absolute;
    top: 6px;
    right: 14px;
    width: 7px; height: 7px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
    overflow: hidden;
  }

  body.sidebar-collapsed .sidebar-footer { padding: 12px 10px; }
  body.sidebar-collapsed .user-pill { justify-content: center; padding: 6px; gap: 0; }
  body.sidebar-collapsed .user-pill .user-info,
  body.sidebar-collapsed .user-pill > svg { display: none; }
  body.sidebar-collapsed .user-dropdown { left: 0; right: auto; min-width: 180px; }
}

/* Suppress layout transitions during initial collapse restore */
body.no-transitions .sidebar,
body.no-transitions .main-wrapper { transition: none !important; }

/* ==========================================================================
   Dashboard components — chart, confidence bars, alert feed, feed health,
   actor cards
   ========================================================================== */

/* ── Page header with actions ── */
.page-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.num { font-variant-numeric: tabular-nums; }

/* ── Ingest chart ── */
.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px 0;
}

.chart-legend .legend-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.chart-legend .legend-swatch {
  width: 9px; height: 9px;
  border-radius: 2.5px;
  flex-shrink: 0;
}

.chart-wrap {
  position: relative;
  padding: 8px 12px 12px;
}

.chart-wrap svg { display: block; }

.chart-tip {
  position: absolute;
  pointer-events: none;
  z-index: 50;
  background: var(--bg-hover);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated);
  padding: 8px 11px;
  font-size: 11.5px;
  min-width: 150px;
}

.chart-tip[hidden] { display: none; }

.chart-tip .tip-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}

.chart-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 1.5px 0;
  color: var(--text-secondary);
}

.chart-tip .tip-row b {
  margin-left: auto;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.chart-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Horizontal metric bars (confidence / top sources) ── */
.hbar-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
}

.hbar {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.hbar-label { font-weight: 600; }

.sev-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sev-label::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 2px;
  background: currentColor;
  flex-shrink: 0;
}

.sev-label.sev-critical { color: var(--sev-critical); }
.sev-label.sev-high     { color: var(--sev-high); }
.sev-label.sev-medium   { color: var(--sev-medium); }
.sev-label.sev-low      { color: var(--sev-low); }

.hbar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-input);
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  border-radius: 4px;
  min-width: 2px;
}

.hbar-val {
  text-align: right;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Alert feed (rail) ── */
.alert-feed {
  display: flex;
  flex-direction: column;
  padding: 8px 10px 10px;
}

.alert-feed-row {
  display: flex;
  gap: 11px;
  padding: 9px 8px;
  border-radius: var(--radius);
  align-items: stretch;
}

.alert-feed-row:hover { background: var(--bg-hover); }

.alert-stripe {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.alert-feed-body { flex: 1; min-width: 0; }

.alert-feed-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.alert-feed-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

/* ── Feed health list (rail) ── */
.feed-list {
  display: flex;
  flex-direction: column;
  padding: 6px 20px 12px;
}

.feed-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.feed-row:last-child { border-bottom: none; }

.feed-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.feed-dot-ok   { background: var(--green); }
.feed-dot-warn { background: var(--yellow); }
.feed-dot-err  { background: var(--red); }

.feed-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.feed-when {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.feed-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 44px;
  text-align: right;
}

.feed-status-ok   { color: var(--green); }
.feed-status-warn { color: var(--yellow); }
.feed-status-err  { color: var(--red); }

/* ── Actor cards ── */
.actor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1100px) {
  .actor-grid { grid-template-columns: 1fr; }
}

.actor-card {
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.actor-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.actor-sigil {
  width: 38px; height: 38px;
  border-radius: var(--radius-lg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  background: var(--neutral-chip-bg);
  border: 1px solid var(--neutral-chip-border);
  color: var(--text-primary);
  text-transform: uppercase;
}

.actor-title { min-width: 0; }

.actor-title h3 {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-primary);
}

.actor-aka {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actor-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.actor-fact { display: flex; flex-direction: column; }

.actor-fact-k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.actor-fact-v {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.actor-foot {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* ==========================================================================
   KPI tiles, indicator table components, length caps
   ========================================================================== */

/* ── KPI tiles (label-top, big value, foot row) ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  transition: border-color var(--transition);
}

.kpi-card:hover { border-color: var(--border-bright); }

.kpi-card-hero {
  background: linear-gradient(135deg, rgba(232,163,61,0.09), var(--bg-card) 60%);
  border-color: rgba(232,163,61,0.35);
}

.kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-value .kpi-value-dim {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
  flex-wrap: wrap;
}

.kpi-delta { font-size: 11.5px; font-weight: 600; }
.kpi-delta-up   { color: var(--green); }
.kpi-delta-bad  { color: var(--red); }
.kpi-delta-flat { color: var(--text-muted); }

.kpi-spark { flex-shrink: 0; }

/* Small severity chips inside KPI feet */
.kpi-foot .sev-label { font-size: 11px; font-weight: 600; }

/* ── Indicator type chip ── */
.type-chip {
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--neutral-chip-border);
  border-radius: 5px;
  padding: 2px 7px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── Confidence score bar ── */
.score {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.score-track {
  width: 46px;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-input);
  overflow: hidden;
  flex-shrink: 0;
}

.score-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.score b {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--text-primary);
}

/* ── Cell length caps ── */
td .cell-clip {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

@media (max-width: 1400px) {
  td .cell-clip { max-width: 190px; }
}

/* ── "+N more" footer row for capped lists ── */
.list-more {
  display: block;
  text-align: center;
  padding: 8px 0 2px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ── Global mono elements (code, .monospace outside tables) ── */
code, .monospace {
  font-family: var(--font-data);
  font-size: 12px;
}

code {
  background: var(--neutral-chip-bg);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.token-reveal {
  display: block;
  margin-top: 6px;
  font-family: var(--font-data);
  font-size: 13px;
  background: var(--bg-input);
  border: 1px dashed var(--border-bright);
  border-radius: var(--radius);
  padding: 8px 12px;
  overflow-wrap: anywhere;
  cursor: pointer;
  color: var(--text-primary);
}

/* ── Enrichment pipeline state (per-IOC) ── */
.enrich-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.enrich-state::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.enrich-running { color: var(--yellow); }
.enrich-failed  { color: var(--red); }
.enrich-done    { color: var(--green); }
.enrich-pending { color: var(--text-muted); }

.enrich-running::before {
  animation: enrichPulse 1.2s ease-in-out infinite;
}

@keyframes enrichPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .enrich-running::before { animation: none; }
}

.progress-mini {
  width: 52px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  overflow: hidden;
  flex-shrink: 0;
}

.progress-mini span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--yellow);
  transition: width 0.4s ease;
}

/* ── Pagination (shared) ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.pagination-info {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Actor profile: detection cards ── */
.detection-list {
  display: flex;
  flex-direction: column;
}

.detection-row {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.detection-row:last-child { border-bottom: none; }

.detection-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.detection-title { min-width: 0; flex: 1; }

.detection-title strong {
  font-size: 13.5px;
  color: var(--text-primary);
}

.detection-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 3px;
  max-width: 72ch;
}

.detection-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.detection-row .code-block {
  margin: 0;
  max-height: 200px;
  overflow: auto;
}

.detection-edit { margin-top: 10px; }

/* ── Layered coverage bars (observed vs covered) ── */
.hbar-track-layered { position: relative; }

.hbar-track-layered .hbar-fill-overlay {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
}
