/* Insight PDA — design system.
   Extends the visual language of insight-pda-dashboard.html into a full application shell. */

:root {
  --bg: #0a0e14;
  --bg-panel: #0f1520;
  --bg-card: #131a26;
  --bg-input: #0d1420;
  --bg-hover: #161f2c;
  --border: #1f2937;
  --border-soft: #16202c;
  --accent: #00d1c1;
  --accent-soft: rgba(0, 209, 193, .12);
  --accent-2: #3b82f6;
  --text: #e6edf3;
  --text-dim: #8b98a9;
  --text-faint: #5b6675;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  --purple: #8b5cf6;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #0d1a22 0%, var(--bg) 55%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #1e2a3a; border-radius: 20px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 8px; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #0891b2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: 0 0 18px rgba(0, 209, 193, .35);
}
.brand-icon svg { width: 19px; height: 19px; }
.brand-text .name { font-weight: 700; font-size: 16px; letter-spacing: .3px; color: #fff; }
.brand-text .tag { font-size: 10px; color: var(--text-faint); letter-spacing: .6px; text-transform: uppercase; }
.brand-org {
  font-size: 10px; color: var(--accent); letter-spacing: .4px;
  padding: 0 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.nav-section-label {
  font-size: 10px; color: var(--text-faint); letter-spacing: .8px; text-transform: uppercase;
  margin: 14px 10px 7px;
}
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border-radius: 8px;
  color: var(--text-dim); font-size: 12.8px; font-weight: 500;
  cursor: pointer; transition: .15s; border: 1px solid transparent; white-space: nowrap;
  background: none; width: 100%; text-align: left;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(0, 209, 193, .25); }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  background: var(--danger); color: #fff; border-radius: 20px; padding: 1px 6px;
}
.nav-badge.new { background: var(--purple); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.status-pill { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-faint); padding: 8px 10px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); flex-shrink: 0; }

/* ---------- SHELL ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: rgba(15, 21, 32, .82); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left h1 { font-size: 17px; font-weight: 600; color: #fff; }
.topbar-left .subtitle { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; width: 260px; color: var(--text-faint);
  position: relative;
}
.search-box svg { width: 14px; height: 14px; flex-shrink: 0; }
.search-box input { background: transparent; border: none; outline: none; color: var(--text); font-size: 12.5px; width: 100%; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; width: 320px;
  background: #111823; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .5); padding: 6px; z-index: 60; display: none;
  max-height: 340px; overflow-y: auto;
}
.search-results.open { display: block; }
.search-hit { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.search-hit:hover { background: var(--bg-hover); }
.search-hit .t { font-size: 12.5px; color: var(--text); font-weight: 600; }
.search-hit .s { font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }
.search-empty { padding: 12px; font-size: 11.5px; color: var(--text-faint); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; color: var(--text-dim);
}
.icon-btn:hover { color: var(--text); border-color: #2b3a4d; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .ping {
  position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--bg-panel);
}

.profile-wrap { position: relative; }
.profile-trigger {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 5px; border-radius: 30px;
  background: var(--bg-card); border: 1px solid var(--border); cursor: pointer;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.xl { width: 64px; height: 64px; font-size: 21px; }
.profile-trigger .who { display: flex; flex-direction: column; line-height: 1.2; }
.profile-trigger .who .n { font-size: 12.5px; font-weight: 600; color: #fff; }
.profile-trigger .who .r { font-size: 10.5px; color: var(--text-faint); }
.chev { width: 12px; height: 12px; color: var(--text-faint); }

.dropdown {
  position: absolute; right: 0; top: calc(100% + 10px); width: 270px;
  background: #111823; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, .5); padding: 16px; display: none; z-index: 50;
}
.dropdown.open { display: block; }
.dropdown.wide { width: 340px; padding: 8px; }
.profile-menu-head {
  display: flex; gap: 12px; align-items: center;
  padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.profile-menu-head .n { font-size: 14px; font-weight: 700; color: #fff; }
.profile-menu-head .e { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.clearance-badge {
  display: inline-block; margin-top: 6px; font-size: 9.5px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(0, 209, 193, .3);
  padding: 2px 7px; border-radius: 20px; letter-spacing: .4px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; border-radius: 8px; font-size: 12.5px; color: var(--text-dim); cursor: pointer;
}
.menu-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.menu-item:hover { background: var(--bg-hover); color: var(--text); }
.menu-item.logout {
  color: #fca5a5; margin-top: 6px; border-top: 1px solid var(--border);
  padding-top: 12px; border-radius: 0 0 8px 8px;
}
.menu-item.logout:hover { background: rgba(239, 68, 68, .1); color: #fecaca; }

.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.notif-head .t { font-size: 12px; font-weight: 700; color: #fff; }
.notif-item { padding: 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; }
.notif-item:hover { background: var(--bg-hover); }
.notif-item .n { font-size: 12px; color: var(--text); font-weight: 600; }
.notif-item .m { font-size: 11px; color: var(--text-faint); margin-top: 2px; line-height: 1.4; }

.content { padding: 20px 28px 60px; overflow-y: auto; flex: 1; }

/* ---------- PRIMITIVES ---------- */
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-title h2 { font-size: 14px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.section-title .dash { flex: 1; height: 1px; background: var(--border); }
.section-title .meta { font-size: 11px; color: var(--text-faint); }

.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel-head h3 { font-size: 13px; font-weight: 600; color: #fff; }
.panel-head .sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.field-label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-faint); font-weight: 700; margin-bottom: 5px; display: block;
}
.field { margin-bottom: 12px; }
input.control, select.control, textarea.control {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 12.5px;
  outline: none; font-family: inherit;
}
input.control:focus, select.control:focus, textarea.control:focus { border-color: rgba(0, 209, 193, .5); }
select.control { cursor: pointer; appearance: none; background-image: none; padding-right: 26px; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: '▾'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 11px; pointer-events: none;
}
input.control::placeholder, textarea.control::placeholder { color: var(--text-faint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-dim);
  transition: .15s;
}
.btn:hover { color: var(--text); border-color: #2b3a4d; }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04201d; }
.btn.primary:hover { background: #21e0d1; color: #04201d; }
.btn.danger { color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
.btn.danger:hover { background: rgba(239, 68, 68, .12); color: #fecaca; }
.btn.sm { padding: 5px 10px; font-size: 11.5px; }
.btn.block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-dim);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 20px; cursor: pointer; transition: .15s;
}
.chip:hover { color: var(--text); border-color: #2b3a4d; }
.chip.on { background: var(--accent-soft); border-color: rgba(0, 209, 193, .3); color: var(--accent); }
.chip svg { width: 12px; height: 12px; }
.chip b { color: var(--text); font-weight: 600; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  white-space: nowrap;
}
.tag-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.tag.critical { background: rgba(239, 68, 68, .12); color: #fca5a5; }
.tag.high { background: rgba(245, 158, 11, .12); color: #fcd34d; }
.tag.medium { background: rgba(59, 130, 246, .12); color: #93c5fd; }
.tag.low { background: rgba(34, 197, 94, .12); color: #86efac; }
.tag.neutral { background: rgba(139, 152, 169, .12); color: var(--text-dim); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.purple { background: rgba(139, 92, 246, .14); color: #c4b5fd; }

.status { font-size: 11.5px; font-weight: 600; }
.status.open { color: var(--warn); }
.status.review { color: var(--accent-2); }
.status.closed { color: var(--text-faint); }
.status.ok { color: var(--ok); }
.status.bad { color: var(--danger); }

.muted { color: var(--text-faint); }
.mono { font-variant-numeric: tabular-nums; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; position: relative; overflow: hidden;
}
.kpi-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(0, 209, 193, .06), transparent 55%); pointer-events: none;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.kpi-icon svg { width: 16px; height: 16px; }
.kpi-icon.cyan { background: rgba(0, 209, 193, .12); color: var(--accent); }
.kpi-icon.blue { background: rgba(59, 130, 246, .12); color: var(--accent-2); }
.kpi-icon.amber { background: rgba(245, 158, 11, .12); color: var(--warn); }
.kpi-icon.red { background: rgba(239, 68, 68, .12); color: var(--danger); }
.kpi-icon.purple { background: rgba(139, 92, 246, .14); color: var(--purple); }
.kpi-trend { font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 3px; }
.kpi-trend.up { color: var(--ok); }
.kpi-trend.down { color: var(--danger); }
.kpi-value { font-size: 26px; font-weight: 700; color: #fff; letter-spacing: -.5px; }
.kpi-label { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* charts */
.charts-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 24px; }

/* Grid children default to min-width:auto, which lets an intrinsically sized child
   (a Chart.js canvas, a wide table) push the track past the viewport. */
.charts-grid > *, .split > *, .kpi-grid > *, .tools-grid > *, .filter-bar > *, .stack > * { min-width: 0; }
.chart-box { height: 230px; position: relative; }
.legend-chip { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.legend-chip .sw { width: 8px; height: 8px; border-radius: 2px; }

.risk-list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.risk-row { display: flex; align-items: center; gap: 10px; }
.risk-row .lbl { width: 150px; font-size: 11.5px; color: var(--text-dim); flex-shrink: 0; }
.bar-track { flex: 1; height: 7px; background: #1a2333; border-radius: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; }
.risk-row .pct { width: 40px; text-align: right; font-size: 11.5px; font-weight: 700; color: var(--text); }

/* tool cards */
.tools-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.tool-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px; transition: .15s; cursor: pointer;
}
.tool-card:hover { border-color: rgba(0, 209, 193, .35); transform: translateY(-2px); }
.tool-icon { width: 38px; height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.tool-icon svg { width: 19px; height: 19px; }
.tool-card h4 { font-size: 13.5px; font-weight: 700; color: #fff; }
.tool-card p { font-size: 11.5px; color: var(--text-faint); line-height: 1.55; }
.tool-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; }
.tool-metric { font-size: 11px; color: var(--accent); font-weight: 700; }
.tool-link { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; }
.tool-link svg { width: 12px; height: 12px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-faint); padding: 0 12px 10px; border-bottom: 1px solid var(--border);
  font-weight: 600; white-space: nowrap;
}
td { padding: 12px; font-size: 12.5px; color: var(--text-dim); border-bottom: 1px solid var(--border-soft); }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: rgba(0, 209, 193, .04); color: var(--text); }
tbody tr.selected td { background: var(--accent-soft); }
.case-id { color: var(--text); font-weight: 600; }
.conf-bar { display: flex; align-items: center; gap: 8px; }
.conf-track { width: 60px; height: 5px; background: #1a2333; border-radius: 20px; overflow: hidden; flex-shrink: 0; }
.conf-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #0891b2); border-radius: 20px; }
.empty-row { text-align: center; color: var(--text-faint); font-size: 12px; padding: 28px 12px; }

/* layout helpers */
.split { display: grid; gap: 16px; }
.split.sidebar-left { grid-template-columns: 280px 1fr; }
.split.sidebar-right { grid-template-columns: 1fr 300px; }
.split.half { grid-template-columns: 1fr 1fr; }
.split.thirds { grid-template-columns: repeat(3, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

.filter-bar { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 12px; align-items: end; }
.filter-bar .field { margin-bottom: 0; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 8px 14px; font-size: 12.5px; color: var(--text-faint); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* definition grid */
.defs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
.defs.two { grid-template-columns: repeat(2, 1fr); }
.def .k {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-faint); font-weight: 700; margin-bottom: 4px;
}
.def .v { font-size: 13px; color: var(--text); font-weight: 600; }

/* result list */
.result-list { display: flex; flex-direction: column; gap: 6px; }
.result-item {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--bg-input);
}
.result-item:hover { border-color: rgba(0, 209, 193, .35); }
.result-item.active { border-color: var(--accent); background: var(--accent-soft); }
.result-item .n { font-size: 12.5px; color: var(--text); font-weight: 600; }
.result-item .p { font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }
.risk-pill {
  margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}
.risk-pill.hi { background: rgba(239, 68, 68, .14); color: #fca5a5; }
.risk-pill.mid { background: rgba(245, 158, 11, .14); color: #fcd34d; }
.risk-pill.lo { background: rgba(34, 197, 94, .12); color: #86efac; }

/* AI note */
.ai-note {
  background: rgba(0, 209, 193, .07); border: 1px solid rgba(0, 209, 193, .22);
  border-radius: 8px; padding: 12px 14px; font-size: 12px; color: var(--text-dim); line-height: 1.6;
}
.ai-note .hdr { display: flex; align-items: center; gap: 7px; font-size: 10.5px; font-weight: 700; color: var(--accent); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 6px; }
.ai-note .hdr svg { width: 13px; height: 13px; }
.cite {
  display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700;
  background: rgba(0, 209, 193, .14); color: var(--accent); border-radius: 5px;
  padding: 1px 6px; margin: 0 2px; cursor: pointer; border: 1px solid rgba(0, 209, 193, .25);
}
.cite:hover { background: rgba(0, 209, 193, .26); }

/* drilldown path */
.drill { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 12px; align-items: center; }
.drill-step { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.drill-step .n { font-size: 9.5px; font-weight: 700; color: var(--accent); letter-spacing: .6px; margin-bottom: 5px; }
.drill-step .t { font-size: 12.5px; font-weight: 700; color: #fff; margin-bottom: 3px; }
.drill-step .d { font-size: 11px; color: var(--text-faint); line-height: 1.5; }
.drill-arrow { color: var(--text-faint); font-size: 16px; }

/* graph */
.graph-canvas { height: 460px; border: 1px solid var(--border); border-radius: 8px; background: #0b1119; }
.node-detail .k { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .6px; }
.node-detail .v { font-size: 12.5px; color: var(--text); font-weight: 600; margin-bottom: 10px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* chat */
.chat-shell { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 4px 12px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 76%; padding: 10px 14px; border-radius: 12px; font-size: 12.5px; line-height: 1.6; }
.msg.bot { background: #1a2333; color: var(--text-dim); border-bottom-left-radius: 3px; align-self: flex-start; }
.msg.user { background: var(--accent-soft); color: var(--accent); border-bottom-right-radius: 3px; align-self: flex-end; }
.msg.typing { color: var(--text-faint); font-style: italic; }
.chat-composer { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.chat-composer input { flex: 1; }
.icon-send {
  width: 36px; height: 36px; border-radius: 8px; border: none; background: var(--accent);
  color: #04201d; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.icon-send svg { width: 15px; height: 15px; }

/* floating chat widget */
.chat-fab {
  position: fixed; bottom: 26px; right: 26px; width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #0891b2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 8px 26px rgba(0, 209, 193, .4); z-index: 60; border: none;
}
.chat-fab svg { width: 24px; height: 24px; color: #04201d; }
.chat-panel {
  position: fixed; bottom: 92px; right: 26px; width: 340px;
  background: #111823; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55); display: none; flex-direction: column;
  overflow: hidden; z-index: 60;
}
.chat-panel.open { display: flex; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); background: linear-gradient(90deg, rgba(0, 209, 193, .08), transparent);
}
.chat-head .t { font-size: 12.5px; font-weight: 700; color: #fff; }
.chat-head .s { font-size: 10px; color: var(--text-faint); }
.chat-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; }
.chat-body .msg { max-width: 88%; font-size: 11.8px; padding: 9px 12px; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input input {
  flex: 1; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; color: var(--text); font-size: 11.5px; outline: none; font-family: inherit;
}
.chat-input button { width: 32px; height: 32px; border-radius: 8px; border: none; background: var(--accent); color: #04201d; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.chat-input button svg { width: 14px; height: 14px; }

/* toggles */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .n { font-size: 12.5px; color: var(--text); font-weight: 600; }
.toggle-row .d { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.switch { width: 38px; height: 21px; border-radius: 20px; background: #1e2a3a; position: relative; cursor: pointer; flex-shrink: 0; border: 1px solid var(--border); transition: .15s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--text-faint); transition: .15s; }
.switch.on { background: var(--accent-soft); border-color: rgba(0, 209, 193, .45); }
.switch.on::after { left: 19px; background: var(--accent); }

/* source status */
.source-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-input); }
.source-row + .source-row { margin-top: 8px; }
.source-row .n { font-size: 12.5px; color: var(--text); font-weight: 600; }
.source-row .m { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }

/* OSINT */
.meter {
  height: 20px; background: #1a2333; border-radius: 20px; overflow: hidden;
  position: relative; border: 1px solid var(--border);
}
.meter-fill { height: 100%; border-radius: 20px; transition: width .3s; }
.meter-fill.ok { background: linear-gradient(90deg, var(--accent), #0891b2); }
.meter-fill.warn { background: linear-gradient(90deg, var(--warn), #d97706); }
.meter-fill.bad { background: linear-gradient(90deg, var(--danger), #b91c1c); }
.meter-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.osint-group { margin-bottom: 20px; }
.osint-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 7px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.osint-group-head h4 { font-size: 12.5px; font-weight: 700; color: #fff; }
.osint-group-head .muted { font-size: 10.5px; }
.osint-purpose { font-size: 11px; color: var(--text-faint); line-height: 1.55; margin: 6px 0 10px; }

.osint-row {
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--border-soft);
}
.osint-row:last-child { border-bottom: none; }
.osint-main { min-width: 0; flex: 1; }
.osint-label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-faint); font-weight: 700; margin-bottom: 4px;
}
.osint-value { font-size: 12.5px; color: var(--text); font-weight: 600; line-height: 1.5; }
.osint-detail { font-size: 11px; color: var(--text-faint); line-height: 1.55; margin-top: 5px; }
.osint-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.osint-corr { font-size: 10.5px; color: var(--ok); white-space: nowrap; }

.src-chip {
  font-size: 10.5px; color: var(--text-dim); background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 20px; padding: 3px 9px; white-space: nowrap;
}
.src-chip.lead { color: #fcd34d; border-color: rgba(245, 158, 11, .3); background: rgba(245, 158, 11, .08); }

.conf-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  border: 1px solid transparent;
}
.conf-badge b { font-size: 11px; letter-spacing: .5px; }
.conf-badge.high { background: rgba(34, 197, 94, .12); color: #86efac; border-color: rgba(34, 197, 94, .25); }
.conf-badge.medium { background: rgba(245, 158, 11, .12); color: #fcd34d; border-color: rgba(245, 158, 11, .25); }
.conf-badge.low { background: rgba(239, 68, 68, .12); color: #fca5a5; border-color: rgba(239, 68, 68, .25); }

.rel-grade {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px; font-size: 11px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(0, 209, 193, .3);
}
.rel-grade.weak { background: rgba(245, 158, 11, .12); color: #fcd34d; border-color: rgba(245, 158, 11, .3); }

.mask-pill {
  font-size: 9px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  background: rgba(139, 92, 246, .16); color: #c4b5fd; border-radius: 4px; padding: 1px 5px;
}

.osint-gaps { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }

/* masked identity + audited reveal */
.masked-field { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.osint-value.revealed {
  color: var(--warn); font-variant-numeric: tabular-nums;
  background: rgba(245, 158, 11, .08); border-radius: 5px; padding: 1px 7px;
}
.reveal-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 6px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-faint);
  cursor: pointer; transition: .15s;
}
.reveal-btn svg { width: 12px; height: 12px; }
.reveal-btn:hover { color: var(--text); border-color: #2b3a4d; }
.reveal-btn.on { color: var(--warn); border-color: rgba(245, 158, 11, .35); background: rgba(245, 158, 11, .1); }

/* household roster */
.hh-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.hh-member {
  border: 1px solid var(--border); border-radius: 9px; padding: 14px; background: var(--bg-input);
}
.hh-member.is-subject { border-color: rgba(0, 209, 193, .3); background: rgba(0, 209, 193, .04); }
.hh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.hh-name { font-size: 13.5px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.hh-rel { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.hh-nik { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.hh-holdings { margin-bottom: 10px; display: flex; flex-direction: column; gap: 5px; }
.hh-holding {
  font-size: 11.5px; color: var(--text); background: rgba(59, 130, 246, .1);
  border-left: 2px solid var(--accent-2); border-radius: 0 5px 5px 0; padding: 5px 9px;
}

.log-sensitive {
  font-size: 9px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  background: rgba(245, 158, 11, .16); color: #fcd34d; border-radius: 4px; padding: 1px 5px; margin-left: 7px;
}

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

.media-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.media-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg-input); }
.media-thumb {
  height: 92px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: repeating-linear-gradient(45deg, #131a26, #131a26 8px, #161f2c 8px, #161f2c 16px);
  color: var(--text-faint); font-size: 10.5px; border-bottom: 1px solid var(--border);
}
.media-thumb svg { width: 20px; height: 20px; }
.media-body { padding: 11px 12px; }
.detect-chip {
  font-size: 10px; background: rgba(59, 130, 246, .12); color: #93c5fd;
  border-radius: 4px; padding: 2px 6px;
}

@media (max-width: 1280px) {
  .media-strip { grid-template-columns: 1fr; }
  .osint-row { flex-direction: column; gap: 8px; }
  .osint-meta { justify-content: flex-start; }
}

/* upload */
.dropzone {
  border: 1.5px dashed #2b3a4d; border-radius: var(--radius);
  background: var(--bg-input); padding: 34px 20px; text-align: center;
  cursor: pointer; transition: .15s;
}
.dropzone:hover { border-color: rgba(0, 209, 193, .5); background: rgba(0, 209, 193, .04); }
.dropzone.over { border-color: var(--accent); background: rgba(0, 209, 193, .09); }
.dz-icon {
  width: 42px; height: 42px; border-radius: 11px; margin: 0 auto 12px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.dz-icon svg { width: 20px; height: 20px; }
.dz-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.dz-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.upload-queue { margin-top: 14px; }

.chunk-card {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-size: 11.8px; color: var(--text-dim); line-height: 1.65;
}
.chunk-card + .chunk-card { margin-top: 8px; }
.chunk-meta {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--accent); font-weight: 700; margin-bottom: 6px;
}

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 8, 14, .72); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 90; padding: 24px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #111823; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6); width: 100%; max-width: 460px; padding: 24px;
}
.modal.lg { max-width: 720px; }
.modal h3 { font-size: 15px; color: #fff; font-weight: 700; margin-bottom: 6px; }
.modal p.lead { font-size: 12.5px; color: var(--text-faint); line-height: 1.6; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-body { max-height: 60vh; overflow-y: auto; }

/* toast */
.toast-host { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #111823; border: 1px solid rgba(0, 209, 193, .3); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 12.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5); display: flex; align-items: center; gap: 9px;
}
.toast svg { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; }

/* breadcrumb */
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-faint); margin-bottom: 14px; }
.crumbs a { cursor: pointer; }
.crumbs a:hover { color: var(--accent); }

/* coverage */
.cov { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; }
.cov .legend-dot.covered { background: var(--ok); }
.cov .legend-dot.partial { background: var(--warn); }
.cov .legend-dot.planned { background: var(--text-faint); }

@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid, .tools-grid, .split.sidebar-left, .split.sidebar-right, .split.half, .split.thirds { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: repeat(2, 1fr); }
  .drill { grid-template-columns: 1fr; }
  .drill-arrow { display: none; }
  .defs { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .search-box { display: none; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
}
