:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #94a3b8;
  --text: #0f172a;
  --text2: #475569;
  --text3: #94a3b8;
  --brand: #6366f1;
  --brand2: #4f46e5;
  --brand-bg: #eef2ff;
  --green: #10b981;
  --green-bg: #ecfdf5;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.6;
}

/* --- TOP BAR --- */
.nav-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-logo { width: 28px; height: 28px; }
.nav-inner h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-docs {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.15s;
}
.nav-docs:hover { background: var(--surface2); color: var(--text); }

/* --- PAGE --- */
.page-shell {
  width: min(1320px, calc(100vw - 40px));
  margin: 24px auto 40px;
}

/* --- HERO --- */
.hero {
  text-align: center;
  padding: 40px 20px 32px;
}
.hero h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 8px;
}
.hero p {
  color: var(--text2);
  font-size: 15px;
}

/* --- LAYOUT --- */
.layout-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* --- SECTION HEADER --- */
.section-heading {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.section-heading h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.section-heading p {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

/* --- UPLOAD FORM --- */
.stacked-form {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="file"],
.field select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-bg);
}
.field select[multiple] {
  min-height: 100px;
}
.field small {
  font-size: 11px;
  color: var(--text3);
}
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}
.checkbox-field input { accent-color: var(--brand); }

/* --- BUTTONS --- */
button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s;
}
.stacked-form button[type="submit"],
.stacked-form .primary-btn {
  background: var(--brand);
  color: white;
  padding: 10px 18px;
  box-shadow: 0 1px 2px rgba(99,102,241,0.3);
}
.stacked-form button[type="submit"]:hover,
.stacked-form .primary-btn:hover {
  background: var(--brand2);
  box-shadow: var(--shadow-hover);
}
.secondary-button {
  font-size: 11px;
  padding: 4px 10px;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border);
}
.secondary-button:hover { background: var(--border); }

/* --- STATUS --- */
.status-panel {
  margin: 0 20px 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
.status-panel.neutral { background: var(--surface2); color: var(--text2); }
.status-panel.success { background: var(--green-bg); color: #065f46; }
.status-panel.error { background: var(--red-bg); color: #991b1b; }

/* --- WORKFLOW TABS --- */
.workflow-selector { padding: 0 20px 12px; }
.workflow-selector > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 8px;
}
.wf-tabs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.wf-tab {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
}
.wf-tab:hover { background: var(--brand-bg); color: var(--brand); }
.wf-tab.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  box-shadow: 0 1px 3px rgba(99,102,241,0.3);
}

/* --- CONFIG PANELS --- */
.wf-config-panel {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.wf-config-panel .section-heading {
  margin: -16px -20px 16px;
  background: var(--surface2);
}
.wf-config-panel .section-heading.compact { padding: 12px 20px; }

/* --- RESULTS PANEL --- */
.results-panel .section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- TABLE BLOCKS --- */
.table-block {
  padding: 0 20px 16px;
}
.hidden { display: none !important; }
.table-block.hidden { display: none; }
.table-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.table-block-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.meta-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--brand-bg);
  color: var(--brand);
  font-weight: 500;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table-wrap th {
  background: var(--surface2);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.table-wrap td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-wrap tr:hover td { background: #f8fafc; }
.table-wrap tr.problem-row td { background: var(--red-bg); }
.table-wrap tr.problem-row:hover td { background: #fee2e2; }

/* --- PLAIN-LANGUAGE FINDINGS --- */
.insights-panel {
  margin: 4px 20px 20px;
  padding: 16px;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  background: var(--amber-bg);
}
.insights-panel h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.insights-note {
  margin: 2px 0 12px;
  color: var(--text2);
  font-size: 12px;
}
.insights-list {
  display: grid;
  gap: 8px;
}
.insights-list article {
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: 6px;
  background: var(--surface);
}
.insights-list strong {
  display: block;
  color: var(--text);
  font-size: 12px;
  margin-bottom: 2px;
}
.insights-list p {
  color: var(--text2);
  font-size: 12px;
  line-height: 1.5;
}

/* --- META CHIPS --- */
.meta-grid {
  display: flex;
  gap: 10px;
  padding: 0 20px 16px;
  flex-wrap: wrap;
}
.meta-grid.hidden { display: none; }
.meta-chip {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meta-chip span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
}
.meta-chip strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.meta-chip.big { min-width: 100px; }
.meta-chip.big strong { font-size: 20px; color: var(--brand); }

/* --- WF RESULT GROUPS --- */
.wf-result-group { }
.wf-result-group.hidden { display: none; }

/* --- COVERAGE --- */
.capability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 0 20px 16px;
}
.capability-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.capability-card > .cap-wf {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--brand);
}
.capability-card strong {
  display: block;
  font-size: 14px;
  margin: 4px 0;
}
.capability-card p {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 6px;
}
.capability-card .cap-items {
  font-size: 11px;
  color: var(--text3);
  font-family: "IBM Plex Mono", monospace;
}

/* --- DATASET PREVIEW --- */
#dataset-preview.hidden { display: none; }
#dataset-preview { border-bottom: 1px solid var(--border); }

/* --- DOCS MODAL --- */
#docs-modal.hidden { display: none; }
#docs-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.docs-scrim { position: absolute; inset: 0; background: rgba(15,23,42,0.5); backdrop-filter: blur(4px); }
.docs-modal {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 640px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.docs-modal h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.docs-modal h3 { font-size: 15px; font-weight: 600; margin: 20px 0 8px; color: var(--brand); }
.docs-modal p { font-size: 13px; color: var(--text2); line-height: 1.7; margin-bottom: 6px; }
.docs-modal pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
  overflow-x: auto;
  margin: 8px 0;
}
.docs-close {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 24px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.docs-close:hover { background: var(--surface2); color: var(--text); }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
  .layout-grid { grid-template-columns: 1fr; }
}
