/* Theme: HashiCorp Helios (soft-dark adaptation).
 * Token hex values from github.com/hashicorp/design-system. */
@import url("https://fonts.googleapis.com/css2?family=Iosevka:wght@400;600&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

:root {
  --bg: #14151a;
  --bg-elevated: #1c1d24;
  --bg-hover: #252731;
  --border: var(--tint-3);

  --text: #e8e9ed;
  --text-muted: #9aa0ac;
  --text-dim: #656a76;

  --accent: #bb8deb;
  --accent-hover: #d8b7fc;

  --success: #4cd099;
  --warn: #f5d712;
  --danger: #f97076;
  --info: #3cc1fb;

  /* Dot-grid texture; flips per theme. */
  --dot: rgba(221, 217, 208, 0.015);

  /* Card/KV header micro-tint; direction flips per theme. */
  --tint-1: rgba(255, 255, 255, 0.015);
  --tint-2: rgba(255, 255, 255, 0.02);
  --tint-3: rgba(255, 255, 255, 0.08);

  --btn-hover-bg: #2d303c;

  /* Primary CTA locked to Terraform brand purple across themes. */
  --primary: #7b42bc;
  --primary-hover: #844fba;

  --mono: "Iosevka", "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Code", consolas, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --radius: 4px;
  --radius-btn: 6px;
  --radius-pill: 3px;
}

/* Helios light theme. */
:root[data-theme="light"] {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-hover: #f1f2f3;
  --border: rgba(101, 106, 118, 0.20);

  --text: #0c0c0e;
  --text-muted: #3b3d45;
  --text-dim: #656a76;

  /* Accent intentionally NOT overridden — brand purple stays constant across themes. */

  --success: #00691b;
  --warn: #9e4b00;
  --danger: #c00005;
  --info: #1060ff;

  --dot: rgba(0, 0, 0, 0.025);

  --tint-1: rgba(0, 0, 0, 0.02);
  --tint-2: rgba(0, 0, 0, 0.025);
  --tint-3: rgba(0, 0, 0, 0.05);

  --btn-hover-bg: #e5e7ea;
}

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

body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  /* Tabular numerals so status columns don't jitter. */
  font-family: var(--mono);
  font-feature-settings: "tnum" 1, "calt" 0;
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px 48px;
}

.header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.theme-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-hover);
}
.theme-toggle__sun { display: inline; }
.theme-toggle__moon { display: none; }
:root[data-theme="light"] .theme-toggle__sun { display: none; }
:root[data-theme="light"] .theme-toggle__moon { display: inline; }
.header h1 { font-size: 16px; font-weight: 600; white-space: nowrap; }
.header h1 .cluster { color: var(--text-muted); font-weight: 400; margin-left: 8px; font-family: var(--mono); font-size: 13px; }
.header .nav {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 13px;
}
.header .nav a {
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
}
.header .nav a:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}
.header .nav a.active {
  color: var(--text);
  background: var(--bg-hover);
}

.crumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.crumb a { color: var(--text-muted); }
.crumb a:hover { color: var(--accent); text-decoration: none; }
.crumb strong { color: var(--text); }
.crumb > * + *::before {
  content: '·';
  color: var(--text-dim);
  margin-right: 8px;
}

.page-title { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.page-title.danger { color: var(--danger); }
.page-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

.hint-line { font-size: 12px; color: var(--text-muted); }
.hint-line.normal-weight { font-weight: 400; }

.cell-actions { text-align: right; white-space: nowrap; }

.filter-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}
.filter-input:focus { outline: none; border-color: var(--accent); }

.objects-toolbar { margin-bottom: 16px; }

thead th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
thead th.sortable:hover { color: var(--text); }
thead th.sortable::after { content: ' ↕'; opacity: 0.35; }
thead th.sortable[aria-sort="ascending"]::after { content: ' ↑'; opacity: 1; }
thead th.sortable[aria-sort="descending"]::after { content: ' ↓'; opacity: 1; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  gap: 2px;
}
.tabs a {
  padding: 12px 18px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: background 0.15s, color 0.15s;
}
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--bg-hover); }
.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
/* Baseline width inside dense tables so status columns don't jitter. */
tbody td .pill, .op-row .pill { min-width: 70px; justify-content: flex-start; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pill.healthy { background: rgba(76, 208, 153, 0.15); color: var(--success); }
.pill.healthy .dot { background: var(--success); }
.pill.warn { background: rgba(245, 215, 18, 0.15); color: var(--warn); }
.pill.warn .dot { background: var(--warn); }
.pill.fail { background: rgba(249, 112, 118, 0.15); color: var(--danger); }
.pill.fail .dot { background: var(--danger); }
.pill.progress { background: rgba(60, 193, 251, 0.15); color: var(--info); }
.pill.progress .dot { background: var(--info); animation: pulse 1.5s ease infinite; }
.pill.neutral { background: rgba(125, 133, 144, 0.15); color: var(--text-muted); }
.pill.neutral .dot { background: var(--text-muted); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .pill.progress .dot,
  .btn.loading::after {
    animation: none;
  }
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--tint-1);
}
.card-header a { font-size: 12px; }
.card-body { padding: 16px; }
.card-body.dense { padding: 0; }

.flag-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.flag-tags .flag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: var(--tint-1);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}
details[open] .expand-hint { display: none; }
/* Copy lives in the <summary>; only meaningful once the SQL is revealed. */
details:not([open]) .copy-btn { display: none; }

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 12px 16px 4px;
  font-weight: 600;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 500;
  background: var(--tint-2);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr.row-clickable:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* Fixed column layout so every database section on the overview lines up,
   instead of each table auto-sizing its own columns. */
.overview-table { table-layout: fixed; }
.overview-table .col-app { width: 26%; }
.overview-table .col-status { width: 14%; }
.overview-table .col-release { width: 16%; }
.overview-table .col-last-deploy { width: 24%; }
.overview-table .col-pending { width: 20%; }
.overview-table td { overflow: hidden; text-overflow: ellipsis; }

.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover {
  background: var(--btn-hover-bg);
  border-color: var(--accent);
  text-decoration: none;
  color: var(--text);
}
.btn:focus-visible, .graph-controls .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: white; }
.btn.danger { background: rgba(249, 112, 118,0.08); border-color: rgba(249, 112, 118,0.3); color: var(--danger); }
.btn.danger:hover { background: rgba(249, 112, 118,0.15); color: var(--danger); }
.btn:disabled, .btn.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-group { display: inline-flex; gap: 8px; }

.db-section { border-bottom: 1px solid var(--border); }
.db-section:last-child { border-bottom: none; }
.db-section h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 16px;
  background: var(--tint-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.db-section h2 .name { color: var(--text); }
.db-section h2 .count { color: var(--text-dim); font-weight: 400; margin-left: auto; }

.op-row {
  display: grid;
  /* Lanes: num | name | op-type | status | backfill-bar | backfill-% */
  grid-template-columns:
    40px
    minmax(160px, 1.4fr)
    90px
    100px
    90px
    90px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
  gap: 10px;
}
/* No backfill anywhere (terminal migration): drop the two empty trailing lanes. */
.ops-no-backfill .op-row {
  grid-template-columns: 40px minmax(160px, 1.4fr) 90px 100px;
}
.ops-no-backfill .op-row .progress-cell,
.ops-no-backfill .op-row .rate { display: none; }
.op-row:last-child { border-bottom: none; }
.op-row:hover { background: var(--bg-hover); }
.op-row .num { color: var(--text-dim); font-family: var(--mono); font-size: 12px; }
.op-row .name { font-family: var(--mono); font-size: 12px; color: var(--text); }
.op-row .type { color: var(--text-muted); font-size: 12px; }
.op-row .status-cell { display: flex; align-items: center; gap: 8px; }
.op-row .progress-cell { display: flex; align-items: center; }
.op-row .progress-cell .progress-bar { width: 100%; }
.op-row .rate { color: var(--text-muted); font-family: var(--mono); font-size: 11px; }

.progress-bar {
  display: inline-block;
  width: 60px;
  height: 4px;
  background: var(--tint-3);
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
}
.progress-bar .bar { display: block; height: 100%; background: var(--info); }
.pct-label { margin-left: 8px; font-size: 12px; }
.backfill-cell { width: 200px; }
.backfill-cell .progress-bar { width: 120px; }

.cluster-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.cluster-metric {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}
.cluster-metric .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.cluster-metric .value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.cluster-metric .spark {
  font-family: var(--mono);
  color: var(--info);
  font-size: 12px;
  margin-top: 4px;
  letter-spacing: 1px;
}
.cluster-metric .spark.muted { color: var(--text-muted); }

.cluster-metric { position: relative; }
.cluster-metric .info-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  user-select: none;
  background: var(--bg);
}
.cluster-metric .info-icon:hover {
  border-color: var(--text);
  color: var(--text);
}
.cluster-metric .info-tooltip {
  position: absolute;
  top: 28px;
  /* Cap inside viewport so the rightmost tile doesn't overflow. */
  right: 6px;
  max-width: min(320px, calc(100vw - 32px));
  z-index: 100;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  font-family: var(--sans);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  display: none;
  white-space: normal;
}
/* `:focus-visible` (keyboard) intentional; plain `:focus` excluded so tooltip doesn't stick on click. */
.cluster-metric .info-icon:hover + .info-tooltip,
.cluster-metric .info-icon:focus-visible + .info-tooltip {
  display: block;
}

.cluster-metric.metric-warn {
  border-color: rgba(245, 215, 18, 0.55);
  background: linear-gradient(0deg, rgba(245, 215, 18, 0.07), transparent);
}
.cluster-metric.metric-fail {
  border-color: rgba(249, 112, 118, 0.55);
  background: linear-gradient(0deg, rgba(249, 112, 118, 0.09), transparent);
}
.cluster-metric.metric-warn .value { color: var(--warn); }
.cluster-metric.metric-fail .value { color: var(--danger); }

.log {
  font-family: var(--mono);
  font-size: 12px;
  padding: 12px 16px;
  background: rgba(0,0,0,0.25);
  max-height: 240px;
  overflow-y: auto;
}
.log .line { padding: 2px 0; color: var(--text); }
.log .ts { color: var(--text-dim); margin-right: 10px; }
.log .tag { color: var(--info); margin-right: 8px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.field label .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-dim); margin-left: 8px; }
.field input, .field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }

.field label.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 0;
  cursor: pointer;
}
.field label.checkbox-row input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin: 0;
  accent-color: var(--accent);
}

.diff-item {
  display: grid;
  grid-template-columns: 90px 1fr 100px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
  gap: 12px;
}
.diff-item:last-child { border-bottom: none; }
.diff-item .badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.diff-item .badge.change { background: rgba(245, 215, 18, 0.15); color: var(--warn); }
.diff-item .badge.add { background: rgba(76, 208, 153, 0.15); color: var(--success); }
.diff-item .badge.drop { background: rgba(249, 112, 118, 0.15); color: var(--danger); }
.diff-item .obj { font-family: var(--mono); font-size: 12px; }
.diff-empty { padding: 10px 16px; color: var(--text-dim); font-style: italic; font-size: 12px; }

.lock-banner {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px;
}
.lock-banner.held { background: rgba(245, 215, 18, 0.05); border: 1px solid rgba(245, 215, 18, 0.25); }

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

/* Migration phase-action bar (the only one with fixed primary/danger slots):
   primary pinned left, destructive pinned right — same locations regardless of
   which phase's controls render. Top-aligned + reserved height so opening the
   danger reveal (it grows downward) and swapping the primary between a button,
   a disabled label, or a hint line never shifts the other controls. */
.action-bar:has(.action-primary) {
  align-items: flex-start;
  min-height: 56px;
}
.action-bar > .action-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}
.action-bar > .action-danger {
  margin-left: auto;
}

.banner {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.banner.danger { background: rgba(249, 112, 118,0.05); border: 1px solid rgba(249, 112, 118,0.25); color: var(--danger); }
.banner a { color: inherit; text-decoration: underline; }

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.flash {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.flash-error {
  background: rgba(249, 112, 118, 0.08);
  border-color: rgba(249, 112, 118, 0.35);
  color: var(--danger);
}
.flash-info {
  background: rgba(60, 193, 251, 0.06);
  border-color: rgba(60, 193, 251, 0.30);
  color: var(--info);
}
.flash-warn {
  background: rgba(245, 215, 18, 0.06);
  border-color: rgba(245, 215, 18, 0.30);
  color: var(--warn);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}
.check-row:hover { background: var(--bg-hover); }
.check-row input[type="checkbox"] { accent-color: var(--accent); }
.check-row .mono { font-family: var(--mono); }

.btn.small,
.btn-small {
  padding: 3px 9px;
  font-size: 11.5px;
  line-height: 1.4;
  border-radius: var(--radius);
}

.card-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.cluster-summary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: var(--bg-elevated);
}
.cluster-summary .summary-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
}
.cluster-summary-healthy {
  border-color: rgba(76, 208, 153, 0.35);
  background: linear-gradient(0deg, rgba(76, 208, 153, 0.05), transparent);
}
.cluster-summary-warn {
  border-color: rgba(245, 215, 18, 0.35);
  background: linear-gradient(0deg, rgba(245, 215, 18, 0.07), transparent);
}
.cluster-summary-fail {
  border-color: rgba(249, 112, 118, 0.40);
  background: linear-gradient(0deg, rgba(249, 112, 118, 0.08), transparent);
}

.widen-banner {
  padding: 12px 16px;
  border: 1px solid rgba(245, 215, 18, 0.35);
  background: rgba(245, 215, 18, 0.06);
  border-radius: var(--radius);
  margin: 12px 0;
}
.widen-banner p { margin-bottom: 8px; }
.widen-banner.danger {
  border-color: rgba(249, 112, 118, 0.35);
  background: rgba(249, 112, 118, 0.06);
}
.conflict-detail {
  margin: 0 0 10px;
  padding: 8px 10px;
  white-space: pre-wrap;
  font-size: 12px;
  color: var(--danger);
  background: rgba(249, 112, 118, 0.05);
  border-radius: var(--radius);
}

.row-warn {
  background: rgba(245, 215, 18, 0.05);
  border-left: 2px solid rgba(245, 215, 18, 0.6);
}
.row-warn td:first-child { padding-left: 10px; }

.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12.5px;
  /* Fixed layout so a long var name can't balloon the name column and shove
     the value far to the right on short-named rows. */
  table-layout: fixed;
}
.kv-col-name { width: 45%; }
.kv-col-value { width: 47%; }
.kv-col-actions { width: 8%; }
.kv-table td.mono { overflow-wrap: anywhere; }
.kv-table th,
.kv-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.kv-table thead th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-hover);
}
.kv-table tbody tr:hover { background: var(--bg-hover); }

.var-value {
  cursor: pointer;
  border: 1px dashed transparent;
  padding: 4px 8px !important;
  border-radius: var(--radius);
  transition: border-color 120ms ease, background 120ms ease;
}
.var-value:hover {
  border-color: var(--accent);
  background: rgba(132, 79, 186, 0.05);
}
.var-value:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: rgba(132, 79, 186, 0.08);
}
.var-value input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 4px 6px;
  border-radius: var(--radius);
}
.var-status {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.var-status:not(:empty)::before { content: ""; }

.note {
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px 16px;
  background: rgba(0,0,0,0.15);
  border-top: 1px solid var(--border);
}
/* Warn variant: full-contrast body text on a warn tint so the banner is
   actually readable (the muted-on-gray default was not). */
.note.warn {
  color: var(--text);
  background: rgba(245, 215, 18, 0.07);
  border-top-color: rgba(245, 215, 18, 0.35);
}
.note.warn code { color: var(--warn); }
/* The global `* { padding: 0 }` reset strips list indentation, so lists inside
   a note render with clipped markers. Restore disc + indent + row spacing. */
.note ul {
  list-style: disc;
  margin: 8px 0 0;
  padding-left: 20px;
}
.note ul li { margin: 2px 0; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding: 16px;
}
/* Variable-height cells (e.g. wrapping fragment-flag tags) take their own row
   so they don't leave short cells orphaned/misaligned in the auto-fit grid. */
.kv-grid .kv.kv-wide { grid-column: 1 / -1; }
.kv-grid .kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }
.kv-grid .kv .v { margin-top: 4px; font-size: 16px; font-family: var(--mono); }
.kv-grid .kv .v.plain { font-family: inherit; }
.kv-grid .kv .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

tr.row-clickable { cursor: pointer; }
tr.row-clickable:hover { background: var(--bg-hover); }

.diff-item.collapsed,
tr.collapsed { display: none; }
.diff-more { padding: 8px 16px; }
.diff-more .btn { font-size: 12px; padding: 4px 10px; }

.diff-group { border-bottom: 1px solid var(--border); }
.diff-group:last-child { border-bottom: none; }
.diff-group > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 13px;
}
.diff-group > summary::-webkit-details-marker { display: none; }
.diff-group > summary::before {
  content: '▸';
  color: var(--text-dim);
  font-size: 11px;
  width: 10px;
  transition: transform 0.15s;
}
.diff-group[open] > summary::before { transform: rotate(90deg); display: inline-block; }
.diff-group > summary:hover { background: var(--bg-hover); }
.diff-group > summary .reason { color: var(--text); font-weight: 500; flex: 1; }
.diff-group > summary .count { font-size: 12px; }
.diff-group-body {
  padding: 4px 0 8px 40px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}
.diff-obj {
  margin: 2px 0;
  border-left: 2px solid var(--border);
  padding-left: 8px;
}
.diff-obj > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  padding: 3px 16px 3px 0;
  font-size: 12px;
  user-select: none;
}
.diff-obj > summary::-webkit-details-marker { display: none; }
.diff-obj > summary:hover { background: var(--bg-hover); }
.diff-obj > summary .obj { color: var(--text); }
.diff-obj .small { font-size: 11px; }
.type-chip {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(125,133,144,0.12);
  color: var(--text-muted);
  text-transform: lowercase;
}
.sql-diff {
  margin: 4px 0 8px 0;
  padding: 10px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}
.sql-diff .diff-add { color: var(--success); display: block; }
.sql-diff .diff-del { color: var(--danger); display: block; }
.flash .sql-diff,
.error-history .sql-diff { white-space: pre-wrap; margin: 0.5rem 0 0; }

.inline-form { display: inline-flex; align-items: center; gap: 8px; }
.flash .inline-form,
.note .inline-form { margin-top: 0.5rem; }

.card > .flash,
.card > .note,
.card > .error-history { margin-top: 0.75rem; }

.action-danger .rollback-reveal { display: inline-block; }
.action-bar .rollback-confirm { margin-top: 8px; }

/* <summary> styled as a button; strip default disclosure marker. */
summary.btn {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
summary.btn::-webkit-details-marker { display: none; }
summary.btn::marker { content: ''; }

.confirm-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  width: 220px;
}
.confirm-input:focus { outline: none; border-color: var(--danger); }

.btn.loading { opacity: 0.7; pointer-events: none; }
.btn.loading::after {
  content: " ⌛";
  display: inline-block;
  animation: spin 1s linear infinite;
}
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* graph */
.graph-canvas {
  position: relative;
  height: 640px;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  user-select: none;
}
.graph-canvas svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.graph-canvas svg.dragging { cursor: grabbing; }
.graph-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 2;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
}
.graph-controls .btn { padding: 4px 8px; font-size: 12px; }
.graph-node rect {
  fill: var(--bg-elevated);
  stroke: var(--border);
  stroke-width: 1.5;
  rx: 6;
}
.graph-node text { fill: var(--text); font-family: var(--mono); font-size: 11px; pointer-events: none; }
.graph-node-link { cursor: pointer; }
.graph-node-link:hover rect { stroke-width: 2.5; }
.graph-node.mv rect { stroke: var(--info); }
.graph-node.sink rect { stroke: var(--success); }
.graph-node.source rect { stroke: var(--warn); }
.graph-node.table rect { stroke: var(--text-muted); stroke-dasharray: 3,2; }
.graph-node.subscription rect { stroke: var(--accent); stroke-dasharray: 1,2; }
/* The lineage panel's focal node: keep its type colour, emphasise the border. */
.graph-node.center rect { stroke-width: 3; }
.graph-edge { stroke: var(--text-dim); stroke-width: 1.25; fill: none; }

/* scope radio (teardown) */
.scope-radio { display: flex; flex-direction: column; gap: 8px; }
.scope-radio .scope-link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg-elevated);
  text-decoration: none;
  color: inherit;
}
.scope-radio .scope-link:hover { background: var(--bg-hover); border-color: #7d8590; }
.scope-radio .scope-link.selected { border-color: var(--accent); background: rgba(132, 79, 186, 0.05); }
.scope-radio .label-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.scope-radio .label-sub { font-size: 12px; color: var(--text-muted); line-height: 1.45; }

.confirm-ack {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  margin-top: 8px;
  font-weight: normal;
  text-transform: none;
  letter-spacing: 0;
}
.confirm-ack input { accent-color: var(--danger); margin: 0; }

.sql-details > summary { cursor: pointer; }
.sql-details > summary .copy-btn { margin-left: auto; }
.sql-details > pre.sql-diff { white-space: pre-wrap; border-top: 1px solid var(--border); margin: 0; }
