/* Amphora Knowledge admin console — minimal CSS.
 *
 * No SLDS, no framework. A future Phase F can swap this out for the
 * platform's LWC OSS + SLDS bundle; this stylesheet only has to be
 * good enough to read on a desktop browser by an internal operator.
 */

:root {
  --bg: #141414;
  --bg-raised: #181f26;
  --bg-input: #0b0f13;
  --border: #2a333d;
  --text: #e6edf3;
  --text-muted: #8b96a3;
  --primary: #c2642c;
  --primary-hover: #a34f1e;
  --success: #2ea24f;
  --danger: #c23934;
  --warning: #d4a017;
  --code-bg: #11161b;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
.muted { color: var(--text-muted); }

/* ─── Top bar ─────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  height: 56px;
}

.topbar-brand {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-logo {
  width: 28px;
  height: 28px;
  display: block;
  border-radius: 4px;
}

.topbar-tabs {
  display: flex;
  gap: 0.25rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border-radius: 4px;
  font-family: inherit;
  transition: color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab-btn.active { color: var(--primary); background: rgba(194, 100, 44, 0.1); }

.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.who { font-size: 0.8125rem; color: var(--text-muted); }

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.375rem 0.875rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.04); }

/* ─── Operator view-as-tenant ─────────────────────────── */

.tenant-switch {
  background: var(--surface, #1a1a1a);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.375rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  max-width: 16rem;
}
.tenant-switch[hidden] { display: none; }

/* Warning banner while impersonating — yellow (intentional action, not
   an error), matching the platform's impersonation banner. */
.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--amphora-warning-bg, #fef3cd);
  color: #856404;
  border-bottom: 1px solid #f0d98a;
  font-size: 0.8125rem;
}
.impersonation-banner[hidden] { display: none; }
.impersonation-text strong { font-weight: 600; }
.impersonation-exit {
  background: transparent;
  border: none;
  color: #856404;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 0;
}
.impersonation-exit:hover { color: #5c4503; }

/* ─── Main content ────────────────────────────────────── */

.content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.section-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.section-desc { color: var(--text-muted); margin: 0 0 1.25rem; }

/* ─── Card / table styling ────────────────────────────── */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--bg-raised);
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

/* Sortable column headers: pointer affordance + hover + active glyph. */
thead th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th.sortable:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
thead th.sortable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
thead th .sort-indicator {
  font-size: 0.7rem;
  opacity: 0.85;
}

tbody td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody td.wrap {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ─── Toggle (visibility column) ──────────────────────── */

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track {
  width: 2.75rem;
  height: 1.4rem;
  background: var(--text-muted);
  border-radius: 1rem;
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}
.toggle .track::after {
  content: '';
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  background: #fff;
  border-radius: 50%;
  top: 0.15rem;
  left: 0.15rem;
  transition: transform 0.15s;
}
.toggle input:checked ~ .track { background: var(--success); }
.toggle input:checked ~ .track::after { transform: translateX(1.35rem); }
.toggle input:disabled ~ .track { opacity: 0.5; cursor: not-allowed; }
.toggle .label { font-size: 0.8125rem; color: var(--text-muted); }
.toggle input:checked ~ .label { color: var(--success); }

/* ─── Filters / inputs ────────────────────────────────── */

.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }

.text-input, select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  min-width: 240px;
}
.text-input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--primary-hover); }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.04); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #962d29; }

/* ─── Status pills ────────────────────────────────────── */

.pill {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.pill-public { background: rgba(46, 162, 79, 0.15); color: var(--success); border-color: rgba(46, 162, 79, 0.4); }
.pill-private { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border-color: var(--border); }
.pill-mixed { background: rgba(212, 160, 23, 0.15); color: var(--warning); border-color: rgba(212, 160, 23, 0.4); }
.pill-running { background: rgba(0, 112, 210, 0.15); color: #4fa8ff; border-color: rgba(0, 112, 210, 0.4); }
.pill-succeeded { background: rgba(46, 162, 79, 0.15); color: var(--success); border-color: rgba(46, 162, 79, 0.4); }
.pill-failed { background: rgba(194, 57, 52, 0.15); color: var(--danger); border-color: rgba(194, 57, 52, 0.4); }
.pill-active { background: rgba(46, 162, 79, 0.15); color: var(--success); border-color: rgba(46, 162, 79, 0.4); }
.pill-revoked { background: rgba(194, 57, 52, 0.15); color: var(--danger); border-color: rgba(194, 57, 52, 0.4); }
.pill-expired { background: rgba(212, 160, 23, 0.15); color: var(--warning); border-color: rgba(212, 160, 23, 0.4); }

/* ─── Footer ──────────────────────────────────────────── */

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Login page ──────────────────────────────────────── */

.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.login-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
}
.login-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0.75rem 0 0.25rem;
}
.login-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.625rem 0.75rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}
.login-input:focus { outline: none; border-color: var(--primary); }
.login-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.login-btn:hover { background: var(--primary-hover); }
.login-status { margin-top: 0.75rem; min-height: 1.25rem; }
.login-fineprint { margin-top: 1rem; font-size: 0.75rem; }

/* ─── Expand caret + chunk drilldown ──────────────────── */

.expand-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1;
  /* Black-triangle glyphs (U+25B6 / U+25BC) carry visual weight
     toward the closed side of the arrow — without a tiny vertical
     nudge the down-pointing form looks cropped at the top. */
  padding: 0 0 1px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}
.expand-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.expand-btn[aria-expanded='true'] { color: var(--primary); border-color: var(--primary); }

.chunks-row td.chunks-cell {
  background: var(--bg);
  padding: 0.75rem 0.75rem 0.75rem 0;
  white-space: normal;
  overflow: visible;
}

.chunks-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.chunk-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}

.chunk-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
}

.chunk-card-index {
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.65rem;
}

.chunk-card-heading {
  font-weight: 600;
  color: var(--text);
}

.chunk-card-meta {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.chunk-card-preview {
  margin: 0;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text);
  background: transparent;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 14em;
  overflow-y: auto;
}

/* ─── Modal (import dialog) ───────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.25rem;
}

.modal-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
}

.modal-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0.75rem 0 0.25rem;
}

.modal-file {
  width: 100%;
  padding: 0.5rem;
  background: var(--bg-input);
  border: 1px dashed var(--border);
  color: var(--text);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8125rem;
}

.modal-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Import progress panel — phase rows match the platform's
   Settings → Admin → Import References UX. Each row shows
   pending / running / done / failed via icon + color. */
.import-progress {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.import-phase {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.import-phase-icon {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9rem;
  width: 1.1rem;
  text-align: center;
  color: var(--text-muted);
}
.import-phase-label { flex: 1; }
.import-phase-detail {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.import-phase.current { color: var(--text); }
.import-phase.current .import-phase-icon { color: var(--primary); }
.import-phase.done { color: var(--text); }
.import-phase.done .import-phase-icon { color: var(--success); }
.import-phase.failed { color: var(--danger); }
.import-phase.failed .import-phase-icon { color: var(--danger); }

/* ─── Licenses table + usage drill-down ──────────────── */

.licenses-table th.num,
.licenses-table td.num,
.usage-table th.num,
.usage-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.usage-row td {
  background: var(--bg);
  padding: 0.5rem 0.75rem 0.75rem 0;
  white-space: normal;
  overflow: visible;
}

/* The 400px cap is the spec from the user request — anything taller
   should scroll within this container, not push the page. */
.usage-scroll {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.usage-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-input);
  z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.usage-table tbody td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.usage-table tbody tr:last-child td { border-bottom: 0; }
.usage-table td.wrap { word-break: break-word; }

/* Query cell: queries can be long. Cap each cell at ~3 lines so a
   single pasted prompt doesn't push every other row off-screen.
   Hover surface = the full query as a tooltip on the inner code. */
.usage-table td.query-cell {
  vertical-align: top;
  max-width: 0; /* with table-layout:auto + col widths above, lets
                    width be controlled by the colgroup flex col. */
}
.usage-table td.query-cell code {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
  background: transparent;
  padding: 0;
  font-size: 0.78125rem;
  color: var(--text);
}

/* ─── Misc ────────────────────────────────────────────── */
code, pre {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  background: var(--code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}
.error { color: var(--danger); }
.empty { color: var(--text-muted); padding: 2rem; text-align: center; }

/* ─── Users tab ─────────────────────────────────────────────── */

.user-add { margin: 0.75rem 0; }
.user-list .data-table th { text-align: left; padding: 0.5rem 0.75rem; font-weight: 600; }
.user-list .data-table td { padding: 0.5rem 0.75rem; border-top: 1px solid rgba(255,255,255,0.08); vertical-align: middle; }
.user-list .pill { cursor: pointer; border: 0; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.85rem; }
.user-list .pill-active { background: rgba(0, 255, 100, 0.15); color: #7eff7e; }
.user-list .pill-revoked { background: rgba(255, 80, 80, 0.15); color: #ff8a8a; }
.user-list .link-btn { background: transparent; border: 0; color: #ff9f1c; cursor: pointer; padding: 0; }

.user-form { background: rgba(255,255,255,0.04); padding: 0.75rem 1rem; border-radius: 6px; margin: 0.75rem 0; }
.user-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 0.5rem 0; }
.user-form-row label { display: flex; flex-direction: column; font-size: 0.85rem; }
.user-form-row input, .user-form-row select { margin-top: 0.25rem; padding: 0.35rem 0.5rem; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; }
.user-form-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; align-items: center; }
.user-form .error { color: #ff8a8a; margin: 0.5rem 0 0; font-size: 0.85rem; }

/* ─── Knowledge Graph tab ───────────────────────────────────── */

.kg-tab .kg-status { margin-bottom: 0.5rem; }
.kg-banner { background: rgba(255, 159, 28, 0.12); border: 1px solid rgba(255, 159, 28, 0.4); padding: 0.65rem 0.85rem; border-radius: 6px; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.kg-banner strong { flex: 1 1 100%; }
.kg-banner-help { flex: 1 1 100%; margin: 0; font-size: 0.85rem; color: rgba(255, 255, 255, 0.75); }
.kg-info { color: #7ed8ff; margin: 0.25rem 0; }

/* Connected variant — discreet green-tinted line so the user always
   has a visible escape hatch to re-auth. Used when OAuth is healthy
   but tokens might be stale (no refresh_token field on legacy rows). */
.kg-banner-ok {
  background: rgba(46, 162, 79, 0.10);
  border-color: rgba(46, 162, 79, 0.35);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  padding: 0.45rem 0.85rem;
}
.kg-banner-ok span { flex: 1; }

.kg-link-btn {
  background: transparent;
  border: 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
}
.kg-link-btn:hover { color: var(--primary-hover); }
.kg-toolbar { display: flex; gap: 0.75rem; align-items: center; margin: 0.5rem 0 0.75rem; }
.kg-meta { color: rgba(255,255,255,0.6); font-size: 0.85rem; }
/* Header row — title + subtitle on the left, refresh button on the
   right. Mirrors the platform's knowledgeGraphPanel header layout
   (Tenant Knowledge Graph / Refresh graph). */
.kg-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.75rem;
}
.kg-header-title h2 { margin: 0 0 0.15rem; }
.kg-header-sub { margin: 0; color: rgba(255,255,255,0.55); font-size: 0.85rem; }
.kg-header-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Canvas toolbar — Edge slider + zoom in/out + reset + stats.
   Sits between the header and the canvas, matching the platform's
   knowledgeGraphPanel toolbar row. */
.kg-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0 0.5rem;
}
.kg-edge-control { display: flex; align-items: center; gap: 0.5rem; }
.kg-edge-label { font-size: 0.85rem; color: rgba(255,255,255,0.7); }
.kg-edge-control input[type="range"] { width: 160px; }
.kg-canvas-btns { display: flex; gap: 0.35rem; }
.kg-icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.kg-icon-btn:hover { background: rgba(255,255,255,0.06); }
.kg-icon-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.kg-stats { margin-left: auto; color: rgba(255,255,255,0.55); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* Layout — capped canvas height so settings card below stays
   above the fold on a typical 1080p viewport. clamp() so the
   canvas adapts to tall displays without stretching beyond a
   comfortable workspace. */
.kg-layout {
  display: grid;
  /* Suggestions panel widened 33% (380px → 505px) so draft frontmatter
     + body previews wrap less; the graph canvas (1fr) absorbs the rest. */
  grid-template-columns: 1fr 505px;
  gap: 1rem;
  height: clamp(420px, 60vh, 720px);
}
.kg-canvas-host {
  /* Use the page bg variable so the canvas blends with the rest of
     the console — currently #141414, kept in lock-step. */
  background: var(--bg);
  border-radius: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.kg-suggestions {
  overflow-y: auto;
  height: 100%;
  min-height: 0;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
}
.kg-suggestions h3 { margin: 0 0 0.5rem; }

/* Node detail card — shown in the aside when a node is clicked.
   Mirrors the platform's knowledgeGraphPanel node-card layout:
   source/tier badge, Frontmatter section (definition list),
   Body section (monospace). */
.kg-node-card { display: flex; flex-direction: column; gap: 0.85rem; }
/* The `display: flex` above beats the UA [hidden] rule, so without this
   the empty node-detail card leaks in below the suggestions list (and
   the × close button appears to do nothing). Let the hidden attribute
   win so the card only shows once a node is selected. */
.kg-node-card[hidden] { display: none; }
.kg-node-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 0;
  padding: 0;
  margin: 0;
}
.kg-node-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(0, 187, 249, 0.18);
  color: #7ed8ff;
  border: 1px solid rgba(0, 187, 249, 0.35);
}
.kg-node-section { margin: 0; }
.kg-node-section-label {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
}
.kg-node-card-meta {
  display: grid;
  grid-template-columns: minmax(80px, max-content) 1fr;
  gap: 0.3rem 0.85rem;
  margin: 0;
  padding: 0.6rem 0.75rem;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  font-size: 0.85rem;
}
.kg-node-card-meta dt { color: rgba(255,255,255,0.55); margin: 0; }
.kg-node-card-meta dd { margin: 0; word-break: break-word; }
.kg-node-card-body {
  margin: 0;
  padding: 0.6rem 0.75rem;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
}
.kg-suggestion { background: rgba(255,255,255,0.04); border-radius: 6px; padding: 0.65rem 0.85rem; margin-bottom: 0.5rem; }
.kg-suggestion header { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; }
.kg-suggestion .kg-severity { margin-left: auto; color: rgba(255,255,255,0.5); font-size: 0.8rem; }
.kg-suggestion-desc { margin: 0.2rem 0; font-size: 0.9rem; color: rgba(255,255,255,0.85); }
.kg-suggestion details { margin: 0.4rem 0; }
.kg-suggestion summary { cursor: pointer; font-size: 0.85rem; color: rgba(255,255,255,0.6); }
.kg-suggestion .kg-draft-body { white-space: pre-wrap; word-break: break-word; background: rgba(0,0,0,0.3); padding: 0.5rem; border-radius: 4px; font-size: 0.8rem; max-height: 240px; overflow-y: auto; }
.kg-suggestion footer { margin-top: 0.4rem; display: flex; gap: 0.5rem; }
.kg-suggestion .pill { padding: 0.1rem 0.45rem; font-size: 0.75rem; border-radius: 999px; }
.kg-suggestion .pill-structural { background: rgba(155, 93, 229, 0.2); color: #c8a8ff; }
.kg-suggestion .pill-orphan { background: rgba(255, 159, 28, 0.2); color: #ffc888; }
.kg-suggestion .pill-demand { background: rgba(0, 187, 249, 0.2); color: #7ed8ff; }

/* ── Suggestions panel parity (Select-all + bulk bar + cards) ─────── */
.kg-sug-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; min-height: 1.9rem; }
.kg-sug-selectall { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: rgba(255,255,255,0.8); cursor: pointer; }
.kg-sug-bulk { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.kg-sug-bulk-count { font-size: 0.8rem; color: rgba(255,255,255,0.55); }
.kg-sug-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; }
.kg-sug-check { flex: 0 0 auto; }
.kg-sug-title { font-size: 0.95rem; }
.kg-sug-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; justify-content: flex-end; }
/* Buttons — match the platform's neutral / destructive / brand trio. */
.kg-btn { padding: 0.3rem 0.75rem; font-size: 0.82rem; border-radius: 5px; border: 1px solid transparent; cursor: pointer; line-height: 1.1; }
.kg-btn-neutral { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.18); color: rgba(255,255,255,0.9); }
.kg-btn-neutral:hover { background: rgba(255,255,255,0.14); }
.kg-btn-danger { background: #c0392b; color: #fff; }
.kg-btn-danger:hover { background: #d4493a; }
.kg-btn-brand { background: var(--primary, #e8743b); color: #fff; }
.kg-btn-brand:hover { filter: brightness(1.08); }
.kg-sug-preview { margin-top: 0.6rem; padding: 0.6rem 0.7rem; background: rgba(0,0,0,0.25); border-radius: 6px; }
.kg-sug-preview-label { margin: 0 0 0.35rem; font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(255,255,255,0.55); }
.kg-sug-preview .kg-sug-fm { margin: 0 0 0.6rem; display: grid; grid-template-columns: minmax(70px, max-content) 1fr; gap: 0.15rem 0.6rem; font-size: 0.82rem; }
.kg-sug-preview .kg-sug-fm dt { color: rgba(255,255,255,0.55); }
.kg-sug-preview .kg-sug-fm dd { margin: 0; color: rgba(255,255,255,0.9); }

.kg-settings-card { margin-top: 1rem; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; }
.kg-settings-header { margin-bottom: 0.75rem; }
.kg-settings-header h3 { margin: 0 0 0.25rem; }
.kg-settings-desc { margin: 0; color: rgba(255,255,255,0.6); font-size: 0.85rem; }
.kg-settings-body { font-size: 0.9rem; }
.kg-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem 1.5rem; }
.kg-setting { display: flex; flex-direction: column; gap: 0.35rem; }
.kg-setting-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.kg-setting-label { font-weight: 500; }
.kg-setting-value { font-variant-numeric: tabular-nums; color: #ffc888; font-size: 0.9rem; }
.kg-setting input[type="range"] { width: 100%; }
.kg-setting-hint { color: rgba(255,255,255,0.55); font-size: 0.8rem; }
.kg-settings-status { margin: 0.6rem 0 0; font-size: 0.8rem; color: rgba(255,255,255,0.6); min-height: 1.1em; }

/* ─── Modal (Claude OAuth + future flows) ───────────────────
   Vanilla port of the .modal-* family from the Amphora platform's
   userSettings.css so the Connect Claude UX matches. */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 10px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  border: 1px solid var(--border);
}
.modal-header {
  padding: 14px 20px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}
.modal-header-brand { background: var(--primary); }
.modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: #fff; }

.modal-body {
  padding: 20px;
  font-size: 14px;
  line-height: 1.55;
}
.modal-help {
  margin: 0 0 12px;
  color: var(--text-muted);
}
.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.modal-field input {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.modal-field input:focus {
  outline: none;
  border-color: var(--primary);
}
.modal-error {
  color: #ff8a8a;
  margin: 10px 0 0;
  font-size: 13px;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg);
}
.modal-btn {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.modal-btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.modal-btn-cancel:hover { background: var(--bg-raised); }
.modal-btn-brand {
  background: var(--primary);
  color: #fff;
}
.modal-btn-brand:hover { background: var(--primary-hover); }
.modal-btn:disabled { opacity: 0.7; cursor: not-allowed; }

/* ─── Row action icons (users + licenses) ─────────────────────────── */
/* The action-icon cell holds buttons, not text — the `text-overflow: ellipsis`
   inherited from `tbody td` renders the overflow indicator as stray ".." dots
   after the buttons. Opt THIS cell out of the truncation (the data columns keep
   their ellipsis for long values like license keys / emails). */
tbody td:has(.row-actions) {
  overflow: visible;
  text-overflow: clip;
}
.row-actions {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-muted); }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.icon-btn.go:hover { color: var(--success); border-color: var(--success); }
.icon-btn.warn:hover { color: var(--warning); border-color: var(--warning); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn svg { display: block; }

/* ─── Provisioned-key one-time reveal ─────────────────────────────── */
.key-reveal-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0 0.75rem;
}
.key-reveal-value {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  user-select: all;
  word-break: break-all;
}
