/* ═══════════════════════════════════════════════════════════════
   SAP Data Profiler — Corporate Enterprise Theme
   A refined, subdued dark palette inspired by SAP Fiori,
   IBM Carbon, and Microsoft Fluent design systems.
   Designed for all-day ERP analyst use.
   ═══════════════════════════════════════════════════════════════ */

/* ─── DESIGN TOKENS ──────────────────────────────────────────── */
:root {
  /* Neutral Surface Scale — warm charcoal, not harsh black */
  --bg-base: #161b22;
  --bg-surface: #1c2129;
  --bg-elevated: #242a33;
  --bg-hover: #2b323c;
  --bg-panel: rgba(28, 33, 41, 0.82);

  /* Text Scale — soft whites, never pure #fff */
  --text-primary: #e3e8ef;
  --text-secondary: #9aa3b0;
  --text-muted: #636d7c;
  --text-inverse: #161b22;

  /* Corporate Blue — the anchor color, muted slate-blue */
  --blue: #4a7fc7;
  --blue-soft: rgba(74, 127, 199, 0.12);
  --blue-border: rgba(74, 127, 199, 0.22);
  --blue-hover: #5a8fd4;

  /* Semantic — understated, functional, not attention-grabbing */
  --success: #3d9a6e;
  --success-bg: rgba(61, 154, 110, 0.10);
  --warning: #c48b2c;
  --warning-bg: rgba(196, 139, 44, 0.10);
  --danger: #c25454;
  --danger-bg: rgba(194, 84, 84, 0.10);
  --info: #5b8db8;
  --info-bg: rgba(91, 141, 184, 0.10);

  /* Borders — subtle warm-gray lines */
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.10);
  --border-active: rgba(74, 127, 199, 0.28);

  /* Shadows — soft and restrained */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.28);

  /* Geometry */
  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --radius-full: 999px;

  /* Typography — professional, readable */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;

  /* Motion — smooth but not playful */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --duration: 180ms;
}

/* ─── LIGHT THEME ────────────────────────────────────────────── */
[data-theme="light"] {
  /* Surface Scale — clean whites and gentle grays */
  --bg-base: #f5f6f8;
  --bg-surface: #ffffff;
  --bg-elevated: #f0f1f4;
  --bg-hover: #e8eaed;
  --bg-panel: rgba(255, 255, 255, 0.92);

  /* Text Scale — dark grays, never pure black */
  --text-primary: #1a1f27;
  --text-secondary: #4d5766;
  --text-muted: #8591a2;
  --text-inverse: #ffffff;

  /* Corporate Blue — slightly warmer for light bg */
  --blue: #3a6fb5;
  --blue-soft: rgba(58, 111, 181, 0.08);
  --blue-border: rgba(58, 111, 181, 0.18);
  --blue-hover: #2e5fa3;

  /* Semantic — slightly darker for contrast on white */
  --success: #2d8659;
  --success-bg: rgba(45, 134, 89, 0.08);
  --warning: #a67520;
  --warning-bg: rgba(166, 117, 32, 0.08);
  --danger: #b03c3c;
  --danger-bg: rgba(176, 60, 60, 0.08);
  --info: #4a7ca8;
  --info-bg: rgba(74, 124, 168, 0.08);

  /* Borders — subtle gray lines */
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.14);
  --border-active: rgba(58, 111, 181, 0.30);

  /* Shadows — lighter and softer */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.10);
}

/* Smooth theme transition */
body,
.hero,
.panel,
.summary-card,
.object-card,
.metric-card,
.mini-card,
.rule-card,
.field-table,
.sql-card,
.ghost-btn,
.tab-btn,
.meta-pill,
.log-entry,
.readiness-item,
.empty-state,
.upload-badge,
.meta-stack a,
pre,
code,
th,
td {
  transition:
    background-color 200ms var(--ease),
    color 200ms var(--ease),
    border-color 200ms var(--ease),
    box-shadow 200ms var(--ease);
}

/* ─── THEME TOGGLE BUTTON ────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-color: var(--border-hover);
}

/* Light theme specific overrides for backdrop */
[data-theme="light"] .page-backdrop {
  background:
    radial-gradient(ellipse 900px 500px at 15% 0%, rgba(58, 111, 181, 0.04), transparent),
    radial-gradient(ellipse 700px 400px at 85% 100%, rgba(45, 134, 89, 0.03), transparent);
}

/* Light theme: hero top accent bar */
[data-theme="light"] .hero::before {
  opacity: 0.7;
}

/* ─── RESET ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── BASE ───────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--blue);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}

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

::selection {
  background: var(--blue);
  color: #fff;
}

/* ─── PAGE SHELL ─────────────────────────────────────────────── */
.page-shell {
  min-height: 100vh;
  position: relative;
}

.page-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  /* very subtle, nearly invisible gradient — just enough depth */
  background:
    radial-gradient(ellipse 900px 500px at 15% 0%, rgba(74, 127, 199, 0.035), transparent),
    radial-gradient(ellipse 700px 400px at 85% 100%, rgba(61, 154, 110, 0.025), transparent);
}

/* ─── APP FRAME ──────────────────────────────────────────────── */
.app-frame {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ─── HERO ───────────────────────────────────────────────────── */
.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 32px 36px;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

/* Thin top accent — single muted blue, not rainbow */
.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 2px;
  background: var(--blue);
  border-radius: 2px;
  opacity: 0.5;
}

.hero {
  position: relative;
  overflow: hidden;
}

.eyebrow,
.panel-eyebrow,
.summary-label,
.table-label,
.rule-meta,
.sql-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hero h1 {
  margin: 8px 0 10px;
  font-size: clamp(1.7rem, 3.2vw, 2.6rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hero-copy {
  max-width: 600px;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.hero-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  flex-shrink: 0;
  min-width: min(560px, 100%);
}

/* ─── STATUS PILL ────────────────────────────────────────────── */
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  border: 1px solid var(--border);
}

.meta-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.meta-stack,
.app-nav-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.app-nav-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px;
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-elevated) 88%, transparent), var(--bg-elevated));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.meta-stack a,
.app-nav-link,
.app-tools-trigger,
.app-tools-link {
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  color: var(--text-secondary);
  transition: all var(--duration) var(--ease);
  text-decoration: none;
}

.app-nav-link:hover,
.app-tools-trigger:hover,
.app-tools-link:hover {
  text-decoration: none;
  color: var(--text-primary);
  background: var(--bg-hover);
}

.app-nav-link.is-active {
  position: relative;
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue-soft) 70%, var(--bg-surface)), color-mix(in srgb, var(--blue-soft) 92%, var(--bg-elevated)));
  border-color: color-mix(in srgb, var(--blue) 22%, var(--border));
  color: var(--blue);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--blue) 12%, transparent),
    0 4px 10px color-mix(in srgb, var(--blue) 10%, transparent);
  transform: translateY(-1px);
}

.app-nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 5px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  opacity: 0.9;
}

.app-tools-menu {
  position: relative;
}

.app-tools-menu[open] .app-tools-trigger {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.app-tools-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  background: var(--bg-elevated);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.app-tools-trigger::-webkit-details-marker {
  display: none;
}

.app-tools-trigger::after {
  content: "▾";
  font-size: 10px;
  color: var(--text-muted);
}

.app-tools-list {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 160px;
  padding: 8px;
  display: grid;
  gap: 6px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.app-tools-link {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.session-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  width: 100%;
}

.session-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 10px 14px;
  min-width: 180px;
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-elevated) 92%, transparent), var(--bg-elevated));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.session-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.session-role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.session-logout {
  min-width: 94px;
}

/* ─── SUMMARY STRIP ──────────────────────────────────────────── */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-height: 132px;
  justify-content: space-between;
}

.summary-card strong {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-foot {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ─── PANELS ─────────────────────────────────────────────────── */
.panel {
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-top: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.panel.hidden {
  display: none;
}

.upload-panel-body.hidden {
  display: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel-header.compact {
  align-items: center;
}

.panel-header h2 {
  margin: 5px 0 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── RESULTS ACTIONS ────────────────────────────────────────── */
.results-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ─── BUTTONS ────────────────────────────────────────────────── */
.ghost-btn,
.tab-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.action-row input[type="text"],
.action-row input[type="search"],
.action-row select {
  min-width: 150px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-surface));
  color: var(--text-primary);
  padding: 10px 16px;
  font: inherit;
  font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.action-row input[type="text"]:focus,
.action-row input[type="search"]:focus,
.action-row select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.ghost-btn:hover,
.tab-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.ghost-btn:active,
.tab-btn:active {
  transform: scale(0.98);
}

.object-card:hover {
  transform: translateY(-1px);
}

/* ─── OBJECT GRID ────────────────────────────────────────────── */
.object-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.object-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.object-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.object-card.active {
  border-color: var(--border-active);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}

.object-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.object-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.object-title {
  margin: 0 0 3px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.object-tables {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.object-stats {
  display: flex;
  gap: 22px;
  margin-top: 16px;
}

.object-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.object-stat strong {
  font-size: 1rem;
  color: var(--text-primary);
}

/* ─── UPLOAD SECTION ─────────────────────────────────────────── */
.upload-grid,
.upload-status-grid {
  display: grid;
  gap: 14px;
}

.upload-grid {
  grid-template-columns: 1fr 1.1fr;
}

.upload-status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.upload-form {
  display: grid;
  gap: 10px;
}

.upload-form select,
.upload-form input[type="file"],
.mini-card select,
.mini-card input[type="search"],
.mini-card input[type="text"],
.mini-card input[type="password"],
.mini-card input[type="number"],
.mini-card input[type="date"],
.mini-card input[readonly],
.mini-card textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-base), var(--bg-surface));
  color: var(--text-primary);
  padding: 11px 13px;
  font: inherit;
  font-size: 13px;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), background var(--duration) var(--ease);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.upload-form select:focus,
.upload-form input[type="file"]:focus,
.mini-card select:focus,
.mini-card input[type="search"]:focus,
.mini-card input[type="text"]:focus,
.mini-card input[type="password"]:focus,
.mini-card input[type="number"]:focus,
.mini-card input[type="date"]:focus,
.mini-card input[readonly]:focus,
.mini-card textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.mini-card input::placeholder,
.mini-card textarea::placeholder,
.action-row input::placeholder {
  color: var(--text-muted);
}

.mini-card input[readonly] {
  color: var(--text-secondary);
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-base));
}

.mini-card select,
.mini-card input,
.mini-card textarea,
.upload-form select,
.upload-form input[type="file"],
.action-row select {
  appearance: none;
  -webkit-appearance: none;
}

.mini-card textarea {
  min-height: 96px;
  resize: vertical;
}

.upload-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-base);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── PROGRESS ───────────────────────────────────────────────── */
.progress-track {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  overflow: hidden;
}

#progress-bar {
  width: 0%;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--blue);
  transition: width 200ms var(--ease);
}

.log-list {
  margin-top: 14px;
  display: grid;
  gap: 4px;
  max-height: 200px;
  overflow: auto;
  padding-right: 4px;
}

.log-list::-webkit-scrollbar {
  width: 3px;
}

.log-list::-webkit-scrollbar-track {
  background: transparent;
}

.log-list::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: var(--radius-full);
}

.log-entry {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border-left: 2px solid var(--border-hover);
}

/* ─── TABS ───────────────────────────────────────────────────── */
.tab-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tab-btn.active {
  background: var(--blue-soft);
  border-color: var(--blue-border);
  color: var(--blue);
  font-weight: 600;
}

/* ─── METRIC GRID ────────────────────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.metric-card strong {
  display: block;
  margin: 6px 0 4px;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

.metric-foot {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ─── OVERVIEW GRID ──────────────────────────────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

.dq-hero {
  align-items: stretch;
}

.dq-hero-copy {
  max-width: 620px;
}

.dq-hero-meta {
  min-width: 420px;
  justify-content: space-between;
}

.dq-hero-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.dq-meta-nav {
  max-width: 420px;
  justify-content: flex-end;
  gap: 10px;
}

#dq-latest-strip {
  align-items: stretch;
}

#dq-latest-strip .summary-card strong {
  font-size: clamp(1.45rem, 2.4vw, 2.15rem);
  line-height: 1.15;
}

#dq-latest-strip .summary-foot {
  font-size: 0.9rem;
}

#worker-status-panel .metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0;
}

#worker-status-panel .metric-card,
#recent-errors-panel .rule-card {
  height: 100%;
}

.mini-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

/* ─── QUALITY / HEALTH ───────────────────────────────────────── */
.quality-list,
.health-list,
.readiness-list {
  display: grid;
  gap: 10px;
}

.quality-item,
.health-item {
  border-radius: var(--radius-md);
  padding: 12px;
}

.readiness-item {
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.row-between {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.row-between strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ─── PROGRESS BARS ──────────────────────────────────────────── */
.bar-track {
  margin-top: 8px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--bg-base);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 200ms var(--ease);
}

/* ─── TABLES ─────────────────────────────────────────────────── */
.field-table,
.sql-card {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

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

th,
td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-surface);
}

td {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

tr:last-child td {
  border-bottom: none;
}

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

.chart-surface {
  min-height: 220px;
  display: grid;
  gap: 12px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 12px;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.chart-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.branding-preview {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 18px;
  align-items: center;
  min-height: 160px;
}

.branding-preview-logo,
.branding-mini-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.branding-preview-logo {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  padding: 12px;
}

.branding-mini-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  min-width: 280px;
  max-width: 440px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
}

.toast-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(61, 154, 110, 0.24);
}

.toast-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(194, 84, 84, 0.24);
}

/* ─── STATUS & SEVERITY PILLS ────────────────────────────────── */
.status-pill,
.severity-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ─── RULES ──────────────────────────────────────────────────── */
.rules-stack,
.sql-stack {
  display: grid;
  gap: 10px;
}

.rule-card {
  border-radius: var(--radius-lg);
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: border-color var(--duration) var(--ease);
}

.rule-card:hover {
  border-color: var(--border-hover);
}

.rule-card.focused {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px var(--blue-soft);
}

.rule-card details {
  margin-top: 12px;
}

.rule-card summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--duration) var(--ease);
}

.rule-card summary:hover {
  color: var(--text-secondary);
  border-color: var(--border-hover);
}

.rule-card summary::-webkit-details-marker {
  display: none;
}

.rule-sql-wrap {
  margin-top: 12px;
}

.rule-title {
  margin: 0 0 5px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.rule-desc,
.sql-card p,
.empty-state p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.88rem;
}

.rule-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.rule-stat {
  text-align: right;
  flex-shrink: 0;
}

.rule-stat strong {
  display: block;
  font-size: 1.1rem;
  color: var(--text-primary);
}

/* ─── SQL CARDS ──────────────────────────────────────────────── */
.sql-card {
  padding: 16px;
}

.sql-name {
  margin-bottom: 10px;
}

/* ─── CODE BLOCKS ────────────────────────────────────────────── */
pre {
  margin: 0;
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-base);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  border: 1px solid var(--border);
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-base);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--blue);
}

/* ─── ERROR PANEL ────────────────────────────────────────────── */
.error-panel {
  margin-bottom: 14px;
  border-color: rgba(194, 84, 84, 0.12) !important;
}

.error-panel .rule-card {
  background: var(--bg-elevated);
}

.error-panel .panel-eyebrow {
  color: var(--danger);
}

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  padding: 28px;
  border-radius: var(--radius-lg);
  text-align: center;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-hover);
}

/* ─── SPLIT GRID ─────────────────────────────────────────────── */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ─── LOADING SPINNER ────────────────────────────────────────── */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-hover);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 16px auto;
}

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

/* ─── PROGRESS PERCENTAGE ────────────────────────────────────── */
#progress-pct {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

/* ─── LOGIN EXPERIENCE ──────────────────────────────────────── */
.login-shell {
  max-width: 1200px;
  min-height: 100vh;
  display: grid;
  align-items: center;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 440px);
  gap: 24px;
  align-items: stretch;
}

.login-brand-panel,
.login-card {
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.login-brand-panel {
  position: relative;
  padding: 36px;
  background:
    linear-gradient(145deg, rgba(74, 127, 199, 0.12), transparent 42%),
    linear-gradient(180deg, var(--bg-surface), var(--bg-elevated));
}

.login-brand-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(74, 127, 199, 0.12), transparent 28%),
    linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.01));
  pointer-events: none;
}

.login-brand-top,
.login-highlights,
.login-capability-grid,
.login-lead {
  position: relative;
  z-index: 1;
}

.login-brand-top {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.login-product-mark {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue), rgba(74, 127, 199, 0.52));
  color: white;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.login-product-mark__mono {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.16em;
  font-weight: 700;
  transform: translateX(0.08em);
}

.login-lead {
  max-width: 640px;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-highlights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.login-highlight-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.login-highlight-card h2 {
  margin: 6px 0 8px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.login-capability-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.login-capability {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border);
}

.login-capability__label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.login-capability strong {
  display: block;
  font-size: 0.96rem;
  color: var(--text-primary);
}

.login-card {
  padding: 28px;
  background: var(--bg-surface);
  display: grid;
  align-content: center;
}

.login-card__header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.login-card__header h2 {
  margin: 6px 0 8px;
  font-size: 1.5rem;
  font-weight: 650;
  color: var(--text-primary);
}

.login-form {
  gap: 12px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--text-primary);
  padding: 13px 14px;
  font: inherit;
  font-size: 14px;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.login-note {
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: grid;
  gap: 4px;
}

.login-actions {
  margin-top: 8px;
}

.login-submit-btn {
  width: 100%;
  border: 1px solid var(--blue-border);
  background: linear-gradient(135deg, var(--blue), var(--blue-hover));
  color: #fff;
  border-radius: 14px;
  padding: 12px 18px;
  font-family: var(--font-sans);
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), filter var(--duration) var(--ease);
  box-shadow: 0 10px 24px rgba(74, 127, 199, 0.18);
}

.login-submit-btn:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

.login-submit-btn:active {
  transform: translateY(0);
}

.login-status {
  min-height: 24px;
  margin-top: 6px;
}

[data-theme="light"] .login-brand-panel {
  background:
    linear-gradient(145deg, rgba(58, 111, 181, 0.08), transparent 42%),
    linear-gradient(180deg, #ffffff, #f1f3f7);
}

[data-theme="light"] .login-highlight-card {
  background: rgba(255, 255, 255, 0.62);
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 1024px) {

  .summary-strip,
  .metric-grid,
  .overview-grid,
  .split-grid,
  .upload-grid,
  .upload-status-grid {
    grid-template-columns: 1fr;
  }

  .object-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dq-hero-meta {
    min-width: 0;
  }

  .hero-meta {
    min-width: 0;
  }

  .app-nav-bar,
  .session-cluster {
    width: 100%;
  }

  #worker-status-panel .metric-grid {
    grid-template-columns: 1fr;
  }

  .login-layout,
  .login-highlights,
  .login-capability-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-frame {
    padding: 14px 12px 32px;
  }

  .hero,
  .panel {
    padding: 18px;
  }

  .hero {
    flex-direction: column;
  }

  .hero-meta {
    align-items: flex-start;
  }

  .app-nav-bar,
  .meta-stack,
  .session-cluster {
    justify-content: flex-start;
  }

  .app-nav-group {
    justify-content: flex-start;
  }

  .app-tools-list {
    left: 0;
    right: auto;
  }

  .session-chip {
    align-items: flex-start;
    min-width: 0;
  }

  .dq-hero-status,
  .dq-meta-nav {
    justify-content: flex-start;
    max-width: none;
  }

  .results-actions {
    width: 100%;
    align-items: stretch;
  }

  .action-row {
    justify-content: flex-start;
  }

  .object-stats {
    flex-wrap: wrap;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .login-brand-panel,
  .login-card {
    padding: 20px;
  }

  .login-card__header {
    flex-direction: column;
    align-items: flex-start;
  }
}
