:root {
  /* Light, enterprise-friendly palette */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface2: #fbfcfe;
  --text: #111827;
  --muted: #5b6b7b;
  --border: rgba(17, 24, 39, 0.10);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);

  /* Accent (Microsoft-ish blue) */
  --accent: #0078d4;
  --accent-weak: rgba(0, 120, 212, 0.12);

  /* Priority colors */
  --prio-high: #d13438;
  --prio-med: #ca5010;
  --prio-low: #107c10;
  --prio-high-bg: rgba(209, 52, 56, 0.10);
  --prio-med-bg: rgba(202, 80, 16, 0.10);
  --prio-low-bg: rgba(16, 124, 16, 0.10);

  /* Master tags */
  --tag-security: #6d28d9;
  --tag-security-bg: rgba(109, 40, 217, 0.10);
  --tag-network: #0f766e;
  --tag-network-bg: rgba(15, 118, 110, 0.10);

  /* JS updates this to the current header height */
  --topbar-height: 0px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Index page: keep top area visible, scroll only rows */
.page-index {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page-index .topbar {
  position: relative;
  top: auto;
}

.page-index .topbar .wrap {
  padding: 10px 18px;
}

.page-index .brand-title { font-size: 16px; }
.page-index .brand-sub { font-size: 12px; }
.page-index .logo { width: 38px; height: 38px; border-radius: 11px; font-size: 14px; }

.page-index .filters { margin-top: 8px; }
.page-index .filter-form { gap: 8px; }
.page-index .input { padding: 10px 12px; }
.page-index .select { padding: 8px 10px; }
.page-index .btn { padding: 8px 10px; }
.page-index .hint { font-size: 12px; }

.page-index .wrap.top-area {
  padding-top: 10px;
  padding-bottom: 6px;
}

.page-index .top-area {
  flex: 0 0 auto;
  padding-bottom: 0;
}

.page-index .rows-area {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-top: 10px;
}

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: 6px 0 8px;
}

.table-count {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
}

.wrap {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 18px 24px;
}

.topbar {
  position: sticky;
  background: rgba(246, 247, 251, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0078d4, #2b88d8);
  color: #ffffff;
  display: grid; place-items: center;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 20px rgba(0, 120, 212, 0.25);
}
.brand-title { font-weight: 800; font-size: 18px; }
.brand-sub { color: var(--muted); font-size: 13px; }

.filters { margin-top: 14px; }
.filter-form { display: grid; gap: 10px; }

.input {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.input:focus { border-color: rgba(0, 120, 212, 0.55); box-shadow: 0 0 0 4px rgba(0, 120, 212, 0.12); }

.select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Keep the search input + button on one line to avoid janky reloads while typing. */
.page-index .search-row { flex-wrap: nowrap; }
.page-index .search-row .search-wrap { position: relative; flex: 1 1 auto; min-width: 260px; }
.page-index .search-row .search-wrap .input { width: 100%; }
.page-index .search-row .btn { white-space: nowrap; }

.suggest-box {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: 320px;
  z-index: 60;
}

.suggest-item {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.suggest-item:hover {
  background: var(--surface2);
}

.suggest-id {
  flex: 0 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: var(--muted);
  padding-top: 1px;
}

.suggest-body {
  flex: 1 1 auto;
  min-width: 0;
}

.suggest-title {
  font-size: 13px;
  line-height: 1.25;
  color: var(--text);
}

.suggest-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.btn {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 120, 212, 0.35);
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
}
.btn:hover { filter: brightness(0.96); }
.btn:active { transform: translateY(0.5px); }
.btn-ghost {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface2); }

.topic-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.pill input { accent-color: var(--accent); }

.pill-dual {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  border-radius: 14px;
  padding: 8px 10px;
}
.pill-title { font-weight: 650; line-height: 1.1; }
.pill-dual-row { display: flex; gap: 10px; align-items: center; }
.subpill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.subpill input { accent-color: var(--accent); }

.pill-count {
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.03);
  padding: 2px 6px;
  border-radius: 999px;
}

.hint { color: var(--muted); font-size: 12px; }
.hint-sep { opacity: 0.7; }

.hint-mode {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.03);
  color: var(--muted);
}

.hint-mode-vector {
  border-color: rgba(0, 120, 212, 0.35);
  background: rgba(0, 120, 212, 0.08);
  color: #0b3a66;
}

.td-snippet {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  background: rgba(0, 120, 212, 0.06);
  border: 1px solid rgba(0, 120, 212, 0.14);
  padding: 6px 8px;
  border-radius: 10px;
}

.similar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.similar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.similar-more {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid rgba(0, 120, 212, 0.20);
  background: rgba(0, 120, 212, 0.06);
  padding: 4px 10px;
  border-radius: 999px;
}

.similar-more:hover { filter: brightness(0.98); }

.similar-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 12px;
}

.similar-item:hover {
  background: var(--surface2);
}

.similar-title {
  font-weight: 650;
}

.similar-caption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.hint-search { color: var(--text); font-weight: 650; }
.hint-vector { color: var(--muted); font-weight: 650; }

.sync {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.sync-label { font-weight: 650; }
.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.03);
  color: var(--muted);
}
.sync-chip.warn {
  background: rgba(202, 80, 16, 0.08);
  border-color: rgba(202, 80, 16, 0.22);
  color: rgba(202, 80, 16, 0.95);
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  align-items: center;
  margin: 0;
  flex-wrap: wrap;
}

.legend-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 6px 0 10px;
}

.legend-bar .table-count {
  flex: 0 0 auto;
}
.dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; margin-right: 6px; }
.dot-high { background: var(--prio-high); }
.dot-med { background: var(--prio-med); }
.dot-low { background: var(--prio-low); }

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
  margin-right: 6px;
  border: 1px solid var(--border);
}
.sw-major { background: rgba(209, 52, 56, 0.10); border-color: rgba(209, 52, 56, 0.25); }
.sw-security { background: var(--tag-security-bg); border-color: rgba(109, 40, 217, 0.28); }
.sw-network { background: var(--tag-network-bg); border-color: rgba(15, 118, 110, 0.28); }

.legend-note {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: help;
}

.legend-ai {
  color: rgba(17, 24, 39, 0.72);
  font-weight: 650;
  cursor: help;
  white-space: nowrap;
}

.list { display: grid; gap: 10px; }
.master-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.master-pills-inline { align-items: center; }

.master-head { display: none; }
.item {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.item:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 120, 212, 0.25);
  box-shadow: var(--shadow);
  background: var(--surface2);
}

.pill-master {
  border-radius: 14px;
  padding: 8px 10px;
  font-weight: 900 !important;
  font-size: 15px;
  border-width: 2px;
}
.master-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 900 !important;
}
.master-title { font-weight: 900 !important; letter-spacing: 0.1px; }

.master-ai {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.3px;
  border: 1px solid currentColor;
  opacity: 0.95;
}
.master-note {
  font-size: 12px;
  color: currentColor;
  opacity: 0.9;
  font-weight: 850;
}
.pill-master-security {
  background: var(--surface);
  border-color: var(--tag-security);
}
.pill-master-security { color: var(--tag-security); }
.pill-master-security .pill-count { color: rgba(109, 40, 217, 0.95); }
.pill-master-security input { accent-color: var(--tag-security); }
.pill-master-network {
  background: var(--surface);
  border-color: var(--tag-network);
}
.pill-master-network { color: var(--tag-network); }
.pill-master-network .pill-count { color: rgba(15, 118, 110, 0.95); }
.pill-master-network input { accent-color: var(--tag-network); }

/* Sortable header links */
.th-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.th-link:hover { text-decoration: underline; text-decoration-style: dotted; }
.th-sort { color: rgba(17, 24, 39, 0.55); font-size: 12px; }

.item-imp-0 { box-shadow: inset 4px 0 0 rgba(16, 124, 16, 0.65), 0 1px 2px rgba(16, 24, 40, 0.04); }
.item-imp-1 { box-shadow: inset 4px 0 0 rgba(16, 124, 16, 0.65), 0 1px 2px rgba(16, 24, 40, 0.04); }
.item-imp-2 { box-shadow: inset 4px 0 0 rgba(202, 80, 16, 0.70), 0 1px 2px rgba(16, 24, 40, 0.04); }
.item-imp-3 { box-shadow: inset 4px 0 0 rgba(202, 80, 16, 0.70), 0 1px 2px rgba(16, 24, 40, 0.04); }
.item-imp-4 { box-shadow: inset 4px 0 0 rgba(209, 52, 56, 0.75), 0 1px 2px rgba(16, 24, 40, 0.04); }
.item-imp-5 { box-shadow: inset 4px 0 0 rgba(209, 52, 56, 0.75), 0 1px 2px rgba(16, 24, 40, 0.04); }

.item-top { display: flex; justify-content: space-between; gap: 10px; }
.item-title { font-weight: 800; line-height: 1.25; }

.badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.03);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
}
.badge-major { color: #7a1f1f; background: rgba(209, 52, 56, 0.10); border-color: rgba(209, 52, 56, 0.25); }
.badge-sev { color: #6b3d11; background: rgba(202, 80, 16, 0.10); border-color: rgba(202, 80, 16, 0.25); }

.item-summary {
  margin-top: 8px;
  color: rgba(17, 24, 39, 0.90);
  font-size: 14px;
}

.item-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.warn { color: var(--prio-med); }

.card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  margin: 12px 0;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.back {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  margin-right: 10px;
}

.kvs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.k { color: var(--muted); font-size: 12px; }
.v { font-size: 13px; }

.summary-big { font-size: 16px; line-height: 1.45; }

.details { display: grid; gap: 8px; }
.detail-row { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.detail-k { color: var(--muted); font-size: 12px; }
.detail-v { font-size: 13px; overflow-wrap: anywhere; }

.body {
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
}
.body a { color: var(--accent); }
.body p, .body li { color: rgba(17, 24, 39, 0.92); }
.body p { margin: 0.55rem 0; }
.body ul, .body ol { padding-left: 22px; margin: 0.55rem 0; }
.body li { margin: 0.25rem 0; }
.body h1, .body h2, .body h3, .body h4 {
  margin: 0.9rem 0 0.4rem;
  line-height: 1.25;
}
.body h1 { font-size: 1.2rem; }
.body h2 { font-size: 1.1rem; }
.body h3 { font-size: 1.02rem; }
.body hr { border: none; border-top: 1px solid var(--border); margin: 0.9rem 0; }
.body table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
.body th, .body td { border: 1px solid var(--border); padding: 6px 8px; vertical-align: top; }
.body th { background: rgba(17, 24, 39, 0.04); text-align: left; }
.body blockquote {
  margin: 0.75rem 0;
  padding: 8px 10px;
  border-left: 4px solid rgba(0, 120, 212, 0.35);
  background: rgba(0, 120, 212, 0.05);
}

.pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  color: rgba(17, 24, 39, 0.92);
  font-size: 12px;
}

.empty {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 18px;
  color: var(--muted);
  background: var(--surface);
}

/* --- Compact table-like list view --- */

.table-shell {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.table-shell-head {
  border-bottom: none;
  border-radius: 14px 14px 0 0;
}

.table-shell-body {
  border-top: none;
  border-radius: 0 0 14px 14px;
}

.table-head-sticky {
  position: relative;
  z-index: 200;
  isolation: isolate;
  transform: translateZ(0);
  will-change: transform;
  contain: paint;
  background: linear-gradient(180deg, rgba(251, 252, 254, 0.98), rgba(241, 245, 255, 0.98));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.08);
}

.table-head-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Hide header scrollbar while keeping it scrollable (still scrolls via body sync) */
.table-head-wrap::-webkit-scrollbar { height: 0; }
.table-head-wrap { scrollbar-width: none; }

.table-body-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}



.table-head {
  display: grid;
  grid-template-columns:
    minmax(520px, 2.0fr)
    minmax(120px, 0.7fr)
    minmax(110px, 0.55fr)
    minmax(110px, 0.6fr)
    minmax(180px, 0.9fr)
    minmax(200px, 1.0fr);
  gap: 0;
  padding: 10px 12px;
  background: transparent;
  min-width: 1220px;
}

.th {
  font-size: 12px;
  font-weight: 700;
  color: rgba(17, 24, 39, 0.78);
  text-transform: none;
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.th-main { padding-left: 6px; }

.tr {
  display: grid;
  grid-template-columns:
    minmax(520px, 2.0fr)
    minmax(120px, 0.7fr)
    minmax(110px, 0.55fr)
    minmax(110px, 0.6fr)
    minmax(180px, 0.9fr)
    minmax(200px, 1.0fr);
  gap: 0;
  align-items: start;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(17, 24, 39, 0.06);
  background: var(--surface);
  position: relative;
  min-width: 1220px;
}

.actionby-graph {
  color: rgba(209, 52, 56, 0.95);
  font-weight: 700;
}

.actionby-ai {
  color: rgba(0, 120, 212, 0.95);
  font-weight: 700;
}

/* Hover overlay (prevents repaint "blink" and keeps left accent stable) */
.tr::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 120, 212, 0.04);
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}
.tr:hover::before { opacity: 1; }
.td { position: relative; z-index: 1; }
.tr:last-child { border-bottom: none; }

/* Row-level meaning (Graph flags) expressed via subtle background tints */
.tr.is-major {
  background: rgba(209, 52, 56, 0.07);
  box-shadow: inset 0 0 0 1px rgba(209, 52, 56, 0.18);
}

/* Master tags: subtle right-side accent bar */
.tr.is-security::after,
.tr.is-network::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 4px;
  opacity: 0.75;
  pointer-events: none;
}
.tr.is-security::after { background: var(--tag-security); }
.tr.is-network::after { background: var(--tag-network); }
.tr.is-security.is-network::after {
  background: linear-gradient(180deg, var(--tag-security), var(--tag-network));
}

.td {
  font-size: 13px;
  color: rgba(17, 24, 39, 0.88);
  padding: 2px 6px;
}

.td-main { padding-left: 0; }
.td-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 20px;
}
.title-text {
  font-weight: 700;
  line-height: 1.2;
  display: -webkit-box;
  line-clamp: 1;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.td-summary {
  margin-top: 4px;
  color: rgba(17, 24, 39, 0.78);
  font-size: 12.5px;
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
}

.td-services-inline {
  color: rgba(17, 24, 39, 0.78);
  font-size: 12.5px;
  line-height: 1.25;
  margin-top: 4px;
  white-space: normal;
  display: -webkit-box;
  line-clamp: 1;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.td-topics,
.td-actions {
  color: rgba(17, 24, 39, 0.78);
  font-size: 12.5px;
  line-height: 1.25;
  white-space: normal;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Priority accent bar: reuse existing item-imp-* classes */
.tr.item-imp-0, .tr.item-imp-1,
.tr.item-imp-2, .tr.item-imp-3,
.tr.item-imp-4, .tr.item-imp-5 {
  border-left: 4px solid transparent;
}
.tr.item-imp-0, .tr.item-imp-1 { border-left-color: rgba(16, 124, 16, 0.65); }
.tr.item-imp-2, .tr.item-imp-3 { border-left-color: rgba(202, 80, 16, 0.70); }
.tr.item-imp-4, .tr.item-imp-5 { border-left-color: rgba(209, 52, 56, 0.75); }

/* Mobile: stack columns */
@media (max-width: 900px) {
  .table-head-sticky { display: none; }
  .tr {
    grid-template-columns: 1fr;
    gap: 6px;
    min-width: 0;
  }
  .td { padding: 0; }
  .td-services-inline { padding-bottom: 2px; }
}
