/* ─── Token system ─────────────────────────────────────────── */
:root {
  /* Ink (dark sidebar) */
  --ink:        #111827;
  --ink-2:      #1B2437;
  --ink-border: #2E3D58;
  --ink-text:   #DDD8CF;
  --ink-muted:  #8494AB;
  --ink-faint:  #4C5B74;

  /* Parchment (main) */
  --bg:         #F7F4EF;
  --bg-2:       #EDE8DF;
  --surface:    #FFFFFF;
  --surface-2:  #FAFAF7;

  /* Borders */
  --border:        #E2D9CD;
  --border-strong: #C8BFB2;

  /* Text */
  --t1: #0E1219;
  --t2: #29334A;
  --t3: #55687A;
  --t4: #8D9AAB;

  /* Brass accent */
  --brass:      #A67230;
  --brass-2:    #C48E40;
  --brass-lt:   #F4EAD8;
  --brass-bd:   #D4AE78;
  --brass-glow: rgba(166, 114, 48, .13);

  /* Status */
  --success: #2E7D4A;
  --success-soft: #E7F4EC;
  --danger: #B3261E;
  --danger-soft: #FBEAE9;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 15px;
  --r-xl: 20px;

  /* Shadows */
  --sh-xs: 0 1px 3px rgba(8, 14, 24, .04);
  --sh-sm: 0 2px 10px rgba(8, 14, 24, .06);
  --sh-md: 0 8px 28px rgba(8, 14, 24, .08);
  --sh-lg: 0 20px 52px rgba(8, 14, 24, .11);

  --sidebar-w: 250px;
  --font-ui: 'Geist', 'Inter', system-ui, sans-serif;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  background: var(--bg);
  color: var(--t1);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(8, 14, 24, .1); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(8, 14, 24, .18); }

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

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  padding: 20px 16px 18px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--ink-border);
}

.brand-row { display: flex; align-items: center; gap: 11px; }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--ink-2);
  border: 1px solid var(--ink-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: .98rem;
  font-weight: 600;
  letter-spacing: -.025em;
  color: var(--ink-text);
  margin: 0;
  line-height: 1.15;
}

.brand-sub {
  font-size: .55rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 3px 0 0;
}

/* Nav ─── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: .57rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 4px 2px 10px;
}

.nav-btn {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px 9px 13px;
  border-radius: var(--r-sm);
  font-size: .8rem;
  font-weight: 500;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
  text-align: left;
}

.nav-btn svg { flex-shrink: 0; opacity: .9; }

.nav-btn::before {
  content: '';
  position: absolute;
  left: 0; top: 7px; bottom: 7px;
  width: 2.5px;
  border-radius: 2px;
  background: transparent;
  transition: background .14s ease;
}

.nav-btn:hover { color: var(--ink-text); border-color: var(--ink-border); }

.nav-btn.active { color: var(--ink-text); border-color: var(--ink-border); }
.nav-btn.active::before { background: var(--brass); }
.nav-btn.locked {
  opacity: .45;
  cursor: not-allowed;
}
.nav-btn.locked:hover {
  color: var(--ink-muted);
  border-color: transparent;
}

.sidebar-footer {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--ink-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ink-muted);
  padding: 0 2px;
}

.env-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2.5px rgba(46, 125, 74, .18);
  flex-shrink: 0;
}

.sidebar-account-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--ink-border);
  background: var(--ink-2);
  color: var(--ink-text);
  cursor: pointer;
  text-align: left;
  transition: border-color .14s ease, background .14s ease;
}

.sidebar-account-btn:hover,
.sidebar-account-btn.active {
  border-color: var(--brass-bd);
  background: rgba(196, 142, 64, .12);
}

.sidebar-account-avatar {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--brass-bd);
  background: var(--brass-lt);
  color: var(--brass);
  font-family: 'JetBrains Mono', monospace;
  font-size: .64rem;
  font-weight: 800;
}

.sidebar-account-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-account-label {
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sidebar-account-email {
  margin-top: 2px;
  font-size: .7rem;
  font-weight: 600;
  color: var(--ink-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════
   MAIN PANEL
═══════════════════════════════════════════ */
.main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.main-topbar {
  flex-shrink: 0;
  height: 54px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(247, 244, 239, .88);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}

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

.topbar-eyebrow {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--t4);
}

.topbar-divider { width: 1px; height: 13px; background: var(--border-strong); border-radius: 1px; }

.topbar-title { font-size: .875rem; font-weight: 500; color: var(--t2); letter-spacing: -.01em; }
.topbar-user { font-size: .74rem; color: var(--t3); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view { flex: 1; display: none; min-height: 0; overflow: hidden; flex-direction: column; }
.view.active { display: flex; }

/* ═══════════════════════════════════════════
   AUTH VIEW
═══════════════════════════════════════════ */
.app-shell.auth-mode .sidebar,
.app-shell.auth-mode .main-topbar {
  display: none;
}

.app-shell.auth-mode .main-panel {
  width: 100%;
}

.auth-shell {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr);
  min-height: 100vh;
  background: var(--surface);
}

.auth-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: 34px 36px 42px;
  overflow: hidden;
  color: var(--ink-text);
  background:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px),
    radial-gradient(circle at 22% 14%, rgba(166, 114, 48, .2), transparent 28%),
    var(--ink);
  background-size: 32px 32px, 32px 32px, auto, auto;
}

.auth-brand-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, .34) 100%);
  pointer-events: none;
}

.auth-brand-lockup,
.auth-quote {
  position: relative;
  z-index: 1;
}

.auth-brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink-text);
}

.auth-brand-mark {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: -.04em;
}

.auth-quote {
  max-width: 420px;
}

.auth-quote p {
  margin: 0 0 22px;
  font-size: 1.35rem;
  line-height: 1.45;
  letter-spacing: -.035em;
  color: rgba(255, 255, 255, .82);
}

.auth-quote strong {
  color: #fff;
  font-weight: 700;
}

.auth-quote-source {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .74rem;
}

.auth-quote-avatar {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ink-2);
  border: 1px solid var(--ink-border);
  color: var(--brass-bd);
  font-size: .58rem;
  font-weight: 800;
}

.auth-quote-source strong,
.auth-quote-source span {
  display: block;
}

.auth-quote-source span {
  margin-top: 2px;
  color: var(--ink-muted);
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 32px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 340px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 24px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.auth-tab {
  border: none;
  border-radius: var(--r-sm);
  padding: 8px 12px;
  background: transparent;
  color: var(--t3);
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--t1);
  box-shadow: var(--sh-xs);
}

.auth-title {
  margin: 0 0 6px;
  font-family: var(--font-ui);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--t1);
}

.auth-body {
  margin: 0 0 22px;
  font-size: .76rem;
  line-height: 1.55;
  color: var(--t3);
}

.auth-microsoft-btn,
.auth-submit-btn {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-xs);
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
}

.auth-microsoft-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--t2);
}

.microsoft-mark {
  width: 12px;
  height: 12px;
  display: inline-block;
  background:
    linear-gradient(#f25022 0 0) left top / 5px 5px no-repeat,
    linear-gradient(#7fba00 0 0) right top / 5px 5px no-repeat,
    linear-gradient(#00a4ef 0 0) left bottom / 5px 5px no-repeat,
    linear-gradient(#ffb900 0 0) right bottom / 5px 5px no-repeat;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--t4);
  font-size: .62rem;
}

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

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 13px;
}

.auth-field > span {
  font-size: .7rem;
  font-weight: 700;
  color: var(--t2);
}

.auth-field input:not([type="checkbox"]) {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--t1);
  padding: 0 11px;
  font-size: .78rem;
  font-family: inherit;
}

.auth-field input:not([type="checkbox"]):focus {
  outline: none;
  border-color: var(--brass-bd);
  box-shadow: 0 0 0 3px var(--brass-glow);
}

.auth-field textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--t1);
  padding: 9px 11px;
  font-size: .78rem;
  font-family: inherit;
  line-height: 1.5;
}
.auth-field textarea:focus {
  outline: none;
  border-color: var(--brass-bd);
  box-shadow: 0 0 0 3px var(--brass-glow);
}
.auth-field textarea::placeholder { color: var(--t4); }

.auth-submit-btn {
  margin-top: 8px;
  border: 1px solid var(--brass);
  background: var(--brass);
  color: #fff;
}

.auth-submit-btn:hover:not(:disabled) {
  background: #8f5f27;
}

.auth-submit-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.auth-terms {
  margin: 18px 0 0;
  font-size: .62rem;
  line-height: 1.6;
  color: var(--t4);
}

.auth-otp-hint {
  margin: 8px 0 12px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--brass-bd);
  background: var(--brass-lt);
  color: var(--brass);
  font-size: .72rem;
  font-family: 'JetBrains Mono', monospace;
}

.auth-link-btn {
  display: block;
  margin: 12px auto 0;
  border: none;
  background: transparent;
  color: var(--brass);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
}

.auth-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  text-align: left;
}

@media (max-width: 820px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand-panel {
    display: none;
  }
}

/* ═══════════════════════════════════════════
   CHAT VIEW
═══════════════════════════════════════════ */
.chat-area { flex: 1; overflow-y: auto; }

/* Kept equal to the input control's own text inset (border + padding, see #queryInput)
   so a response's left edge lines up exactly with the placeholder text below it. */
.chat-inner {
  max-width: 730px;
  margin: 0 auto;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.welcome-wrap { padding: 40px 0 12px; display: flex; flex-direction: column; align-items: center; text-align: center; }

.welcome-emblem {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--brass-lt), #f0e0c4);
  border: 1px solid var(--brass-bd);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 4px 16px var(--brass-glow), inset 0 1px 0 rgba(255, 255, 255, .7);
}

.welcome-heading {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -.025em;
  color: var(--t1);
  margin: 0 0 10px;
  line-height: 1.2;
}

.welcome-body { font-size: .85rem; line-height: 1.65; color: var(--t3); max-width: 400px; margin: 0 auto; }

.message-row { display: flex; width: 100%; }
.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }

.message-content { max-width: 76%; display: flex; flex-direction: column; }
/* Assistant replies are plain text, not a bubble — let them use the full row width so
   their line length (and left/right edges) matches the input control below. */
.message-row.assistant .message-content { max-width: 100%; width: 100%; }

.chat-msg-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--t4);
  margin: 0 0 5px 2px;
}
.chat-msg-label.user { text-align: right; margin-right: 2px; }

/* Assistant responses: clean and minimal — no card, no border, just text. */
.chat-msg-body {
  padding: 0;
}

.chat-msg-body.user {
  background: var(--ink);
  border: none;
  border-radius: var(--r-lg);
  border-top-right-radius: var(--r-xs);
  padding: 12px 17px;
}

.chat-msg-text { margin: 0; font-size: .875rem; line-height: 1.75; color: var(--t2); }
.chat-msg-text.user { color: rgba(255, 255, 255, .9); white-space: pre-wrap; }
.chat-msg-text p { margin: 0 0 10px; }
.chat-msg-text p:last-child { margin-bottom: 0; }
.chat-msg-text ul,
.chat-msg-text ol {
  margin: 0 0 10px;
  padding-left: 20px;
}
.chat-msg-text ul:last-child,
.chat-msg-text ol:last-child { margin-bottom: 0; }
.chat-msg-text li { margin: 4px 0; }
.chat-msg-text li > p { margin: 0; }
.chat-msg-text table {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: .82rem;
}
.chat-msg-text th,
.chat-msg-text td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.chat-msg-text th {
  font-weight: 600;
  color: var(--t3);
  border-bottom-color: var(--border-strong);
}
.chat-msg-text code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: .82em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
}
.chat-msg-text pre {
  margin: 0 0 10px;
  padding: 12px 14px;
  border-radius: var(--r-md, 8px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow-x: auto;
}
.chat-msg-text pre:last-child { margin-bottom: 0; }
.chat-msg-text pre code {
  background: none;
  padding: 0;
  font-size: .8rem;
  line-height: 1.6;
  white-space: pre;
}

/* Minimal "thinking" affordance — a few pulsing dots, no card or fill color. */
.typing-dots { display: inline-flex; align-items: center; gap: 4px; height: 1.2em; }
.typing-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--t4);
  animation: typingBounce 1.1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.chat-citations {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.chat-citations-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--t4);
}
.chat-citations-toggle:hover { color: var(--t3); }
.chat-citations-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 5px;
  border-color: transparent transparent transparent currentColor;
  transform-origin: 35% 50%;
  transition: transform .15s ease;
}
.chat-citations-toggle[aria-expanded="true"] .chat-citations-arrow {
  transform: rotate(90deg);
}
.chat-citations ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}
.chat-citations ul[hidden] { display: none; }
.chat-citations li {
  margin: 4px 0;
  color: var(--t3);
  font-size: .74rem;
}
.chat-citations a {
  color: inherit;
  text-decoration: none;
}
.chat-citations a:hover {
  color: var(--brass);
  text-decoration: underline;
}
.citation-id {
  color: var(--brass);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.input-shell {
  flex-shrink: 0;
  padding: 8px 20px 14px;
  background: rgba(247, 244, 239, .9);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
}
.input-inner { max-width: 730px; margin: 0 auto; }
.input-row { display: flex; align-items: flex-end; gap: 9px; }

#inputWrapper {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color .2s ease, box-shadow .2s ease;
}

#inputWrapper:focus-within { border-color: var(--brass-bd); box-shadow: 0 0 0 3.5px var(--brass-glow), var(--sh-sm); }

/* Left/right padding is chat-inner's 20px minus this wrapper's 1px border, so the
   placeholder text lines up exactly with a response's left edge above it. */
#queryInput {
  width: 100%;
  border: none;
  resize: none;
  background: transparent;
  min-height: 22px;
  max-height: 140px;
  padding: 13px 19px 9px;
  font-family: 'Inter', sans-serif;
  font-size: .875rem;
  line-height: 1.6;
  color: var(--t1);
}
#queryInput:focus { outline: none; }
#queryInput::placeholder { color: var(--t4); }

.input-bottom-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 15px 8px; }
.input-hint { font-size: .62rem; color: var(--t4); font-family: 'JetBrains Mono', monospace; letter-spacing: .01em; }

.send-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--ink);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: var(--sh-sm);
  flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { background: var(--ink-2); transform: translateY(-1px); box-shadow: var(--sh-md); }
.send-btn:disabled { opacity: .32; cursor: not-allowed; transform: none; box-shadow: none; }

/* ═══════════════════════════════════════════
   TENANT & DATA VIEWS
═══════════════════════════════════════════ */
.tenant-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-xs);
  margin-bottom: 18px;
}

.tenant-avatar {
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  color: var(--brass);
  font-size: .82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.tenant-info { flex: 1; min-width: 0; }
.tenant-name { font-size: .95rem; font-weight: 600; color: var(--t1); margin: 0; }
.tenant-id { font-size: .72rem; color: var(--t4); margin: 3px 0 0; font-family: 'JetBrains Mono', monospace; }

.tenant-members {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.tenant-members-count { font-size: 1rem; font-weight: 700; color: var(--t1); line-height: 1.1; }
.tenant-members-label { font-size: .6rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--t4); margin-top: 2px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-xs);
}

.stat-value {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0;
  line-height: 1.15;
}

.stat-label { font-size: .68rem; color: var(--t4); margin: 5px 0 0; }

.tenant-actions { display: flex; gap: 10px; }

.account-detail-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-xs);
}

.account-detail-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.account-detail-avatar {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--r-md);
  border: 1px solid var(--brass-bd);
  background: var(--brass-lt);
  color: var(--brass);
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem;
  font-weight: 800;
}

.account-detail-name {
  margin: 0;
  color: var(--t1);
  font-size: .95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-detail-email {
  margin: 3px 0 0;
  color: var(--t3);
  font-size: .78rem;
}

.account-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.account-detail-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.account-detail-item span {
  display: block;
  margin-bottom: 5px;
  color: var(--t4);
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.account-detail-item strong {
  display: block;
  color: var(--t2);
  font-size: .76rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.mcp-hero-card {
  padding: 22px 24px;
  border: 1px solid var(--brass-bd);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--brass-lt), var(--surface) 60%);
  box-shadow: var(--sh-xs);
}

.mcp-hero-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.mcp-hero-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--r-md);
  border: 1px solid var(--brass-bd);
  background: var(--surface);
  color: var(--brass);
}

.mcp-hero-title {
  margin: 0;
  color: var(--t1);
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mcp-hero-desc {
  margin: 4px 0 0;
  color: var(--t3);
  font-size: .83rem;
}

.api-key-badge {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t4);
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  align-self: center;
}
.api-key-badge.active {
  color: #2a7a45;
  border-color: #b5ddc5;
  background: #edfaf3;
}

.api-key-reveal {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.api-key-value {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: .76rem;
  color: var(--brass);
  word-break: break-all;
}
.api-key-once-note {
  margin: 8px 0 0;
  font-size: .72rem;
  color: var(--brass);
  font-weight: 600;
}

.api-key-codex-block {
  margin-top: 16px;
}
.api-key-codex-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--t4);
  margin: 0 0 6px;
}
.api-key-codex-pre {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--ink);
  color: rgba(255,255,255,.82);
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
}

.mcp-how-to-link-wrap {
  margin: 14px 0 0;
}

.mcp-how-to-link {
  color: var(--brass);
  font-size: .86rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.mcp-how-to-link:hover {
  border-bottom-color: var(--brass-bd);
}

/* ─── Data page: hierarchical drill-down navigator ───────────── */
.data-view-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 26px 26px 22px;
}

.data-view-header { margin-bottom: 14px; flex-shrink: 0; }

/* breadcrumb path */
.nav-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.crumb {
  font-size: .74rem;
  font-weight: 500;
  color: var(--t3);
  background: transparent;
  border: none;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .14s ease, color .14s ease;
}
.crumb:hover { background: var(--bg-2); color: var(--t1); }
.crumb.current { color: var(--brass); font-weight: 600; cursor: default; }
.crumb.current:hover { background: transparent; }
.crumb-sep { color: var(--t4); font-size: .78rem; padding: 0 1px; }

/* horizontal flow of columns */
.nav-flow {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
}

.nav-links {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}

.nav-cols {
  display: flex;
  align-items: stretch;
  gap: 60px;
  height: 100%;
  min-height: 0;
  padding-right: 8px;
}

/* column */
.nav-col {
  position: relative;
  z-index: 1;
  width: 328px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}
.nav-col.entering { animation: colIn .32s cubic-bezier(.22, 1, .36, 1); }
.nav-col.files { width: 420px; }

/* root (connectors) column floats freely, no panel chrome */
.nav-col.connectors {
  width: 250px;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}
.nav-col.connectors .nav-col-list {
  padding: 0;
  overflow: visible;
  justify-content: center;
}

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

.nav-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.nav-col-headtext { min-width: 0; }
.nav-col-eyebrow {
  display: block;
  font-size: .54rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-col-title {
  font-size: .84rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0;
  letter-spacing: -.01em;
}

.nav-col-badge {
  font-size: .62rem;
  font-weight: 600;
  color: var(--t3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 9px;
  font-family: 'JetBrains Mono', monospace;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
  margin-left: 10px;
}

.nav-col-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* node */
.nav-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
.nav-node:hover { border-color: var(--brass-bd); box-shadow: var(--sh-xs); }
.nav-node.leaf { cursor: default; }
.nav-node.leaf:hover { border-color: var(--border); box-shadow: none; background: var(--bg); }

.nav-node.selected {
  border-color: var(--brass);
  background: var(--brass-lt);
  box-shadow: 0 0 0 3px var(--brass-glow);
}

.nav-node-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  color: var(--brass);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-node.leaf .nav-node-icon { width: 26px; height: 26px; }
.nav-node-icon.plain { background: transparent; border: none; }

.nav-node-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nav-node-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-node-sub {
  font-size: .65rem;
  color: var(--t4);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-node-chip {
  font-size: .62rem;
  font-weight: 700;
  color: var(--brass);
  background: var(--surface);
  border: 1px solid var(--brass-bd);
  border-radius: 99px;
  padding: 1px 7px;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}
.nav-node-chevron { color: var(--t4); flex-shrink: 0; }
.nav-node.selected .nav-node-chevron { color: var(--brass); }

/* files column: header stacks into its own rows so the branch selector and
   sync status/button always have full column width to breathe in (the column
   clips overflow for its rounded corners, so a single cramped row would cut
   badges/buttons off instead of wrapping). */
.files-head {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 10px;
  padding: 14px 16px;
}
.files-head-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.files-head-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-col-branch {
  display: flex;
  align-items: center;
  gap: 7px;
}
.nav-col-branch-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--t4);
}
.nav-col-branch-value {
  font-size: .74rem;
  font-weight: 500;
  color: var(--t1);
  font-family: 'JetBrains Mono', monospace;
}
.repo-branch-select {
  font-size: .74rem;
  font-weight: 500;
  color: var(--t1);
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 4px 9px;
  max-width: 180px;
  cursor: pointer;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.repo-branch-select:hover { border-color: var(--brass-bd); }
.repo-branch-select:focus {
  border-color: var(--brass-bd);
  box-shadow: 0 0 0 3px var(--brass-glow);
  outline: none;
}
.branch-select-loading {
  font-size: .62rem;
  color: var(--t4);
}
.nav-col-sync {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}

.sync-control-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.sync-control-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sync-error-detail {
  font-size: .68rem;
  line-height: 1.35;
  color: var(--danger);
  text-align: right;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.sync-progress-detail {
  font-size: .68rem;
  line-height: 1.35;
  color: var(--t3);
  text-align: right;
  max-width: 100%;
  word-break: break-word;
}

.sync-progress-bar-track {
  width: 120px;
  max-width: 100%;
  height: 5px;
  border-radius: 99px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.sync-progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--brass);
  transition: width .6s ease;
}

.sync-progress-eta {
  font-size: .64rem;
  line-height: 1.3;
  color: var(--t3);
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

.nav-col-count {
  display: inline-block;
  margin-left: 8px;
  font-size: .62rem;
  font-weight: 600;
  color: var(--t3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 8px;
  font-family: 'JetBrains Mono', monospace;
  vertical-align: middle;
}

.nav-col-search {
  padding: 10px 10px 4px;
  background: var(--surface);
  flex-shrink: 0;
}

.data-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
  color: var(--t4);
}
.data-search-wrap:focus-within {
  border-color: var(--brass-bd);
  box-shadow: 0 0 0 3px var(--brass-glow);
  color: var(--t3);
}
.data-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: .8rem;
  color: var(--t1);
  font-family: inherit;
  outline: none;
  min-width: 0;
}
.data-search-input::placeholder { color: var(--t4); }

/* pagination (files column footer) */
.nav-col-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.pagination-info {
  font-size: .66rem;
  color: var(--t3);
  font-family: 'JetBrains Mono', monospace;
}
.pagination-controls { display: flex; align-items: center; gap: 6px; }

.page-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--t2);
  cursor: pointer;
  transition: all .14s ease;
  flex-shrink: 0;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--brass-bd);
  background: var(--brass-lt);
  color: var(--brass);
}
.page-btn:disabled { opacity: .32; cursor: not-allowed; }

.page-current {
  font-size: .66rem;
  font-weight: 600;
  color: var(--t2);
  font-family: 'JetBrains Mono', monospace;
  min-width: 44px;
  text-align: center;
}

/* ═══════════════════════════════════════════
   CONNECTORS VIEW
═══════════════════════════════════════════ */
.page-scroll { flex: 1; overflow-y: auto; }
.page-inner { max-width: 760px; margin: 0 auto; padding: 32px 26px 60px; }

.page-header { margin-bottom: 22px; }
.page-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--t1);
  margin: 0 0 6px;
}
.page-desc {
  font-size: .82rem; color: var(--t3); line-height: 1.6; margin: 0;
 }

/* ─── Knowledge Search ──────────────────────────────────────── */
.search-inner { max-width: 820px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 8px 8px 8px 14px;
  box-shadow: var(--sh-sm);
  margin-bottom: 26px;
}
.search-bar:focus-within { border-color: var(--brass-bd); box-shadow: 0 0 0 3px var(--brass-glow); }
.search-bar-icon { color: var(--t4); flex-shrink: 0; }
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: .92rem;
  color: var(--t1);
  padding: 6px 0;
}
.search-input::placeholder { color: var(--t4); }
.search-submit {
  border: none;
  background: var(--brass);
  color: #fff;
  font-weight: 600;
  font-size: .82rem;
  padding: 9px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .15s ease;
}
.search-submit:hover:not(:disabled) { background: var(--brass-2); }
.search-submit:disabled { opacity: .55; cursor: default; }

.search-empty {
  color: var(--t3);
  font-size: .85rem;
  padding: 34px 4px;
  text-align: center;
}

.search-section { margin-bottom: 30px; }
.search-section-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--t4);
  margin: 0 0 12px;
}

.search-answer {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 18px 20px;
  box-shadow: var(--sh-xs);
  font-size: .88rem;
  line-height: 1.7;
  color: var(--t2);
}
.search-answer p { margin: 0 0 10px; }
.search-answer p:last-child { margin-bottom: 0; }
.search-answer ul, .search-answer ol { margin: 8px 0; padding-left: 20px; }
.search-answer li { margin: 4px 0; }
.search-answer strong { color: var(--t1); }
.search-answer table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .82rem; }
.search-answer th, .search-answer td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.search-answer th { background: var(--surface-2); font-weight: 600; color: var(--t1); }
.search-answer code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: .82em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
}
.search-answer pre {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: var(--r-md, 8px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow-x: auto;
}
.search-answer pre code {
  background: none;
  padding: 0;
  font-size: .8rem;
  line-height: 1.6;
  white-space: pre;
}

.entity-grid { display: grid; gap: 14px; }
.entity-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 18px 20px;
  box-shadow: var(--sh-xs);
}
.entity-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.entity-name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0;
  text-transform: capitalize;
}
.entity-type {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brass);
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  border-radius: var(--r-xs);
  padding: 2px 7px;
}
.entity-desc { font-size: .82rem; color: var(--t3); line-height: 1.6; margin: 10px 0 0; }

.fact-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 7px; }
.fact-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: .82rem;
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--border);
}
.fact-row:last-child { border-bottom: none; padding-bottom: 0; }
.fact-relation {
  flex-shrink: 0;
  min-width: 150px;
  color: var(--t4);
  font-weight: 500;
  text-transform: capitalize;
}
.fact-target { color: var(--t1); font-weight: 500; text-transform: capitalize; }
.fact-target-type {
  margin-left: 7px;
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--t4);
}

.entity-sources { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.source-pill {
  font-size: .7rem;
  color: var(--t3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  text-decoration: none;
  transition: border-color .15s ease, color .15s ease;
}
a.source-pill:hover { border-color: var(--brass-bd); color: var(--brass); }

.evidence-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.evidence-row {
  border: 1px solid var(--border);
  border-left: 3px solid var(--brass-bd);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 14px 16px;
}
.evidence-head { font-size: .74rem; color: var(--t4); margin-bottom: 7px; }
.evidence-source { color: var(--t2); font-weight: 600; text-decoration: none; }
a.evidence-source:hover { color: var(--brass); }
.evidence-text { margin: 0; font-size: .84rem; line-height: 1.65; color: var(--t2); }

.connector-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-xs);
  overflow: hidden;
}

.connector-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
}

.connector-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  /* background: var(--surface-2);
  border: 1px solid var(--border); */
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.connector-meta { flex: 1; min-width: 0; }

.connector-name-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.connector-name { font-size: .92rem; font-weight: 600; color: var(--t1); margin: 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 99px;
  font-family: 'JetBrains Mono', monospace;
}

.status-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

.status-badge.connected { background: var(--success-soft); color: var(--success); }
.status-badge.connected::before { background: var(--success); box-shadow: 0 0 0 2.5px rgba(46, 125, 74, .18); }

.status-badge.disconnected { background: var(--bg-2); color: var(--t3); border: 1px solid var(--border-strong); }
.status-badge.disconnected::before { background: var(--t4); }

/* Sync status badges (ingestion sync-tab cards) */
.status-badge.status-synced { background: var(--success-soft); color: var(--success); }
.status-badge.status-synced::before { background: var(--success); box-shadow: 0 0 0 2.5px rgba(46, 125, 74, .18); }

.status-badge.status-syncing { background: var(--brass-lt); color: var(--brass); }
.status-badge.status-syncing::before { display: none; }

.status-badge.status-queued { background: var(--bg-2); color: var(--t3); border: 1px solid var(--border-strong); }
.status-badge.status-queued::before { display: none; }

.status-badge.status-error { background: var(--danger-soft); color: var(--danger); }
.status-badge.status-error::before { background: var(--danger); }

.status-badge.status-stopped { background: var(--bg); color: var(--t3); border: 1px solid var(--border-strong); }
.status-badge.status-stopped::before { background: var(--t4); }

.status-badge .spinner {
  width: 9px; height: 9px;
  border-width: 1.5px;
  border-color: rgba(166, 114, 48, .25);
  border-top-color: var(--brass);
}

.connector-desc { font-size: .78rem; color: var(--t3); line-height: 1.6; margin: 6px 0 0; }

.connector-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 99px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.btn-primary { background: var(--brass); color: #fff; border-color: var(--brass); }
.btn-primary:hover { background: #8f5f27; transform: translateY(-1px); box-shadow: 0 4px 12px var(--brass-glow); }

.btn-secondary { background: var(--brass-lt); color: var(--brass); border-color: var(--brass-bd); }
.btn-secondary:hover { background: #eedfbe; transform: translateY(-1px); box-shadow: 0 4px 12px var(--brass-glow); }

.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border-strong); border-radius: var(--r-sm); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-sm { padding: 5px 11px; font-size: .7rem; }

.btn-ghost { background: transparent; color: var(--t3); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-2); color: var(--t1); border-color: var(--border); }

.connector-body {
  border-top: 1px solid var(--border);
  padding: 16px 20px 20px;
  background: var(--surface-2);
}

.connector-body-label {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--t4);
  margin: 0 0 10px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  margin-bottom: 14px;
}

.account-info { display: flex; align-items: center; gap: 10px; min-width: 0; }

.account-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  color: var(--brass);
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.account-text { min-width: 0; }
.account-email { font-size: .8rem; font-weight: 500; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-tenant { font-size: .7rem; color: var(--t4); margin-top: 1px; font-family: 'JetBrains Mono', monospace; }

.connector-hint { font-size: .74rem; color: var(--t4); margin: 14px 0 0; line-height: 1.5; }
.connector-hint strong { color: var(--t3); }

/* ═══════════════════════════════════════════
   EXTERNAL SOURCES VIEW
═══════════════════════════════════════════ */
.external-sources-inner {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0 0 60px;
}

.external-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 22px 26px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.external-eyebrow {
  display: inline-flex;
  margin-bottom: 7px;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brass);
}

.external-hero-stats {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.external-stat {
  min-width: 104px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: var(--sh-xs);
}

.external-stat-value {
  display: block;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
  color: var(--t1);
}

.external-stat-label {
  display: block;
  margin-top: 5px;
  font-size: .62rem;
  font-weight: 600;
  color: var(--t4);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.external-source-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 26px 0;
}

.external-section {
  padding: 0;
}

.external-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.external-section-kicker {
  display: block;
  margin-bottom: 4px;
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brass);
}

.external-section-title {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--t1);
}

.external-section-desc {
  max-width: 620px;
  margin: 6px 0 0;
  font-size: .78rem;
  line-height: 1.55;
  color: var(--t3);
}

.external-count-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--t3);
  font-size: .64rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.source-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 400px);
  gap: 12px;
}

.source-card {
  position: relative;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-xs);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.source-card:hover {
  transform: translateY(-2px);
  border-color: var(--brass-bd);
  box-shadow: var(--sh-sm);
}

.source-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  /* border: 1px solid var(--border);
  background: var(--surface-2); */
  flex-shrink: 0;
}

.source-logo img {
  width: 35px;
  height: 35px;
  object-fit: contain;
}

.source-card-content {
  flex: 1;
  min-width: 0;
}

.source-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.source-status {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--t3);
  font-size: .62rem;
  font-weight: 700;
}

.source-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--t4);
}

.source-status.connected {
  background: var(--success-soft);
  border-color: rgba(46, 125, 74, .22);
  color: var(--success);
}

.source-status.connected::before {
  background: #22C55E;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .14);
}

.source-card h3 {
  margin: 0;
  font-size: .98rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--t1);
}

.source-card p {
  margin: 0;
  font-size: .76rem;
  line-height: 1.45;
  color: var(--t3);
}

.source-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.source-tags span {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--t4);
  font-family: 'JetBrains Mono', monospace;
  font-size: .6rem;
  font-weight: 600;
}

.source-action {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 1px solid var(--brass);
  border-radius: var(--r-md);
  background: var(--brass);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}

.source-action:hover {
  border-color: #8f5f27;
  background: #8f5f27;
  color: #fff;
}

.source-action:disabled {
  opacity: .45;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .external-hero,
  .external-section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .external-hero-stats {
    width: 100%;
  }

  .external-stat {
    flex: 1;
  }

  .source-card {
    width: 100%;
  }

  .source-action {
    width: 100%;
  }
}

.site-sync-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--r-xs);
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--t3);
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

.site-sync-tag .spinner {
  width: 9px; height: 9px;
  border-width: 1.5px;
  border-color: rgba(85, 104, 122, .25);
  border-top-color: var(--t3);
}

.site-sync-tag.syncing { background: var(--brass-lt); border-color: var(--brass-bd); color: var(--brass); }
.site-sync-tag.syncing .spinner { border-color: rgba(166, 114, 48, .25); border-top-color: var(--brass); }

.site-sync-tag.synced { background: var(--success-soft); border-color: transparent; color: var(--success); }

.site-sync-tag.synced-warn { background: var(--brass-lt); border-color: transparent; color: var(--brass); cursor: help; }

.site-sync-tag.error { background: var(--danger-soft); border-color: transparent; color: var(--danger); cursor: help; }

.site-sync-tag.stopped { background: var(--bg); border-color: var(--border-strong); color: var(--t3); }

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 24px 16px;
  text-align: center;
  font-size: .78rem;
  color: var(--t4);
  line-height: 1.6;
}
.empty-state .btn-link {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--brass);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.inline-error {
  margin-top: 10px;
  font-size: .74rem;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(179, 38, 30, .25);
  border-radius: var(--r-sm);
  padding: 8px 11px;
}

.spinner {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.btn-secondary .spinner { border-color: rgba(166, 114, 48, .25); border-top-color: var(--brass); }

.spinner-lg {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--brass);
  animation: spin .85s linear infinite;
  flex-shrink: 0;
}

.nav-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  width: 100%;
}

.kg-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font-size: .82rem;
  color: var(--t4);
}

.connector-checking {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  color: var(--t3);
  padding: 6px 4px;
}
.connector-checking .spinner {
  border-color: rgba(166, 114, 48, .25);
  border-top-color: var(--brass);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ File delete button (on file rows in the Data view) ═══ */
.file-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--t4);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .14s ease, color .14s ease, background .14s ease, border-color .14s ease;
}
.nav-node.file:hover .file-delete-btn { opacity: 1; }
.file-delete-btn:hover { color: var(--danger); background: var(--danger-soft); border-color: rgba(179, 38, 30, .25); }

/* ═══ Confirm modal ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(31, 26, 20, .38);
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal-overlay-nested { z-index: 110; }

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  padding: 24px;
  text-align: center;
  animation: modalIn .16s ease;
}

.modal-card-wide {
  max-width: 480px;
  text-align: left;
}

.modal-card-angle {
  max-width: 640px;
  text-align: left;
  max-height: min(92vh, 820px);
  overflow-y: auto;
}

.sql-connect-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0 4px;
}

.sql-connect-fields .auth-field {
  margin: 0;
}

.sql-connect-fields .auth-field input {
  width: 100%;
}

.sql-trust-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 2px;
  font-size: .78rem;
  color: var(--t3);
  text-align: left;
  cursor: pointer;
}

.sql-trust-row input {
  margin-top: 2px;
  flex-shrink: 0;
}

.sql-discover-hint {
  margin: 0;
  font-size: .74rem;
  line-height: 1.45;
  color: var(--t3);
}

.sql-db-picker {
  position: relative;
  width: 100%;
}

.sql-db-picker-trigger {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--t1);
  padding: 0 11px;
  font-size: .78rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.sql-db-picker-trigger:hover {
  border-color: var(--brass-bd);
}

.sql-db-picker-trigger:focus,
.sql-db-picker.open .sql-db-picker-trigger {
  outline: none;
  border-color: var(--brass-bd);
  box-shadow: 0 0 0 3px var(--brass-glow);
}

.sql-db-picker-chevron {
  flex-shrink: 0;
  color: var(--t4);
  transition: transform .14s ease;
}

.sql-db-picker.open .sql-db-picker-chevron {
  transform: rotate(180deg);
  color: var(--brass);
}

.sql-db-picker-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface);
  box-shadow: var(--sh-sm);
  padding: 4px;
}

.sql-db-picker-option {
  width: 100%;
  display: block;
  border: 0;
  background: transparent;
  color: var(--t1);
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--r-xs);
  font-size: .78rem;
  font-family: inherit;
  cursor: pointer;
}

.sql-db-picker-option:hover {
  background: var(--surface-2);
}

.sql-db-picker-option.selected {
  background: var(--brass-lt);
  color: var(--brass);
  font-weight: 600;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger-soft);
  color: var(--danger);
}

/* External source connect success / error popup */
.external-connect-card {
  max-width: 400px;
  padding: 28px 24px 24px;
}

.external-connect-hero {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.external-connect-logo-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--r-xl);
  background: linear-gradient(160deg, var(--surface-2), var(--brass-lt));
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.external-connect-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.external-connect-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--success);
  color: #fff;
  border: 2px solid var(--surface);
  box-shadow: var(--sh-xs);
}

.external-connect-card.is-error .external-connect-logo-wrap {
  background: linear-gradient(160deg, var(--surface-2), var(--danger-soft));
  border-color: rgba(179, 38, 30, .2);
}

.external-connect-card.is-error .external-connect-badge {
  background: var(--danger);
}

.modal-title { font-size: 1.02rem; font-weight: 600; color: var(--t1); margin-bottom: 8px; }
.modal-body { font-size: .82rem; color: var(--t3); line-height: 1.6; }
.modal-body strong { color: var(--t1); word-break: break-all; }
.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { min-width: 110px; justify-content: center; }
.modal-actions .btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.modal-actions .btn-danger:hover { background: #99201a; }
.modal-actions .btn:disabled { opacity: .6; cursor: not-allowed; }

/* Three stacked choices (e.g. "delete for real" vs "just hide the record" vs "cancel") read
   as a menu of distinct outcomes; forcing them into one row either crushes the labels or
   makes the riskiest option look identical in weight to the safe ones. */
.modal-actions-stacked { flex-direction: column; align-items: stretch; }
.modal-actions-stacked .btn { width: 100%; min-width: 0; }
.btn-plain { background: none; color: var(--t3); border-color: transparent; }
.btn-plain:hover { background: var(--surface-2); color: var(--t1); }

/* ═══════════════════════════════════════════
   KNOWLEDGE GRAPH VIEW
═══════════════════════════════════════════ */
.kg-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.kg-body { flex: 1; display: flex; min-height: 0; min-width: 0; }

/* The toolbar floats over the canvas rather than inside it: vis-network owns the contents
   of .kg-graph and re-lays them out on every redraw. */
.kg-stage { flex: 1; min-width: 0; position: relative; display: flex; }

/* ── TwymMind investigation filter bar (only while TwymMind KG is active) ── */
.tm-filters {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 3;
}
.tm-filters[hidden] { display: none; }

.tm-filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.tm-filter-label {
  flex-shrink: 0;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--t4);
}

.tm-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.tm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--t2);
  font-family: inherit;
  font-size: .72rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease, opacity .12s ease;
}
.tm-chip:hover { border-color: var(--brass-bd); color: var(--t1); }
.tm-chip.off { opacity: .42; }
.tm-chip .tm-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tm-chip-remove {
  margin: 0 -4px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--t4);
  font-size: .85rem;
  line-height: 1;
  cursor: pointer;
}
.tm-chip-remove:hover { color: var(--t1); }

.tm-chip-shutter {
  padding: 0 11px;
}
.tm-chip-shutter.on {
  background: var(--t1);
  border-color: var(--t1);
  color: #fff;
  opacity: 1;
}

.tm-add-wrap { position: relative; flex-shrink: 0; }

.tm-add-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 99px;
  background: transparent;
  color: var(--t3);
  font-family: inherit;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
}
.tm-add-btn:hover { border-color: var(--brass-bd); color: var(--brass); }

.tm-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 8;
  min-width: 180px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--sh-md);
}
.tm-add-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--t2);
  font-family: inherit;
  font-size: .74rem;
  cursor: pointer;
}
.tm-add-menu button:hover { background: var(--bg); color: var(--t1); }
.tm-add-empty {
  padding: 8px 10px;
  font-size: .72rem;
  color: var(--t4);
}

.tm-filter-row--geo { gap: 10px; }

.tm-select {
  height: 26px;
  min-width: 160px;
  max-width: 240px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--t2);
  font-family: inherit;
  font-size: .72rem;
  font-weight: 500;
  cursor: pointer;
}
.tm-select:hover { border-color: var(--brass-bd); color: var(--t1); }
.tm-select:focus {
  border-color: var(--brass-bd);
  box-shadow: 0 0 0 3px var(--brass-glow);
  outline: none;
}
.tm-select:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.tm-filter-stats {
  font-size: .7rem;
  color: var(--t4);
  padding-top: 2px;
}

.kg-graph {
  flex: 1;
  min-width: 0;
  position: relative;
  background: var(--surface-2);
}

/* ── Graph toolbar: search across the graph, filter what's drawn ── */
.kg-toolbar {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.kg-tool-row { display: flex; align-items: center; gap: 8px; }

/* Sits first (top-right-most) in the toolbar row: the entry point to load every accessible
   node at once instead of the default one-neighbourhood-at-a-time explore view. */
.kg-fullgraph-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  flex-shrink: 0;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--t2);
  font-family: inherit;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--sh-xs);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.kg-fullgraph-btn:hover { color: var(--brass); border-color: var(--brass-bd); }
.kg-fullgraph-btn:disabled { opacity: .6; cursor: default; }
.kg-fullgraph-btn.active {
  background: var(--brass);
  border-color: var(--brass);
  color: #fff;
}
.kg-fullgraph-btn.active:hover { color: #fff; }

.kg-tool-btn {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--t3);
  box-shadow: var(--sh-xs);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.kg-tool-btn:hover { color: var(--brass); border-color: var(--brass-bd); }

.kg-filter-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brass);
  border: 1.5px solid var(--surface);
}

.kg-searchbox {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-xs);
}
.kg-searchbox.open { border-color: var(--brass-bd); box-shadow: 0 0 0 3px var(--brass-glow), var(--sh-xs); }
.kg-searchbox .kg-tool-btn { border: none; box-shadow: none; background: transparent; }

.kg-search-input {
  width: 0;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: .78rem;
  color: var(--t1);
  transition: width .18s ease, padding .18s ease;
}
.kg-search-input::placeholder { color: var(--t4); }
.kg-searchbox.open .kg-search-input { width: 210px; padding: 0 4px 0 2px; }

.kg-search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--t4);
  cursor: pointer;
}
/* Author `display` beats the browser's own [hidden] rule, so it has to be restated. */
.kg-search-clear[hidden] { display: none; }
.kg-search-clear:hover { color: var(--t2); }

.kg-dropdown {
  width: 336px;
  max-height: min(58vh, 460px);
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-md);
}

.kg-dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 7px;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t4);
}

.kg-dropdown-empty {
  padding: 14px 10px;
  font-size: .74rem;
  line-height: 1.55;
  color: var(--t3);
}

.kg-linkbtn {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--brass);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}
.kg-linkbtn:hover { text-decoration: underline; }

/* ── Search results ── */
.kg-result {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.kg-result:hover:not(:disabled) { background: var(--bg); }
.kg-result:disabled { cursor: default; opacity: .6; }

.kg-result-dot {
  width: 11px;
  height: 11px;
  margin-top: 3px;
  flex-shrink: 0;
  border: 2px solid transparent;
}

.kg-result-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kg-result-label {
  font-size: .79rem;
  color: var(--t1);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.kg-result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: .64rem;
  color: var(--t4);
}
.kg-result-meta > span + span::before { content: "·"; margin-right: 6px; color: var(--border-strong); }
.kg-result-kind {
  color: var(--brass);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.kg-result-warn { color: var(--brass); }

/* ── Filters ── */
.kg-filter-group { padding-bottom: 4px; }
.kg-filter-group + .kg-filter-group { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }

.kg-filter-title {
  padding: 4px 8px 6px;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t4);
}

.kg-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.kg-filter-row:hover { background: var(--bg); }
.kg-filter-row.off .kg-filter-name,
.kg-filter-row.off .kg-filter-count { color: var(--t4); text-decoration: line-through; }
.kg-filter-row.off .kg-filter-swatch,
.kg-filter-row.off .kg-filter-rel { opacity: .35; }

.kg-filter-check {
  width: 12px;
  flex-shrink: 0;
  color: var(--brass);
  font-size: .7rem;
  line-height: 1;
}
.kg-filter-swatch { width: 11px; height: 11px; flex-shrink: 0; border: 2px solid transparent; }
.kg-filter-rel { width: 11px; height: 2px; flex-shrink: 0; background: #aab2bf; border-radius: 2px; }

.kg-filter-name {
  flex: 1;
  min-width: 0;
  font-size: .76rem;
  color: var(--t2);
  overflow-wrap: anywhere;
}
.kg-filter-count {
  font-size: .64rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--t4);
}

.kg-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-size: .82rem;
  color: var(--t4);
  pointer-events: none;
}

.kg-panel {
  width: 310px;
  min-width: 310px;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kg-panel-header {
  padding: 16px 18px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.kg-panel-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: .95rem;
  font-weight: 600;
  color: var(--t1);
  word-break: break-word;
  margin: 0 0 6px;
  line-height: 1.4;
}

.kg-panel-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border: 1px solid var(--border-strong);
  color: var(--t3);
  background: var(--bg-2);
}

.kg-panel-body { flex: 1; overflow-y: auto; padding: 16px 18px; }

.kg-section { margin-bottom: 20px; }
.kg-section h3 {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--t4);
  margin: 0 0 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
}

.kg-kv { display: flex; flex-direction: column; margin-bottom: 10px; }
.kg-kv-key { font-size: .62rem; color: var(--t4); font-weight: 600; text-transform: capitalize; margin-bottom: 2px; }
.kg-kv-val { font-size: .78rem; color: var(--t2); word-break: break-word; line-height: 1.5; }

.kg-doc-chip {
  display: inline-block;
  font-size: .68rem;
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  color: var(--brass);
  padding: 4px 10px;
  border-radius: var(--r-xs);
  word-break: break-word;
  font-weight: 500;
}

.kg-neighbors { list-style: none; margin: 0; padding: 0; }
.kg-neighbors li {
  font-size: .74rem;
  color: var(--t3);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}
.kg-neighbors li:hover { color: var(--brass); }
.kg-neighbors .kg-neighbor-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.kg-legend-item { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.kg-legend-dot { width: 13px; height: 13px; flex-shrink: 0; border: 2px solid transparent; }
.kg-legend-label { font-size: .78rem; color: var(--t2); }

.kg-stat {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--t2);
}
.kg-stat span:last-child { color: var(--brass); font-weight: 600; }

.kg-hint { font-size: .68rem; color: var(--t4); margin-top: 14px; line-height: 1.5; }

.kg-wrap--twymmind .kg-panel {
  width: 340px;
  min-width: 340px;
}

.tm-panel-summary {
  margin: 0 0 16px;
  font-size: .8rem;
  line-height: 1.55;
  color: var(--t2);
}

.tm-risk {
  margin-bottom: 18px;
  padding: 10px 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.tm-risk-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.tm-risk-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--t4);
}
.tm-risk-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: .92rem;
  font-weight: 600;
  color: var(--t1);
}
.tm-risk-bar {
  height: 4px;
  border-radius: 99px;
  background: var(--bg-2);
  overflow: hidden;
}
.tm-risk-bar span {
  display: block;
  height: 100%;
  background: var(--brass);
}
.tm-risk-high .tm-risk-score { color: var(--danger); }
.tm-risk-high .tm-risk-bar span { background: var(--danger); }
.tm-risk-mid .tm-risk-score { color: var(--brass); }
.tm-risk-note {
  margin: 7px 0 0;
  font-size: .62rem;
  line-height: 1.4;
  color: var(--t4);
}

.tm-panel-list { display: flex; flex-direction: column; }

.tm-rel-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.tm-rel-row:hover .tm-rel-name { color: var(--brass); }
.tm-rel-name { font-size: .8rem; font-weight: 600; color: var(--t1); }
.tm-rel-type { font-size: .68rem; color: var(--t3); }

.tm-doc-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.tm-doc-name { font-size: .78rem; font-weight: 600; color: var(--t1); word-break: break-word; }
.tm-doc-kind {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--t3);
}
.tm-doc-date { font-size: .68rem; color: var(--t4); }

.tm-source-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.tm-source-name { font-size: .74rem; color: var(--t2); }
.tm-source-detail { font-size: .68rem; color: var(--t4); word-break: break-word; }

/* ═══════════════════════════════════════════
   INGESTION VIEW
   ═══════════════════════════════════════════ */

.ingestion-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Step tabs ── */
.ingestion-steps {
  display: flex;
  align-items: center;
  padding: 20px 28px 0;
  gap: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.ingestion-step-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--t3);
  font-size: .82rem;
  font-weight: 500;
  font-family: inherit;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}

.ingestion-step-btn:hover { color: var(--t1); }
.ingestion-step-btn.active { color: var(--t1); border-bottom-color: var(--brass); }

.ingestion-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: .67rem;
  font-weight: 700;
  color: var(--t3);
  flex-shrink: 0;
}
.ingestion-step-btn.active .ingestion-step-num {
  background: var(--brass);
  border-color: var(--brass);
  color: #fff;
}

.ingestion-step-label { font-weight: 600; }

.ingestion-step-status {
  font-size: .65rem;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  background: var(--bg-2);
  color: var(--t4);
  font-weight: 500;
}
.ingestion-step-status.status-approved {
  background: var(--success-soft);
  color: var(--success);
}
.ingestion-step-status.status-draft {
  background: var(--brass-lt);
  color: var(--brass);
}

.ingestion-step-connector {
  width: 24px;
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Tab content ── */
.ingestion-tab {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ── Choose state ── */
.ontology-choose-header {
  margin-bottom: 28px;
}
.ontology-choose-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0 0 6px;
  font-family: 'Fraunces', Georgia, serif;
  letter-spacing: -.02em;
}
.ontology-choose-desc {
  font-size: .82rem;
  font-family: inherit;
  color: var(--t3);
  margin: 0;
  max-width: 520px;
  line-height: 1.6;
}

.ontology-choice-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 680px;
}

.ontology-choice-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px 24px 22px;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s, transform .1s;
  position: relative;
}
.ontology-choice-card:hover {
  border-color: var(--brass-bd);
  box-shadow: var(--sh-md), 0 0 0 3px var(--brass-glow);
  transform: translateY(-1px);
}

.ontology-choice-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brass-lt);
  border-radius: var(--r-md);
  color: var(--brass);
  margin-bottom: 14px;
}

.ontology-choice-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0 0 6px;
}
.ontology-choice-body {
  font-size: .78rem;
  color: var(--t3);
  line-height: 1.5;
  margin: 0 0 14px;
}
.ontology-choice-tag {
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: var(--r-xs);
  background: var(--brass-lt);
  color: var(--brass);
}

.ontology-choose-section-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--t4);
  margin: 8px 0 10px;
}

.ontology-template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 760px;
  margin-bottom: 22px;
}

.ontology-template-card .ontology-choice-body {
  margin-bottom: 10px;
}

.ontology-template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.ontology-template-chip {
  font-size: .65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--t2);
  border: 1px solid var(--border);
}

.ontology-template-banner {
  font-size: .82rem;
  color: var(--t2);
  line-height: 1.5;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  border-radius: var(--r-md);
}
.ontology-template-banner strong {
  color: var(--t1);
}

/* ── Editor state ── */
.ontology-editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.ontology-editor-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0 0 4px;
  font-family: 'Fraunces', Georgia, serif;
  letter-spacing: -.02em;
}
.ontology-editor-desc {
  font-size: .82rem;
  font-family: inherit;
  color: var(--t3);
  margin: 0;
  line-height: 1.6;
}

.ontology-mode-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 18px;
}
.ontology-mode-label {
  font-size: .82rem;
  color: var(--t2);
  font-weight: 500;
  flex: 1;
}

.toggle-label { display: flex; align-items: center; gap: 0; cursor: pointer; }
.toggle-label input[type="checkbox"] { display: none; }
.toggle-track {
  width: 34px;
  height: 18px;
  background: var(--border-strong);
  border-radius: 99px;
  position: relative;
  transition: background .2s;
}
.toggle-track::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-label input:checked + .toggle-track { background: var(--brass); }
.toggle-label input:checked + .toggle-track::after { transform: translateX(16px); }

.ontology-generate-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}
.ontology-domain-input {
  flex: 1;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .82rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--t1);
  outline: none;
  transition: border-color .15s;
}
.ontology-domain-input:focus { border-color: var(--brass-bd); }
.ontology-domain-input::placeholder { color: var(--t4); }

.ontology-two-col,
.ontology-approved-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.ontology-section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
}
.ontology-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.ontology-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0;
}
.ontology-section-hint {
  font-size: .65rem;
  color: var(--t4);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Tag list ── */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  margin-bottom: 12px;
}
.tag-list-readonly .tag-chip { cursor: default; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 500;
  color: var(--brass);
  font-family: 'JetBrains Mono', monospace;
}

.tag-chip-remove {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--brass);
  font-size: .9rem;
  line-height: 1;
  opacity: .6;
  transition: opacity .15s;
}
.tag-chip-remove:hover { opacity: 1; }

.tag-empty {
  font-size: .74rem;
  color: var(--t4);
  font-style: italic;
  align-self: center;
}

.tag-input-row {
  display: flex;
  gap: 6px;
}
.tag-input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  font-size: .8rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--t1);
  outline: none;
  transition: border-color .15s;
}
.tag-input:focus { border-color: var(--brass-bd); }
.tag-input::placeholder { color: var(--t4); }

/* ── Editor actions ── */
.ontology-editor-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

/* ── Approved state ── */
.ontology-approved-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--success-soft);
  border: 1px solid rgba(46, 125, 74, .18);
  border-radius: var(--r-sm);
  font-size: .8rem;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 20px;
}
.ontology-approved-mode {
  margin-left: auto;
  font-size: .68rem;
  font-weight: 500;
  padding: 2px 8px;
  background: rgba(46, 125, 74, .1);
  border-radius: var(--r-xs);
  color: var(--success);
  text-transform: capitalize;
}
.ontology-approved-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

/* ── Sync tab ── */
.ingestion-sync-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.ingestion-sync-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0 0 4px;
  font-family: 'Fraunces', Georgia, serif;
  letter-spacing: -.02em;
}
.ingestion-sync-desc {
  font-size: .82rem;
  font-family: inherit;
  color: var(--t3);
  margin: 0;
  line-height: 1.6;
}

.ingestion-sync-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  border-radius: var(--r-sm);
  font-size: .78rem;
  color: var(--brass);
  margin-bottom: 18px;
}
.ingestion-sync-warning .btn-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--brass);
  font-weight: 600;
  font-size: inherit;
  text-decoration: underline;
}

.ingestion-source-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.source-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--t3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color .14s ease, color .14s ease, background .14s ease;
}
.source-toggle-btn:hover { border-color: var(--brass-bd); color: var(--t1); }
.source-toggle-btn.active {
  background: var(--brass-lt);
  border-color: var(--brass-bd);
  color: var(--brass);
}
.source-toggle-btn img { display: block; }

.ingestion-site-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ingestion-site-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.ingestion-site-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 160px;
}
.ingestion-site-name {
  font-size: .85rem;
  font-weight: 600;
  color: var(--t1);
}
/* Everything numeric about one source, in a fixed-width column so the figures form a
   readable vertical line down the list instead of drifting with each source's name. */
.sync-stat {
  width: 210px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  /* Rows that were never synced drop the meter and the detail line, so reserve the full
     three-line height to keep every card in the list the same size. */
  min-height: 46px;
}

.sync-stat-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.sync-stat-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: .8rem;
  font-weight: 600;
  color: var(--t1);
  /* Counters tick upward on every poll; tabular figures keep them from jittering. */
  font-variant-numeric: tabular-nums;
}

.sync-stat-label {
  font-size: .7rem;
  color: var(--t3);
}

.sync-stat-note {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: .66rem;
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}

.sync-meter {
  height: 4px;
  border-radius: 99px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.sync-meter-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--brass);
  transition: width .6s ease;
}

/* Progress messages carry a filename, so clamp to one line and keep the full text in the
   title attribute rather than letting a long name reflow the whole row. */
.sync-stat-detail {
  font-size: .68rem;
  color: var(--t3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-stat.is-complete .sync-meter-fill { background: var(--success); }
.sync-stat.is-error .sync-stat-detail { color: var(--danger); }
.sync-stat.is-error .sync-meter-fill { background: var(--danger); }
.sync-stat.is-muted .sync-stat-count,
.sync-stat.is-muted .sync-stat-label { color: var(--t4); }
.sync-stat.is-muted .sync-meter { opacity: .5; }

/* Fixed so buttons of different widths (Sync now / Re-sync / Stop) share a right edge. */
.ingestion-site-actions {
  margin-left: auto;
  min-width: 92px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 720px) {
  .sync-stat { width: 100%; }
  .ingestion-site-actions { margin-left: 0; }
}

/* Fixed-width label+select so the dropdown doesn't grow/shrink with the branch name and
   every row's stat block starts at the same x position. */
.ingestion-branch-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  width: 180px;
}
.ingestion-branch-group .repo-branch-select {
  flex: 1;
  min-width: 0;
  max-width: none;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.ingestion-sync-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--t3);
}
.ingestion-sync-empty p { margin: 0; font-size: .83rem; }
.ingestion-sync-empty svg { opacity: .35; }

.ingestion-loading {
  font-size: .82rem;
  color: var(--t4);
  padding: 24px 0;
}

.form-error {
  font-size: .82rem;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(179, 38, 30, .15);
  border-radius: var(--r-xs);
  padding: 8px 12px;
  margin-bottom: 4px;
}

.ingestion-sync-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Manual upload modal ── */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 28px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-2);
  color: var(--t3);
  transition: border-color .14s ease, background .14s ease;
}
.upload-dropzone.is-dragover {
  border-color: var(--brass);
  background: var(--brass-lt);
  color: var(--brass);
}
.upload-dropzone-text {
  margin: 0;
  font-size: .84rem;
  font-weight: 600;
  color: var(--t1);
}
.upload-dropzone-actions {
  display: flex;
  gap: 8px;
  margin: 4px 0;
}
.upload-dropzone-actions label { cursor: pointer; }
.upload-dropzone-hint {
  margin: 0;
  font-size: .72rem;
  color: var(--t4);
  max-width: 340px;
}

.upload-file-list {
  margin-top: 14px;
}
.upload-file-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .76rem;
  color: var(--t3);
  margin-bottom: 8px;
}
.upload-file-list-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px;
  background: var(--surface);
}
.upload-file-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--r-xs);
}
.upload-file-list-item:hover { background: var(--bg-2); }
.upload-file-name {
  flex: 1;
  min-width: 0;
  font-size: .76rem;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'JetBrains Mono', monospace;
}
.upload-file-size {
  font-size: .68rem;
  color: var(--t4);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.upload-file-remove {
  border: none;
  background: none;
  color: var(--t4);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}
.upload-file-remove:hover { color: var(--danger); }
.upload-file-list-more {
  font-size: .72rem;
  color: var(--t4);
  text-align: center;
  padding: 4px 0 2px;
}

.upload-progress-wrap {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upload-progress-label {
  font-size: .74rem;
  color: var(--t3);
  text-align: center;
}

.upload-modal-actions {
  justify-content: space-between;
  align-items: center;
}
.upload-modal-actions .btn { min-width: 0; }
.upload-modal-actions-right {
  display: flex;
  gap: 10px;
}
#uploadDataAngleBtn.active {
  border-color: var(--brass);
  box-shadow: 0 0 0 3px var(--brass-glow);
}

.upload-angle-summary {
  margin-top: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--brass-lt);
  border: 1px solid var(--brass-bd);
  border-radius: var(--r-sm);
}
.upload-angle-summary[hidden] { display: none; }
.upload-angle-summary-text {
  min-width: 0;
  font-size: .76rem;
  color: var(--t2);
  line-height: 1.45;
}
.upload-angle-summary-text strong {
  color: var(--t1);
  font-weight: 650;
}
.upload-angle-summary-meta {
  display: block;
  margin-top: 2px;
  font-size: .7rem;
  color: var(--t3);
}
.upload-angle-summary-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.angle-focus-list {
  min-height: 0;
  margin-bottom: 8px;
}
.angle-focus-list:empty {
  display: none;
}
.angle-focus-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.angle-focus-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--t4);
  pointer-events: none;
}
.angle-focus-wrap input {
  width: 100%;
  padding-left: 32px;
}

.angle-themes-hint {
  margin: 0 0 8px;
  font-size: .72rem;
  font-weight: 400;
  color: var(--t4);
  line-height: 1.4;
}

.angle-theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.angle-theme-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.angle-theme-card:hover {
  border-color: var(--brass-bd);
  background: var(--surface-2);
}
.angle-theme-card.is-checked {
  border-color: var(--brass-bd);
  background: var(--brass-lt);
  box-shadow: 0 0 0 1px var(--brass-bd);
}
.angle-theme-card input {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--brass);
}
.angle-theme-card-copy {
  min-width: 0;
}
.angle-theme-card-title {
  display: block;
  font-size: .76rem;
  font-weight: 650;
  color: var(--t1);
  line-height: 1.3;
}
.angle-theme-card-desc {
  display: block;
  margin-top: 3px;
  font-size: .68rem;
  font-weight: 400;
  color: var(--t3);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .angle-theme-grid { grid-template-columns: 1fr; }
}

/* Upload batches reuse .ingestion-site-item rows; no source-specific overrides needed. */
