/* ==========================================================================
   PHOSPHOR GRID v1.0 — 4-Theme Spreadsheet Workbench, Scrubber & Chart CSS
   Themes: CRT '96 (Emerald Terminal) | DARK | OFFICE (Daylight) | TURBO '96
   ========================================================================== */

:root,
[data-theme="crt"] {
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Consolas", "Cascadia Mono", "Courier New", monospace;

  --bg-app: #061310;
  --bg-panel: #0b1d19;
  --bg-panel-alt: #102823;
  --bg-surface: #081814;
  --bg-input: #040d0b;
  --bg-row-alt: rgba(57, 255, 136, 0.03);
  --bg-row-hover: rgba(57, 255, 136, 0.08);

  --border: #193b33;
  --border-hi: #275b4f;

  --text-main: #e6f5ee;
  --text-muted: #8cb2a4;
  --text-dim: #5d8074;

  --accent: #39ff88;
  --accent-bg: rgba(57, 255, 136, 0.14);
  --accent-text: #03190d;
  --green: #39ff88;
  --cyan: #4cc9f0;
  --amber: #ffb84d;
  --red: #ff5c77;

  --radius: 5px;
  --radius-lg: 8px;
  --scanline-opacity: 0.06;
}

[data-theme="dark"] {
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Consolas", "Cascadia Mono", "SFMono-Regular", monospace;

  --bg-app: #111317;
  --bg-panel: #181c23;
  --bg-panel-alt: #202631;
  --bg-surface: #14181f;
  --bg-input: #0e1015;
  --bg-row-alt: rgba(255, 255, 255, 0.02);
  --bg-row-hover: rgba(122, 162, 247, 0.09);

  --border: #2b313e;
  --border-hi: #3e4759;

  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent: #34d399;
  --accent-bg: rgba(52, 211, 153, 0.15);
  --accent-text: #061812;
  --green: #4ade80;
  --cyan: #60a5fa;
  --amber: #f59e0b;
  --red: #f87171;

  --radius: 6px;
  --radius-lg: 10px;
  --scanline-opacity: 0;
}

[data-theme="office"] {
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Consolas", "SFMono-Regular", monospace;

  --bg-app: #eef2f6;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f5f8fb;
  --bg-surface: #f8fafc;
  --bg-input: #ffffff;
  --bg-row-alt: #f8fafc;
  --bg-row-hover: #eff6ff;

  --border: #cbd5e1;
  --border-hi: #94a3b8;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --accent: #15803d;
  --accent-bg: rgba(21, 128, 61, 0.10);
  --accent-text: #ffffff;
  --green: #16a34a;
  --cyan: #0284c7;
  --amber: #b45309;
  --red: #dc2626;

  --radius: 6px;
  --radius-lg: 10px;
  --scanline-opacity: 0;
}

[data-theme="turbo"] {
  --font-ui: "Consolas", "Cascadia Mono", "Courier New", monospace;
  --font-mono: "Consolas", "Cascadia Mono", "Courier New", monospace;

  --bg-app: #020804;
  --bg-panel: #041208;
  --bg-panel-alt: #061c0d;
  --bg-surface: #030e06;
  --bg-input: #010502;
  --bg-row-alt: rgba(0, 255, 102, 0.04);
  --bg-row-hover: rgba(0, 255, 102, 0.12);

  --border: #0f6f34;
  --border-hi: #00ff66;

  --text-main: #7affaa;
  --text-muted: #34c76e;
  --text-dim: #1d7a42;

  --accent: #00ff66;
  --accent-bg: rgba(0, 255, 102, 0.15);
  --accent-text: #011407;
  --green: #00ff66;
  --cyan: #00f0ff;
  --amber: #ffb000;
  --red: #ff4757;

  --radius: 0px;
  --radius-lg: 0px;
  --scanline-opacity: 0.18;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.45;
  min-height: 100%;
  overflow-x: hidden;
}

.crt-scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: var(--scanline-opacity);
  background: repeating-linear-gradient(to bottom, transparent 0px, transparent 2px, rgba(0, 0, 0, 0.5) 3px, transparent 4px);
}
body.no-scanlines .crt-scanlines,
[data-theme="dark"] .crt-scanlines,
[data-theme="office"] .crt-scanlines { display: none; }

/* TOPBAR */
.topbar {
  position: sticky; top: 0; z-index: 100;
  min-height: 54px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 6px 12px; flex-wrap: nowrap;
}
@media (max-width: 1120px) {
  .topbar { flex-wrap: wrap; }
}
.brand-cluster { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  font-family: var(--font-mono); font-weight: 900; font-size: 12px;
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-title { font-weight: 800; font-size: 14.5px; letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; }
.ver-badge {
  font-family: var(--font-mono); font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.brand-sub { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); letter-spacing: 0.35px; }

.proof-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--green) 45%, var(--border));
  background: color-mix(in srgb, var(--green) 11%, transparent);
  color: var(--green);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 800; cursor: pointer;
}
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }

.controls-cluster { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.theme-switch {
  display: inline-flex; background: var(--bg-input); border: 1px solid var(--border-hi);
  border-radius: var(--radius); padding: 2px; gap: 2px;
}
.theme-btn {
  border: none; background: transparent; color: var(--text-muted);
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  padding: 4px 7px; border-radius: calc(var(--radius) - 1px); cursor: pointer; white-space: nowrap;
}
.theme-btn:hover { color: var(--text-main); }
.theme-btn.active { background: var(--accent); color: var(--accent-text); }

.save-as-btn {
  height: 30px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--border-hi); background: var(--bg-panel-alt); color: var(--text-main);
  font-size: 11.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.save-as-btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-surface);
  color: var(--text-main); cursor: pointer; display: grid; place-items: center; font-size: 13px;
}
.icon-btn.muted { opacity: 0.45; }

/* APP SHELL */
.app-shell {
  display: grid;
  grid-template-columns: 274px minmax(0, 1fr);
  min-height: calc(100vh - 54px);
}

/* STICKY LEFT SIDEBAR */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 54px;
  height: calc(100vh - 54px);
  overflow-y: auto;
  min-width: 0;
}

.nav-section-lbl {
  font-family: var(--font-mono); font-size: 10px; font-weight: 800;
  color: var(--text-dim); letter-spacing: 0.8px; padding: 0 4px;
}

.tool-nav {
  display: flex; flex-direction: column; gap: 5px;
}
.tool-tab {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  text-align: left; cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.tool-tab:hover { border-color: var(--border-hi); background: var(--bg-panel-alt); }
.tool-tab.active {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.tab-ico { font-size: 17px; flex-shrink: 0; line-height: 1; }
.tab-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.tab-name {
  font-size: 12.5px; font-weight: 800; color: var(--text-main);
  display: flex; align-items: center; gap: 6px;
}
.tool-tab.active .tab-name { color: var(--accent); }
.tab-desc {
  font-size: 10.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pii-pill {
  font-family: var(--font-mono); font-size: 10px; font-weight: 900;
  padding: 0 6px; border-radius: 999px;
  background: var(--red); color: #fff;
  line-height: 1.5;
}

/* DATASET SUMMARY CARD */
.dataset-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.ds-name {
  font-weight: 800; font-size: 12.5px; color: var(--text-main);
  word-break: break-word;
}
.ds-meta {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
}
.ds-btns { display: flex; gap: 6px; margin-top: 2px; }

/* FLEET FOOTER STACK */
.sidebar-footer-stack {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 6px;
}
.guide-sidebar-btn {
  width: 100%; padding: 8px 10px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--green) 50%, var(--border));
  background: color-mix(in srgb, var(--green) 11%, var(--bg-surface));
  color: var(--green); font-weight: 800; font-size: 12px;
  cursor: pointer; text-align: center;
}
.guide-sidebar-btn:hover { background: color-mix(in srgb, var(--green) 18%, var(--bg-surface)); }

.sidebar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 9px 10px;
  display: flex; flex-direction: column; gap: 5px;
}
.brand-card { border-style: dashed; border-color: var(--border-hi); }
.scard-kicker { font-family: var(--font-mono); font-size: 10px; font-weight: 800; color: var(--accent); }
.scard-text { margin: 0; font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.scard-btn {
  display: block; text-align: center; text-decoration: none;
  padding: 6px 8px; border-radius: var(--radius);
  border: 1px solid var(--border-hi); background: var(--bg-panel-alt);
  color: var(--text-main); font-size: 11.5px; font-weight: 700;
}
.scard-btn:hover { border-color: var(--accent); color: var(--accent); }
.bcard-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bcard-title { font-family: var(--font-mono); font-size: 10.5px; font-weight: 900; color: var(--text-main); }
.bcard-badge {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 900;
  padding: 1px 6px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent);
}
.bcard-links { font-size: 10.5px; color: var(--text-dim); line-height: 1.5; }
.bcard-links a { color: var(--text-muted); text-decoration: none; font-weight: 600; }
.bcard-links a:hover { color: var(--accent); text-decoration: underline; }
.bcard-links.legal { font-size: 10px; border-top: 1px solid var(--border); padding-top: 4px; margin-top: 2px; }

/* MAIN STAGE */
.main-stage {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 16px 24px;
  min-width: 0;
  position: relative;
}
.main-stage.drag-over::after {
  content: "📂 DROP CSV, TSV, OR JSON FILE TO LOAD IN RAM";
  position: fixed; inset: 16px; z-index: 500;
  border: 3px dashed var(--accent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-app) 88%, transparent);
  color: var(--accent);
  font-family: var(--font-mono); font-size: 20px; font-weight: 900;
  display: grid; place-items: center;
  pointer-events: none;
}

/* TOOLBARS & BUTTONS (LEFT-JUSTIFIED WITH | RAILS) */
.top-action-bar,
.janitor-bar,
.stats-strip,
.flip-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 10px;
}

.tb-group { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb-lbl {
  font-family: var(--font-mono); font-size: 11px; font-weight: 800;
  color: var(--text-muted); margin-right: 2px;
}
.tb-sep {
  width: 1px; height: 22px; background: var(--border-hi);
  display: inline-block; flex-shrink: 0;
}

.tb-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  background: var(--bg-panel-alt);
  color: var(--text-main);
  font-family: var(--font-ui); font-size: 12px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.tb-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tb-btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.tb-btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
}
.tb-btn.primary:hover:not(:disabled) { filter: brightness(1.08); color: var(--accent-text); }
.tb-btn.danger:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.tb-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.file-lbl { user-select: none; }

.wire-input,
.tb-input,
.tb-select,
.tb-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  color: var(--text-main);
  font-family: var(--font-ui); font-size: 12.5px;
  padding: 5px 9px;
  min-width: 0; max-width: 100%;
}
.wire-input { width: 240px; flex: 0 1 240px; }
.tb-input, .tb-select, .tb-textarea { width: 100%; }
.tb-select.compact { width: auto; min-width: 130px; max-width: 220px; }
.tb-textarea { font-family: var(--font-mono); font-size: 12px; resize: vertical; }
.wire-input:focus, .tb-input:focus, .tb-select:focus, .tb-textarea:focus {
  outline: none; border-color: var(--accent);
}

/* STATS STRIP */
.stats-strip { background: var(--bg-surface); padding: 7px 10px; }
.stat-col-pick {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
}
.stat-pills { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.stat-pill {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px;
}
.stat-pill span { color: var(--text-muted); font-size: 10px; text-transform: uppercase; }
.stat-pill strong { color: var(--accent); font-weight: 900; }
.stat-pill.warn strong { color: var(--amber); }
.stat-pill.alert {
  border-color: color-mix(in srgb, var(--amber) 60%, var(--border));
  background: color-mix(in srgb, var(--amber) 12%, var(--bg-panel));
}
.stat-pill.alert strong { color: var(--amber); }

/* VIEW PANELS */
.view-panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}
.panel-head h2 { margin: 0 0 3px; font-size: 16px; font-weight: 800; }
.panel-head p { margin: 0; font-size: 12px; color: var(--text-muted); max-width: 720px; }

/* INTERACTIVE SPREADSHEET TABLE */
.table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  max-height: calc(100vh - 285px);
  min-height: 320px;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.data-table thead th {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border-hi);
  border-right: 1px solid var(--border);
  padding: 0;
  text-align: left;
  white-space: nowrap;
}
.data-table thead th.sorted { background: color-mix(in srgb, var(--accent) 16%, var(--bg-panel-alt)); }

.th-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 2px;
}
.th-sort-btn {
  flex: 1; display: flex; align-items: center; gap: 5px;
  padding: 8px 9px; border: none; background: transparent;
  color: var(--text-main); font-family: var(--font-ui); font-size: 12px; font-weight: 800;
  cursor: pointer; text-align: left;
}
.th-sort-btn:hover { color: var(--accent); }
.th-arrow { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); margin-left: auto; }
.sorted .th-arrow { color: var(--accent); }
.th-pii-dot { font-size: 11px; }
.th-del-btn {
  border: none; background: transparent; color: var(--text-dim);
  padding: 6px 7px; cursor: pointer; font-size: 13px; font-weight: 800;
}
.th-del-btn:hover { color: var(--red); }

.data-table tbody td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0;
  min-width: 118px;
}
.data-table tbody tr:nth-child(even) td { background: var(--bg-row-alt); }
.data-table tbody tr:hover td { background: var(--bg-row-hover); }
.data-table tbody tr.blank-row td { background: color-mix(in srgb, var(--amber) 9%, transparent); }
.data-table tbody tr.dup-row td { background: color-mix(in srgb, var(--amber) 7%, transparent); }
.data-table tbody tr.selected-row td {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-panel)) !important;
}
.data-table tbody tr.selected-row td.col-rownum {
  background: var(--accent) !important;
  color: var(--accent-text) !important;
  font-weight: 900;
}
.data-table tbody tr.selected-row .dup-badge {
  background: rgba(0, 0, 0, 0.28);
  color: var(--accent-text);
  border-color: rgba(0, 0, 0, 0.35);
}

/* FAR-RIGHT DELETE RAIL (SEPARATE FROM LEFT EXCEL ROW # HIGHLIGHT) */
.col-del {
  width: 32px; min-width: 32px !important; max-width: 32px;
  text-align: center !important;
  background: var(--bg-surface) !important;
  padding: 0 !important;
  border-right: none !important;
}
.row-del-btn {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 3px;
  border: none; background: transparent; color: var(--text-dim);
  opacity: 0.4; cursor: pointer; font-weight: 900; font-size: 13px;
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.data-table tbody tr:hover .row-del-btn,
.row-del-btn:focus {
  opacity: 1;
  color: var(--red);
  background: color-mix(in srgb, var(--red) 14%, transparent);
}

.col-rownum {
  width: 58px; min-width: 58px !important; max-width: 68px;
  text-align: center !important;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
  background: var(--bg-surface) !important;
  white-space: nowrap;
  padding: 0 6px !important;
  cursor: pointer;
  user-select: none;
}
.data-table tbody td.col-rownum:hover {
  background: var(--accent-bg) !important;
  color: var(--accent);
}
.dup-badge {
  display: inline-block; margin-left: 4px;
  font-family: var(--font-mono); font-size: 8.5px; font-weight: 900;
  padding: 0 4px; border-radius: 3px;
  background: color-mix(in srgb, var(--amber) 22%, transparent);
  color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 55%, transparent);
  vertical-align: middle;
}

.cell-input {
  width: 100%; border: none; background: transparent;
  color: var(--text-main); font-family: var(--font-ui); font-size: 12.5px;
  padding: 6px 9px; outline: none;
}
.cell-input.num {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--cyan);
}
[data-theme="office"] .cell-input.num { color: #0369a1; }
.cell-input:focus {
  background: var(--bg-input);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.empty-table-msg {
  text-align: center; padding: 36px 16px !important; color: var(--text-muted);
}

.table-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-muted);
  padding: 2px 2px;
}
.pager { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 11.5px; }

/* LIVE 1-FOR-1 CHANGE & AUDIT LOG */
.audit-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.audit-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  padding: 9px 12px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
}
.audit-head-left {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0;
}
.audit-title {
  font-family: var(--font-mono); font-size: 12px; font-weight: 900; color: var(--text-main);
}
.audit-count-pill {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 800;
  padding: 2px 8px; border-radius: 999px;
  background: var(--bg-input); border: 1px solid var(--border-hi); color: var(--text-muted);
}
.audit-count-pill.has-items {
  background: var(--accent-bg); border-color: var(--accent); color: var(--accent);
}
.audit-sub { font-size: 11px; color: var(--text-dim); }

.audit-list {
  max-height: 240px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-input);
}
.audit-empty {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim);
  padding: 8px 4px;
}
.audit-entry {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 7px 10px;
  display: flex; flex-direction: column; gap: 5px;
}
.audit-entry.kind-dedupe,
.audit-entry.kind-empty,
.audit-entry.kind-delete { border-left-color: var(--amber); }
.audit-entry.kind-pii { border-left-color: var(--cyan); }
.audit-entry.kind-reset { border-left-color: var(--red); }
.audit-entry.kind-undo { border-left-color: var(--text-muted); }

.audit-entry-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.audit-tag {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 900;
  padding: 1px 6px; border-radius: 3px;
  background: var(--accent-bg); color: var(--accent);
}
.audit-tag.kind-dedupe,
.audit-tag.kind-empty,
.audit-tag.kind-delete {
  background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber);
}
.audit-tag.kind-pii {
  background: color-mix(in srgb, var(--cyan) 18%, transparent); color: var(--cyan);
}
.audit-tag.kind-reset {
  background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red);
}
.audit-tag.kind-undo {
  background: var(--bg-panel-alt); color: var(--text-muted);
}
.audit-summary { font-size: 12px; font-weight: 700; color: var(--text-main); }
.audit-ts {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim);
}
.audit-details {
  margin: 0; padding: 0 0 0 16px;
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
}
.audit-details li { word-break: break-word; }

/* PRIVACY SCRUBBER GRID */
.scrub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
}
.scrub-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0;
}
.scrub-card.is-pii {
  border-color: color-mix(in srgb, var(--amber) 60%, var(--border));
  box-shadow: inset 3px 0 0 var(--amber);
}
.scrub-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.scrub-title { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrub-badge {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 800;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.scrub-badge.pii {
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 50%, transparent);
}
.scrub-badge.clean {
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: var(--green);
}
.scrub-meta { font-size: 11.5px; color: var(--text-muted); }
.scrub-samples {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 8px;
  min-height: 62px;
}
.scrub-samples code {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-main);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scrub-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }

/* CHART STUDIO */
.chart-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.card-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
}
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}
.field-lbl {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11.5px; font-weight: 700; color: var(--text-muted);
  min-width: 0;
}
.chk-lbl {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text-main); cursor: pointer;
}
.chart-stage {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-width: 0;
}
.chart-frame {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-hi);
}
.chart-frame svg {
  display: block;
  width: 100%;
  height: auto;
}

/* FORMAT FLIPPER */
.tool-seg {
  display: inline-flex; flex-wrap: wrap; gap: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 3px;
}
.seg-btn {
  border: none; background: transparent; color: var(--text-muted);
  font-family: var(--font-ui); font-size: 12px; font-weight: 700;
  padding: 5px 10px; border-radius: calc(var(--radius) - 1px); cursor: pointer;
}
.seg-btn:hover { color: var(--text-main); }
.seg-btn.active { background: var(--accent); color: var(--accent-text); }

.sql-tbl-wrap {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
}

.flip-code {
  margin: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-main);
  overflow: auto;
  max-height: calc(100vh - 300px);
  min-height: 300px;
  white-space: pre;
}

/* MODALS */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  display: grid; place-items: center; padding: 16px;
}
.modal-window {
  width: min(500px, 100%);
  background: var(--bg-panel);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.modal-wide { width: min(680px, 100%); }
.modal-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-panel-alt);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; font-weight: 900; color: var(--accent);
}
.modal-close {
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 15px; font-weight: 900;
}
.modal-close:hover { color: var(--text-main); }
.modal-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
.tiny-note { font-size: 11.5px; color: var(--text-muted); }

.guide-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.guide-col h4 { margin: 0 0 6px; font-size: 13px; color: var(--accent); }
.guide-col ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.guide-col code, .modal-body code {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-input); border: 1px solid var(--border);
  padding: 1px 4px; border-radius: 3px; color: var(--accent);
}

/* TOAST */
.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 1200;
  background: var(--bg-panel-alt);
  border: 1px solid var(--accent);
  color: var(--text-main);
  padding: 9px 14px; border-radius: var(--radius-lg);
  font-size: 12.5px; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.toast.warn { border-color: var(--amber); color: var(--amber); }

/* PRINT MOUNT */
.grid-print-mount { display: none; }
@media print {
  .no-print { display: none !important; }
  html, body { background: #ffffff !important; height: auto !important; }
  .grid-print-mount {
    display: block !important;
    width: 100%;
    padding: 0.4in;
  }
  .grid-print-mount svg { width: 100%; height: auto; display: block; }
}

/* MOBILE & TABLET RESPONSIVE */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .chart-layout { grid-template-columns: minmax(0, 1fr); }
  .guide-grid { grid-template-columns: minmax(0, 1fr); }
  .brand-sub { display: none; }
  .wire-input { width: 100%; flex: 1 1 100%; }
  .table-wrap { max-height: 62vh; }
}

@media (max-width: 560px) {
  .topbar { padding: 6px 10px; }
  .main-stage { padding: 10px; }
  .proof-pill { font-size: 9.5px; padding: 4px 8px; }
  .theme-btn { font-size: 10px; padding: 4px 5px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .tb-sep { display: none; }
  .scrub-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   STANDARDIZED 8-POINT PRIVACY PROOF MODAL & FOOTER PARITY (PHASE 2 SYNC)
   ========================================================================== */
.proof-pill { white-space: nowrap; }
.proof-checklist {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 6px;
}
.proof-checklist li {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 9px;
  font-size: 12px; line-height: 1.42; color: var(--text-muted);
}
.proof-checklist li strong { color: var(--text-main); }
.proof-checklist code {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-panel); border: 1px solid var(--border);
  padding: 1px 4px; border-radius: 3px; color: var(--accent);
}
.proof-status-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--green) 10%, var(--bg-input));
  border: 1px solid color-mix(in srgb, var(--green) 42%, var(--border));
  font-family: var(--font-mono); font-size: 11px; color: var(--green);
}
.proof-status-bar a { color: var(--accent); font-weight: 800; text-decoration: none; }
.proof-status-bar a:hover { text-decoration: underline; }
