/* ==========================================================================
   brain.css — Şirket Beyni paneli için stiller.

   Ana görsel kimlik admin.css ile aynı: aynı renk tokenları, aynı tipografi,
   aynı auth-gate görünümü. Sayfa düzeni farklı (sidebar + içerik) ve
   Cytoscape grafik konteyneri / önem rozetleri / iş kartları gibi yeni
   bileşenler eklenmiştir.
   ========================================================================== */

:root {
  --panel: rgba(12, 22, 43, 0.72);
  --panel-strong: rgba(14, 26, 50, 0.82);
  --panel-soft: rgba(15, 28, 56, 0.55);
  --line: rgba(116, 170, 255, 0.24);
  --line-strong: rgba(137, 213, 255, 0.42);
  --muted: #95abc8;
  --accent: #7cf2ff;
  --accent-2: #3a8dff;
  --accent-soft: rgba(124, 242, 255, 0.16);
  --glow: 0 0 0 1px rgba(81, 179, 255, 0.22), 0 18px 48px rgba(5, 14, 30, 0.62);
  --glow-soft: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 36px rgba(2, 8, 22, 0.45);
  --glow-strong: 0 0 0 1px rgba(124, 242, 255, 0.45), 0 0 28px rgba(124, 242, 255, 0.22);
  --button-hover-filter: brightness(1.06);
  --button-hover-border: rgba(137, 213, 255, 0.56);
  --radius-md: 12px;
  --radius-lg: 16px;

  --severity-high: #ff6b6b;
  --severity-medium: #ffba59;
  --severity-low: #7cf2ff;
  --health-good: #4ade80;
  --health-mid: #ffba59;
  --health-bad: #ff6b6b;
}

* { box-sizing: border-box; }

button,
input,
select,
textarea,
summary,
optgroup,
option {
  font-family: inherit;
}

html {
  scrollbar-color: rgba(124, 242, 255, 0.32) transparent;
  scrollbar-width: thin;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #eaf3ff;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background-color: #060c18;
  background-image:
    radial-gradient(1100px 620px at 8% 12%, rgba(52, 236, 255, 0.10) 0%, transparent 60%),
    radial-gradient(900px 540px at 92% 8%, rgba(111, 121, 255, 0.10) 0%, transparent 60%),
    radial-gradient(1200px 700px at 50% 110%, rgba(43, 125, 255, 0.13) 0%, transparent 65%),
    linear-gradient(160deg, #040816 0%, #08101d 42%, #0a1530 100%);
  background-attachment: fixed;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
body::before {
  width: 520px; height: 520px; left: -180px; top: 14%;
  background: radial-gradient(circle, rgba(52, 236, 255, 0.45) 0%, rgba(52, 236, 255, 0.04) 65%);
  opacity: 0.32;
}
body::after {
  width: 460px; height: 460px; right: -160px; bottom: 6%;
  background: radial-gradient(circle, rgba(111, 121, 255, 0.55) 0%, rgba(111, 121, 255, 0.05) 68%);
  opacity: 0.34;
}

::selection { background: rgba(124, 242, 255, 0.32); color: #eaf3ff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(124, 242, 255, 0.28), rgba(58, 141, 255, 0.32));
  border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}

/* ---------- Auth gate (mirrors admin) ---------- */
.auth-gate {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: 1rem; z-index: 60; overflow: hidden;
  background:
    radial-gradient(circle at 15% 12%, rgba(52, 236, 255, 0.2) 0%, transparent 36%),
    radial-gradient(circle at 85% 84%, rgba(43, 125, 255, 0.28) 0%, transparent 34%),
    linear-gradient(160deg, #040816 0%, #08101d 42%, #0a1530 100%);
}
.auth-card {
  position: relative; z-index: 1;
  width: min(92vw, 420px);
  border: 1px solid var(--line);
  border-radius: 16px; padding: 1.1rem;
  background: var(--panel); backdrop-filter: blur(18px);
  box-shadow: var(--glow); text-align: center;
}
.brand-label {
  margin: 0; font-size: 0.74rem; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.auth-card h2 { margin: 0.28rem 0 0.5rem; font-weight: 700; }
.auth-desc { margin: 0 0 0.85rem; color: #c4daf5; font-size: 0.92rem; }
.auth-status { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.82rem; }
#google-login-btn { display: inline-flex; justify-content: center; }

.background-shape { display: none; }

/* ---------- Shell + topbar ---------- */
.brain-shell.locked { display: none; }
.brain-shell {
  padding: 1.1rem 1.25rem 1.4rem;
  position: relative; z-index: 1;
  max-width: 1640px; margin: 0 auto;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(20, 38, 70, 0.55) 0%, rgba(10, 20, 38, 0.45) 100%);
  backdrop-filter: blur(14px);
  box-shadow: var(--glow-soft);
  margin-bottom: 1rem;
}
.topbar h1 {
  margin: 0; font-size: 1.18rem;
  background: linear-gradient(135deg, #d2f1ff 0%, #7cf2ff 50%, #6ba7ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#brain-who { display: block; margin-top: 0.3rem; color: #b3c7e5; font-size: 0.82rem; }
.top-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.topbar-status {
  margin: 0; padding: 0; color: #97adca; font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 28rem;
}
.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem; font-weight: 500;
  color: #eaf3ff;
  background: rgba(16, 31, 57, 0.92);
  border: 1px solid rgba(116, 170, 255, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  text-decoration: none;
}
.btn:not(:disabled):hover {
  filter: var(--button-hover-filter);
  border-color: var(--button-hover-border);
}
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn.primary {
  background: linear-gradient(135deg, #84f7ff 0%, #1dd8ff 45%, #1fa8ff 100%);
  color: #041225;
  border-color: rgba(124, 242, 255, 0.6);
  box-shadow: 0 8px 22px rgba(31, 168, 255, 0.35);
  font-weight: 600;
}
.btn.danger {
  border-color: rgba(255, 107, 107, 0.5);
  color: #ffd3d3;
}
/* Filled red — used for "Sil" (per row) and "Seçilenleri Sil". */
.btn.btn-danger {
  background: linear-gradient(135deg, #ff8888 0%, #ff5252 50%, #d63838 100%);
  color: #1a0606;
  border-color: rgba(255, 90, 90, 0.7);
  box-shadow: 0 6px 18px rgba(214, 56, 56, 0.32);
  font-weight: 600;
}
.btn.btn-danger:disabled {
  background: rgba(80, 30, 30, 0.55);
  color: #c79292;
  box-shadow: none;
  opacity: 0.85;
}
/* Outlined red — used for "Tümünü Sil" (rare, intentionally separated
   from the per-row delete style so accidental clicks are less likely). */
.btn.btn-danger-outline {
  background: transparent;
  color: #ff9b9b;
  border-color: rgba(255, 107, 107, 0.55);
}
.btn.btn-danger-outline:not(:disabled):hover {
  background: rgba(214, 56, 56, 0.18);
  border-color: rgba(255, 90, 90, 0.85);
}

/* Inline link-style button — used in the topic detail modal to expand
   the truncated summary into the full document_summary text. Looks like
   a hyperlink, behaves like a button. */
.btn.btn-link {
  background: transparent;
  border: none;
  color: #1fa8ff;
  padding: 0.15rem 0.25rem;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}
.btn.btn-link:hover { color: #66c5ff; }
.btn.btn-link:disabled { color: rgba(159, 175, 200, 0.6); cursor: progress; }

/* Topic detail modal — full-summary expansion + subscore/reason styling.
   These classes are written by showTopicDetail() in brain.js. */
.topic-summary-block {
  margin: 0 0 0.85rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.topic-summary-text {
  white-space: pre-wrap;
  line-height: 1.55;
  color: #d4dcf0;
}
.topic-summary-text-full {
  max-height: 45vh;
  overflow-y: auto;
  padding-right: 0.5rem;
  border-left: 2px solid rgba(120, 160, 220, 0.35);
  padding-left: 0.75rem;
}
.topic-summary-doc-head {
  font-weight: 600;
  color: #cfe6ff;
  margin: 0.6rem 0 0.25rem 0;
}
.topic-summary-doc-head:first-child { margin-top: 0; }
.topic-summary-doc-body {
  color: #c4cfe2;
  margin-bottom: 0.5rem;
}
.muted { color: rgba(159, 175, 200, 0.7); font-size: 0.85em; }

.topic-subscores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  margin: 0.4rem 0;
}
.topic-subscore-label {
  color: rgba(190, 205, 230, 0.85);
  font-style: italic;
}
.topic-subscore-hint {
  color: rgba(159, 175, 200, 0.75);
  font-size: 0.85em;
}

.health-reasons { margin: 0.25rem 0 0.75rem 0; padding-left: 1.25rem; }
.health-reasons li { margin-bottom: 0.2rem; line-height: 1.45; }
.reason-scope {
  font-size: 0.82em;
  color: rgba(159, 175, 200, 0.85);
  margin-left: 0.25rem;
}
.reason-value {
  font-size: 0.85em;
  color: rgba(190, 205, 230, 0.85);
  margin-left: 0.35rem;
}
.reason-delta-bad   { color: #ff8a8a; margin-left: 0.35rem; font-weight: 600; }
.reason-delta-good  { color: #6ee7a7; margin-left: 0.35rem; font-weight: 600; }
.reason-delta-neutral { color: rgba(159, 175, 200, 0.85); margin-left: 0.35rem; }

.btn.success {
  border-color: rgba(74, 222, 128, 0.55);
  color: #c8ffe1;
}
.btn.chat-link-btn {
  background: linear-gradient(135deg, #c6d7ff 0%, #94b7ff 45%, #779fff 100%);
  color: #041225; border-color: rgba(124, 159, 255, 0.6);
  box-shadow: 0 8px 22px rgba(87, 132, 255, 0.35); font-weight: 600;
}
.refresh-btn-icon { font-size: 1rem; line-height: 1; }

/* ---------- Layout: sidebar + content ---------- */
.brain-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  align-items: flex-start;
}
@media (max-width: 960px) {
  .brain-layout { grid-template-columns: 1fr; }
}

.brain-sidebar {
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--glow-soft);
  position: sticky; top: 0.5rem;
}
.brain-nav-btn {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #b7d5ff;
  font-size: 0.92rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.brain-nav-btn:hover {
  background: rgba(20, 38, 70, 0.55);
  border-color: var(--line);
}
.brain-nav-btn.active {
  background: linear-gradient(135deg, rgba(124, 242, 255, 0.18) 0%, rgba(58, 141, 255, 0.18) 100%);
  border-color: var(--line-strong);
  color: #eaf3ff;
  box-shadow: 0 0 0 1px rgba(124, 242, 255, 0.18) inset;
}
.brain-nav-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: rgba(20, 38, 70, 0.6);
  font-size: 0.95rem;
}
.brain-nav-count {
  margin-left: auto;
  min-width: 1.5rem; padding: 0 0.45rem;
  font-size: 0.75rem; line-height: 1.4rem;
  text-align: center; border-radius: 999px;
  background: rgba(124, 242, 255, 0.18);
  color: #cfeaff;
  display: none;
}
.brain-nav-count.visible { display: inline-block; }

/* ---------- Panels ---------- */
.brain-content { min-width: 0; }
.brain-panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  backdrop-filter: blur(14px);
  padding: 1rem 1.1rem 1.2rem;
  box-shadow: var(--glow-soft);
}
.brain-panel.active { display: block; }
.panel-head {
  display: flex; flex-wrap: wrap; gap: 0.65rem;
  align-items: center; justify-content: space-between;
  margin-bottom: 0.85rem;
}
.panel-head h2 {
  margin: 0; font-size: 1.1rem; font-weight: 600;
  color: #eaf3ff;
}
.panel-head-actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
}

/* ---------- Form controls ---------- */
.brain-select,
.brain-input {
  background: rgba(8, 16, 31, 0.88);
  border: 1px solid rgba(116, 170, 255, 0.28);
  border-radius: 8px;
  color: #eaf3ff;
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  min-width: 140px;
}
.brain-input { min-width: 80px; max-width: 110px; }
.brain-checkbox {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.85rem; color: #cfeaff;
}

/* ---------- Cards (overview KPIs) ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.card {
  border: 1px solid rgba(116, 170, 255, 0.2);
  border-radius: 10px; padding: 0.75rem 0.85rem;
  background: rgba(12, 24, 48, 0.78);
}
.card .label {
  margin: 0; font-size: 0.78rem; color: var(--muted);
  letter-spacing: 0.04em;
}
.card .value {
  margin: 0.3rem 0 0; font-size: 1.4rem; font-weight: 700;
  color: #eaf3ff;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
}
.overview-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  padding: 0.85rem 0.95rem;
}
.overview-block h3 {
  margin: 0 0 0.5rem; font-size: 0.95rem; color: #cfeaff;
}
.bullet-list { list-style: disc; padding-left: 1.2rem; margin: 0; color: #d6e7ff; font-size: 0.88rem; line-height: 1.5; }
.bullet-list li { margin-bottom: 0.2rem; }
.severity-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.severity-list li {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: rgba(8, 16, 31, 0.55);
  border: 1px solid rgba(116, 170, 255, 0.18);
  font-size: 0.85rem;
}
.severity-list .item-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tables ---------- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(8, 14, 28, 0.55);
}
.table-scroll-x { overflow-x: auto; }
.brain-panel table {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
}
.brain-panel th,
.brain-panel td {
  border-bottom: 1px solid rgba(116, 170, 255, 0.18);
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  text-align: left;
  vertical-align: middle;
}
.brain-panel th {
  color: #b7d5ff;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(12, 24, 48, 0.55);
  position: sticky; top: 0;
}
.brain-panel tbody tr:hover { background: rgba(20, 38, 70, 0.45); }

.row-actions { display: flex; flex-wrap: nowrap; gap: 0.35rem; }
.row-actions .btn {
  padding: 0.28rem 0.55rem; font-size: 0.78rem;
}

/* Small button variant — used inline next to topic names in the
   pivoted (one-row-per-document) topics table. */
.btn.btn-sm {
  padding: 0.22rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 500;
  border-radius: 8px;
}

/* ---------- Pivoted topics-by-document table ---------- */

/* Konu cell: scrollable list of editable topic names. Each <li> holds
   the input + Kaydet/Detay/Sil. We cap height so a doc with 20 topics
   doesn't push the row to 600px tall — 7-8 entries fit before the
   internal scrollbar kicks in. */
.topic-konu-cell {
  vertical-align: top;
  min-width: 22rem;
  max-width: 32rem;
  padding: 0.4rem 0.6rem;
}
.konu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 14rem;
  overflow-y: auto;
}
.konu-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.18rem 0.25rem 0.18rem 0.05rem;
  border-radius: 7px;
}
.konu-item:hover { background: rgba(20, 38, 70, 0.45); }
.konu-name-input {
  flex: 1 1 auto;
  min-width: 0;            /* allow shrink inside flex */
  padding: 0.32rem 0.55rem;
  font-size: 0.86rem;
  color: #eaf3ff;
  background: rgba(8, 18, 38, 0.65);
  border: 1px solid rgba(116, 170, 255, 0.22);
  border-radius: 7px;
  font-family: inherit;
}
.konu-name-input:focus {
  outline: none;
  border-color: rgba(124, 242, 255, 0.55);
  background: rgba(8, 18, 38, 0.85);
}
.konu-item-buttons {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  flex-shrink: 0;
}

/* Add-row sits at the bottom of every .konu-list. It mirrors a
   .konu-item shell so it lines up with the editable rows above it,
   but its sole content is a full-width "+" button. After a
   successful add, the list re-renders with the new <li> ABOVE this
   row so the "+" naturally floats back to the bottom. */
.konu-add-item {
  justify-content: stretch;
}
.konu-add-item:hover { background: transparent; }
.konu-add-item .js-topic-add {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: calc(0.32rem * 2 + 0.86rem * 1.4); /* match input height */
  padding: 0.18rem 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1;
  color: #cfeaff;
  background: rgba(124, 242, 255, 0.08);
  border: 1px dashed rgba(124, 242, 255, 0.35);
  border-radius: 7px;
  cursor: pointer;
}
.konu-add-item .js-topic-add:hover {
  background: rgba(124, 242, 255, 0.16);
  border-style: solid;
  border-color: rgba(124, 242, 255, 0.6);
  color: #eaf6ff;
}
.konu-add-item .js-topic-add:focus-visible {
  outline: 2px solid rgba(124, 242, 255, 0.7);
  outline-offset: 1px;
}

/* The single file_id cell — fixed-width-ish, monospace so long
   uploaded ids stay readable without dominating the row. The Detay
   button sits inline and can wrap to the next line on narrow viewports. */
.topic-doc-cell {
  vertical-align: middle;
  max-width: 22rem;
}
.topic-doc-cell .topic-doc-id {
  display: inline-block;
  font-family: var(--font-mono, ui-monospace, "SFMono-Regular", "Menlo", monospace);
  font-size: 0.78rem;
  color: #cfeaff;
  margin-right: 0.45rem;
  word-break: break-all;
  vertical-align: middle;
}
.topic-doc-cell .btn { vertical-align: middle; }

/* ---------- Topics toolbar (bulk-select actions) ---------- */
.topics-toolbar {
  display: flex; align-items: center; gap: 0.55rem;
  margin: 0.4rem 0 0.55rem;
  padding: 0.45rem 0.65rem;
  background: rgba(14, 26, 50, 0.55);
  border: 1px solid rgba(116, 170, 255, 0.18);
  border-radius: 10px;
  flex-wrap: wrap;
}
.topics-toolbar-info {
  color: var(--muted);
  font-size: 0.82rem;
  margin-right: auto;
}

/* Tight checkbox column — both header and cells. */
.brain-panel th.col-select,
.brain-panel td.col-select {
  width: 32px;
  padding-left: 0.55rem;
  padding-right: 0.25rem;
  text-align: center;
}
.brain-panel td.col-select input[type="checkbox"],
.brain-panel th.col-select input[type="checkbox"] {
  cursor: pointer;
  accent-color: #1fa8ff;
}

/* ---------- Severity / health badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-sev-high {
  background: rgba(255, 107, 107, 0.18);
  color: #ff9b9b; border-color: rgba(255, 107, 107, 0.45);
}
.badge-sev-medium {
  background: rgba(255, 186, 89, 0.18);
  color: #ffd089; border-color: rgba(255, 186, 89, 0.45);
}
.badge-sev-low {
  background: rgba(124, 242, 255, 0.16);
  color: #b8f5ff; border-color: rgba(124, 242, 255, 0.4);
}
.badge-status-open  { background: rgba(255, 186, 89, 0.16); color: #ffd089; border-color: rgba(255, 186, 89, 0.4); }
.badge-status-drafted { background: rgba(124, 242, 255, 0.16); color: #b8f5ff; border-color: rgba(124, 242, 255, 0.4); }
.badge-status-approved { background: rgba(74, 222, 128, 0.18); color: #b9fbcd; border-color: rgba(74, 222, 128, 0.45); }
.badge-status-resolved { background: rgba(74, 222, 128, 0.14); color: #a5f0bb; border-color: rgba(74, 222, 128, 0.35); }
.badge-status-rejected { background: rgba(255, 107, 107, 0.14); color: #ffb6b6; border-color: rgba(255, 107, 107, 0.4); }
.badge-status-published { background: rgba(58, 141, 255, 0.18); color: #cce0ff; border-color: rgba(58, 141, 255, 0.45); }
.badge-status-default { background: rgba(116, 170, 255, 0.14); color: #cfeaff; border-color: rgba(116, 170, 255, 0.32); }

.health-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; font-weight: 600;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  min-width: 3.5rem; justify-content: center;
}
.health-bar {
  position: relative;
  width: 90px; height: 6px;
  background: rgba(116, 170, 255, 0.12);
  border-radius: 4px; overflow: hidden;
}
.health-bar > span {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 4px;
}
.health-good { background: rgba(74, 222, 128, 0.2); color: #b9fbcd; border-color: rgba(74, 222, 128, 0.5); }
.health-good > span { background: linear-gradient(90deg, #4ade80, #2dd4bf); }
.health-mid  { background: rgba(255, 186, 89, 0.2); color: #ffd089; border-color: rgba(255, 186, 89, 0.5); }
.health-mid  > span { background: linear-gradient(90deg, #fbbf24, #fb923c); }
.health-bad  { background: rgba(255, 107, 107, 0.2); color: #ff9b9b; border-color: rgba(255, 107, 107, 0.5); }
.health-bad  > span { background: linear-gradient(90deg, #ef4444, #f97316); }
/* "Veri yok" — null score, surfaced when there's no usage signal AND no
   structural problems yet. Should look distinct from a low score so admins
   don't confuse "we have no data" with "the topic is broken." */
.health-neutral { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.35); }
.health-cell { display: flex; flex-direction: column; gap: 0.25rem; min-width: 110px; }

/* ---------- Topic type badges ---------- */
.badge.type-knowledge { background: rgba(99, 179, 237, 0.16); color: #a6d4ff; border-color: rgba(99, 179, 237, 0.35); }
.badge.type-policy    { background: rgba(252, 165, 165, 0.16); color: #fcc4c4; border-color: rgba(252, 165, 165, 0.35); }
.badge.type-process   { background: rgba(167, 139, 250, 0.16); color: #d8caff; border-color: rgba(167, 139, 250, 0.35); }
.badge.type-metric    { background: rgba(45, 212, 191, 0.16); color: #b2f0e6; border-color: rgba(45, 212, 191, 0.35); }
.badge.type-product   { background: rgba(251, 191, 36, 0.16); color: #ffe09a; border-color: rgba(251, 191, 36, 0.35); }
.badge.type-contract  { background: rgba(244, 114, 182, 0.16); color: #ffc6e1; border-color: rgba(244, 114, 182, 0.35); }
.badge.type-report    { background: rgba(125, 211, 252, 0.16); color: #c4e9ff; border-color: rgba(125, 211, 252, 0.35); }
.badge.type-unknown   { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.3); }

/* ---------- Insights list ---------- */
.insights-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-direction: column; gap: 0.65rem; }
.insight-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  background: rgba(12, 24, 48, 0.6);
}
.insight-item header {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  align-items: center; justify-content: space-between;
  margin-bottom: 0.4rem;
}
.insight-item h3 { margin: 0; font-size: 1rem; }
.insight-meta {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  font-size: 0.78rem; color: var(--muted);
}
.insight-departments {
  display: inline-flex; flex-wrap: wrap; gap: 0.25rem;
}
.dept-chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.72rem;
  border-radius: 999px;
  background: rgba(58, 141, 255, 0.16);
  border: 1px solid rgba(58, 141, 255, 0.4);
  color: #cce0ff;
}
.insight-summary { margin: 0.3rem 0; font-size: 0.92rem; color: #d6e7ff; line-height: 1.45; }
.insight-rec {
  margin-top: 0.4rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: rgba(124, 242, 255, 0.08);
  border-left: 3px solid var(--accent);
  font-size: 0.85rem;
  color: #d6e7ff;
}

/* ---------- Knowledge map ---------- */
.cy-graph {
  position: relative;
  width: 100%;
  height: 620px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 30% 30%, rgba(124, 242, 255, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(58, 141, 255, 0.06) 0%, transparent 50%),
    rgba(6, 12, 26, 0.7);
  overflow: hidden;
}
.map-legend {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  margin-bottom: 0.55rem;
}
.legend-item {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.legend-item::before {
  content: ""; width: 10px; height: 10px; border-radius: 999px; display: inline-block;
}
.legend-department { background: rgba(124, 242, 255, 0.14); border-color: rgba(124, 242, 255, 0.45); color: #cfeaff; }
.legend-department::before { background: #7cf2ff; }
.legend-topic      { background: rgba(167, 139, 250, 0.14); border-color: rgba(167, 139, 250, 0.45); color: #ddd1ff; }
.legend-topic::before { background: #a78bfa; }
.legend-document   { background: rgba(96, 165, 250, 0.14); border-color: rgba(96, 165, 250, 0.45); color: #d3e3ff; }
.legend-document::before { background: #60a5fa; }
.legend-gap        { background: rgba(255, 186, 89, 0.16); border-color: rgba(255, 186, 89, 0.5); color: #ffd089; }
.legend-gap::before { background: #fbbf24; }
.legend-conflict   { background: rgba(255, 107, 107, 0.18); border-color: rgba(255, 107, 107, 0.5); color: #ff9b9b; }
.legend-conflict::before { background: #ef4444; }
.legend-insight    { background: rgba(74, 222, 128, 0.18); border-color: rgba(74, 222, 128, 0.5); color: #b9fbcd; }
.legend-insight::before { background: #4ade80; }
.legend-suggested  { background: rgba(56, 189, 248, 0.16); border-color: rgba(56, 189, 248, 0.5); color: #c5ecff; }
.legend-suggested::before { background: #38bdf8; }
.legend-owner      { background: rgba(244, 114, 182, 0.16); border-color: rgba(244, 114, 182, 0.5); color: #ffd0e6; }
.legend-owner::before { background: #f472b6; }

.cy-detail {
  position: absolute;
  right: 1.6rem; top: 5.7rem;
  width: min(360px, 38vw);
  max-height: 540px; overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(8, 16, 32, 0.95);
  box-shadow: var(--glow);
  padding: 0.85rem 0.95rem;
  z-index: 4;
}
.cy-detail.hidden { display: none; }
.cy-detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.4rem;
}
.cy-detail h3 {
  margin: 0; font-size: 1rem; flex: 1; word-break: break-word;
}
.cy-detail-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; line-height: 1;
}
.cy-detail-meta {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.55rem;
  background: rgba(8, 16, 31, 0.7);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #b7d5ff;
}

/* ---------- Jobs ---------- */
.jobs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}
.jobs-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  padding: 0.85rem 1rem;
}
.jobs-card h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.jobs-card .muted { font-size: 0.85rem; }
.jobs-card-form {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin-top: 0.65rem;
}
.jobs-history-title { margin: 1rem 0 0.5rem; font-size: 0.95rem; color: #cfeaff; }

.job-status-running   { color: #ffd089; }
.job-status-completed { color: #b9fbcd; }
.job-status-failed    { color: #ff9b9b; }
.job-status-queued    { color: #cce0ff; }

/* ---------- Modal / drawer ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(6, 12, 24, 0.62); backdrop-filter: blur(6px);
  padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal-card {
  width: min(94vw, 760px);
  max-height: 86vh; overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 1rem 1.15rem 1.2rem;
  background: rgba(13, 24, 46, 0.97);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 0.6rem;
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.4rem; cursor: pointer; line-height: 1;
}
.modal-body {
  font-size: 0.9rem; color: #d6e7ff; line-height: 1.55;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.modal-body h4 { margin: 0.65rem 0 0.25rem; font-size: 0.92rem; color: #b7d5ff; }
.modal-body ul { margin: 0; padding-left: 1.15rem; }
.modal-body pre {
  white-space: pre-wrap; word-break: break-word;
  background: rgba(8, 16, 31, 0.7);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 0.82rem;
  max-height: 360px; overflow-y: auto;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  margin-top: 0.65rem; flex-wrap: wrap;
}

/* ---------- Misc ---------- */
.empty-row td { color: var(--muted); text-align: center; padding: 1.2rem; font-size: 0.88rem; }
.brain-link-btn {
  background: linear-gradient(135deg, rgba(124, 242, 255, 0.22) 0%, rgba(58, 141, 255, 0.22) 100%) !important;
  border-color: rgba(124, 242, 255, 0.55) !important;
  color: #eaf3ff !important;
  font-weight: 600;
}
