/* ==========================================================================
   CybIntel — Tactical Editorial Monograph Design System
   Archival Paper (Light) + Carbon Slate (Dark)
   Zero generic neon/gradient AI SaaS clichés.
   ========================================================================== */

:root {
  --bg: #F6F4EF;
  --bg-well: #ECE9E1;
  --surface: #FFFFFF;
  --surface-hover: #FAF9F6;
  --ink: #13161B;
  --ink-2: #4A515C;
  --ink-3: #767E8A;
  --line: #DBD7CD;
  --line-strong: #BDB8AC;

  /* Precision Signal Palette */
  --signal: #C83E2B;          /* Active threat / Internal-only / Vermilion */
  --signal-soft: #FBECE9;
  --signal-line: #E8B5AC;

  --release: #1D6348;         /* Releasable / Published / Forest Pine */
  --release-soft: #E9F3EE;
  --release-line: #A9D1BF;

  --cobalt: #1E4B82;          /* Links / Pivots / TLP:CLEAR */
  --cobalt-soft: #EAF0F7;
  --cobalt-line: #B5C8E0;

  --amber: #A86112;           /* TLP:AMBER / Caution / Draft */
  --amber-soft: #FDF3E4;
  --amber-line: #E7C796;

  --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 2px;
  --radius: 4px;
  --shadow-subtle: 0 1px 2px rgba(19, 22, 27, 0.04);
  --shadow-drawer: -8px 0 32px rgba(19, 22, 27, 0.14);
}

[data-theme="dark"] {
  --bg: #0D1015;
  --bg-well: #12161E;
  --surface: #161B24;
  --surface-hover: #1C222D;
  --ink: #EAE7E0;
  --ink-2: #9EA6B3;
  --ink-3: #6E7684;
  --line: #262D39;
  --line-strong: #3A4354;

  --signal: #E05A47;
  --signal-soft: rgba(224, 90, 71, 0.13);
  --signal-line: rgba(224, 90, 71, 0.38);

  --release: #3AA379;
  --release-soft: rgba(58, 163, 121, 0.13);
  --release-line: rgba(58, 163, 121, 0.36);

  --cobalt: #6AA1E6;
  --cobalt-soft: rgba(106, 161, 230, 0.13);
  --cobalt-line: rgba(106, 161, 230, 0.35);

  --amber: #E5A04B;
  --amber-soft: rgba(229, 160, 75, 0.13);
  --amber-line: rgba(229, 160, 75, 0.36);

  --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-drawer: -12px 0 40px rgba(0, 0, 0, 0.55);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); }

.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: -3px;
  flex-shrink: 0;
}
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }

/* ---- Top Navigation Bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none !important;
  flex-shrink: 0;
}
.brand-link svg { height: 28px; width: auto; display: block; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  text-decoration: none !important;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-well); color: var(--ink); }
.nav-item.active {
  color: var(--ink);
  background: var(--bg-well);
  box-shadow: inset 0 -2px 0 var(--signal);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  width: 240px;
}
.search-pill input {
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  width: 100%;
  outline: none;
}
.search-pill input::placeholder { color: var(--ink-3); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-well); border-color: var(--ink-3); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-xs { padding: 2px 7px; font-size: 11px; }
.btn-primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.btn-primary:hover { opacity: 0.9; background: var(--ink); color: var(--surface); }
.btn-signal {
  background: var(--signal);
  color: #FFFFFF;
  border-color: var(--signal);
}
.btn-signal:hover { opacity: 0.92; background: var(--signal); color: #FFFFFF; }
.btn-release {
  background: var(--release);
  color: #FFFFFF;
  border-color: var(--release);
}
.btn-release:hover { opacity: 0.92; background: var(--release); color: #FFFFFF; }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--bg-well); color: var(--ink); border-color: transparent; }

/* ---- Classification & Status Stamps ---- */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-well);
  color: var(--ink-2);
}
.tlp-RED { background: #1A1111; color: #FF5C5C; border-color: #9E2626; }
.tlp-AMBER, .tlp-AMBER\+STRICT { background: #1B150E; color: #F5B041; border-color: #A86112; }
.tlp-GREEN { background: #0E1B15; color: #4FD19B; border-color: #1D6348; }
.tlp-CLEAR { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }

.badge-published { background: var(--release-soft); color: var(--release); border-color: var(--release-line); }
.badge-draft { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.badge-internal { background: var(--signal-soft); color: var(--signal); border-color: var(--signal-line); }
.badge-cobalt { background: var(--cobalt-soft); color: var(--cobalt); border-color: var(--cobalt-line); }

/* ---- Tags (Synapse Hierarchical Dot-Tags) ---- */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
}
.tag-chip .tag-ns { color: var(--ink-3); font-weight: 500; }
.tag-attr { border-left: 2.5px solid var(--signal); }
.tag-ind { border-left: 2.5px solid var(--cobalt); }
.tag-src { border-left: 2.5px solid var(--amber); }
.tag-ttp { border-left: 2.5px solid var(--ink-2); }

/* ---- Page Container & Grids ---- */
.page {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}
.page-narrow {
  max-width: 1020px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 32px;
  line-height: 1.12;
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.01em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-subtle);
}
.card-pad { padding: 18px 20px; }

/* ---- Report View Mode: Left IOC Rail + Dual Boxes ---- */
.report-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) {
  .report-layout { grid-template-columns: 1fr; }
}

.ioc-rail {
  position: sticky;
  top: 72px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: calc(100vh - 94px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ioc-rail-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-well);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ioc-rail-body {
  overflow-y: auto;
  padding: 8px 0;
}

.ioc-group { border-bottom: 1px solid var(--line); }
.ioc-group:last-child { border-bottom: none; }
.ioc-group-toggle {
  width: 100%;
  background: transparent;
  border: none;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.ioc-group-toggle:hover { background: var(--surface-hover); }
.ioc-group-count {
  font-weight: 500;
  color: var(--ink-3);
  background: var(--bg-well);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}
.ioc-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.ioc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.ioc-row:hover { background: var(--bg-well); }
.ioc-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}
.ioc-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.flag-r {
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 2px;
  background: var(--release-soft);
  color: var(--release);
  border: 1px solid var(--release-line);
}
.flag-i {
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 2px;
  background: var(--signal-soft);
  color: var(--signal);
  border: 1px solid var(--signal-line);
}
.corr-dot {
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 4px;
  border-radius: 2px;
  background: var(--cobalt-soft);
  color: var(--cobalt);
}

/* ---- Dual Narrative Boxes (Internal vs Releasable) ---- */
.intel-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}
.intel-box-internal { border-left: 4px solid var(--signal); }
.intel-box-releasable { border-left: 4px solid var(--release); }

.intel-box-bar {
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.intel-box-internal .intel-box-bar { background: var(--signal-soft); color: var(--signal); }
.intel-box-releasable .intel-box-bar { background: var(--release-soft); color: var(--release); }

.intel-box-body {
  padding: 18px 20px;
}

/* Prose / Rendered Markdown */
.prose h1, .prose h2, .prose h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  margin-top: 1.2em;
  margin-bottom: 0.45em;
  line-height: 1.25;
}
.prose h2 { font-size: 17px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.prose h3 { font-size: 15px; }
.prose p { margin: 0 0 0.85em; }
.prose ul, .prose ol { margin: 0 0 0.9em; padding-left: 20px; }
.prose code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-well);
  padding: 1px 5px;
  border-radius: 2px;
}
.prose pre {
  background: #13161B;
  color: #EAE7E0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
}
.prose pre code { background: transparent; padding: 0; color: inherit; }

/* Inline Linked IOC Pills in View Mode */
.ioc-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 0 5px;
  border-radius: 2px;
  border: 1px solid var(--cobalt-line);
  background: var(--cobalt-soft);
  color: var(--cobalt);
  cursor: pointer;
  transition: background 0.1s;
}
.ioc-pill:hover { background: var(--cobalt); color: #FFFFFF; }
.ioc-pill-rel { border-color: var(--release-line); background: var(--release-soft); color: var(--release); }
.ioc-pill-rel:hover { background: var(--release); color: #FFFFFF; }

/* ---- Forms & Inputs ---- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 2px var(--cobalt-soft);
}
.textarea {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--bg-well);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.data-table tr:hover td { background: var(--surface-hover); }

/* ---- Slide-Over IOC Pivot Drawer ---- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 16, 21, 0.45);
  z-index: 60;
  display: none;
  justify-content: flex-end;
}
.drawer-backdrop.open { display: flex; }
.drawer-panel {
  width: min(500px, 94vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-well);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

/* ---- Editorial Masthead (cybintel.com Landing) ---- */
.masthead {
  border-bottom: 2px solid var(--ink);
  padding: 36px 0 28px;
  margin-bottom: 28px;
}
.masthead-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 36px;
  align-items: end;
}
@media (max-width: 860px) {
  .masthead-grid { grid-template-columns: 1fr; }
}
.masthead h1 {
  font-family: var(--font-serif);
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.04;
  font-weight: 400;
  margin: 8px 0 14px;
  letter-spacing: -0.02em;
}
.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 28px;
}
@media (max-width: 720px) { .metric-strip { grid-template-columns: repeat(2, 1fr); } }
.metric-cell {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}
.metric-cell:last-child { border-right: none; }
.metric-num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
}
.metric-lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-top: 4px;
}

/* ---- Alerts & Flash Messages ---- */
.alert {
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
}
.alert-warn { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.alert-ok { background: var(--release-soft); border-color: var(--release-line); color: var(--release); }
.alert-err { background: var(--signal-soft); border-color: var(--signal-line); color: var(--signal); }

/* ---- Utilities ---- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 780px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.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-muted { color: var(--ink-2); }
.text-dim { color: var(--ink-3); }
.text-xs { font-size: 11.5px; }
.text-sm { font-size: 13px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
