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

:root {
  --bg: #0f0f11;
  --bg2: #18181c;
  --bg3: #222228;
  --border: #2e2e36;
  --text: #f0f0f3;
  --muted: #8888a0;
  --accent: #6366f1;
  --accent2: #818cf8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --green-bg: rgba(34,197,94,0.1);
  --yellow-bg: rgba(234,179,8,0.1);
  --red-bg: rgba(239,68,68,0.1);
  --radius: 10px;
  --shadow: 0 2px 16px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
}

/* ===== HEADER ===== */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
}
nav { display: flex; gap: 24px; }
nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: color .2s;
}
nav a:hover { color: var(--text); }

/* ===== LAYOUT ===== */
main { flex: 1; }
.section { padding: 48px 0; }
.section.hidden { display: none; }
.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.container.wide { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ===== HERO ===== */
.hero { text-align: center; margin-bottom: 40px; }
.hero h1 {
  font-size: clamp(24px, 4vw, 40px);
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
}
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto; font-size: 16px; }

/* ===== UPLOAD BOX ===== */
.upload-box {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 56px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg2);
  margin-bottom: 24px;
}
.upload-box:hover, .upload-box.drag-over {
  border-color: var(--accent);
  background: rgba(99,102,241,0.05);
}
.upload-icon { margin-bottom: 16px; }
.upload-label { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.upload-sub { color: var(--muted); margin-bottom: 16px; }
.upload-hint { color: var(--muted); font-size: 13px; margin-top: 16px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: opacity .2s, transform .1s;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }

/* ===== PROGRESS ===== */
.progress-wrap { margin-bottom: 24px; }
.progress-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.progress-track {
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  width: 0%;
  transition: width .3s ease;
}

/* ===== ALERTS ===== */
.alert {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: var(--red-bg); border: 1px solid var(--red); color: #fca5a5; }
.alert-warn { background: var(--yellow-bg); border: 1px solid var(--yellow); color: #fde68a; }
.alert-success { background: var(--green-bg); border: 1px solid var(--green); color: #86efac; }

/* ===== FILE QUEUE ===== */
.file-queue {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.fq-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.fq-item:last-of-type { border-bottom: none; }
.fq-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fq-status { font-size: 18px; flex-shrink: 0; }
.fq-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 380px; }
.fq-meta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fq-tag {
  display: inline-block;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.25);
  color: var(--accent2);
  border-radius: 99px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}
.fq-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.fq-remove:hover { color: var(--red); background: var(--red-bg); }
.fq-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  justify-content: flex-end;
}

/* ===== DOWNLOAD FLOW ===== */
.flow-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.flow-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: background .2s;
}
.flow-header:hover { background: var(--bg3); }
.flow-header-left { display: flex; align-items: center; gap: 12px; }
.flow-header-icon { font-size: 22px; }
.flow-header-title { font-weight: 700; font-size: 15px; }
.flow-header-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.flow-chevron { font-size: 12px; color: var(--muted); transition: transform .25s; }
.flow-chevron.open { transform: rotate(180deg); }
.flow-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 24px 20px;
}
.flow-body.open { display: block; }

/* Steps */
.flow-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.flow-step-start { border-color: var(--accent); }
.flow-step-end { border-color: var(--green); }
.flow-step-num {
  width: 28px; height: 28px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  flex-shrink: 0;
}
.flow-step-icon { font-size: 24px; flex-shrink: 0; line-height: 1.2; }
.flow-step-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.flow-step-desc { font-size: 13px; color: var(--muted); line-height: 1.6; }

.flow-connector {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 0;
  font-weight: 600;
}

/* Branches */
.flow-branches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 4px 0;
}
@media (max-width: 768px) { .flow-branches { grid-template-columns: 1fr; } }

.flow-branch {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.flow-branch-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.flow-branch-body { padding: 14px; }

.flow-nav-path {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.flow-nav-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent2);
}
.flow-nav-arrow { color: var(--muted); font-size: 14px; }

.flow-steps-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.6;
}
.flow-steps-list strong { color: var(--text); }
.flow-steps-list em { font-style: normal; color: var(--muted); }

.flow-label-badge {
  display: inline-block;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  color: var(--accent2);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
}
.flow-mini-tip {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* End step extras */
.flow-files-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.flow-file-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* ===== HOW-TO CARD (legacy, keep for reference) ===== */
.how-to-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.how-to-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  transition: background .2s;
}
.how-to-header:hover { background: var(--bg3); }
.how-to-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}
.how-to-chevron { font-size: 12px; color: var(--muted); transition: transform .25s; }
.how-to-chevron.open { transform: rotate(180deg); }
.how-to-body {
  border-top: 1px solid var(--border);
  padding: 20px;
  display: none;
}
.how-to-body.open { display: block; }
.how-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.how-tab {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.how-tab:hover { color: var(--text); background: var(--bg3); }
.how-tab.active { background: var(--accent); border-color: var(--accent); color: white; }
.how-panel { display: none; }
.how-panel.active { display: block; }
.how-panel ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.how-panel li { font-size: 13px; color: var(--text); line-height: 1.6; }
.how-panel strong { color: var(--accent2); }
.how-panel em { color: var(--muted); font-style: normal; background: var(--bg3); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.how-notice {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
}
.how-notice strong { color: var(--text); display: block; margin-bottom: 2px; }
.how-notice em { font-style: normal; color: var(--accent2); font-weight: 600; }
.how-notice-tip {
  background: rgba(99,102,241,0.07);
  border-color: rgba(99,102,241,0.25);
}
.how-notice-icon { font-size: 18px; flex-shrink: 0; line-height: 1.4; }

.re-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.re-tag {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin: 3px 3px 0 0;
}

.how-path {
  font-size: 12px;
  color: var(--accent2);
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 6px;
  padding: 6px 12px;
  margin-bottom: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.how-path em { font-style: normal; color: var(--text); }
.how-tip {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
}

/* ===== FEATURES ===== */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 48px;
}
.feature-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.feature-icon { font-size: 28px; display: block; margin-bottom: 12px; }
.feature-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 13px; color: var(--muted); }

/* ===== RESULTS HEADER ===== */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}
.results-header h2 { font-size: 24px; font-weight: 800; }
.results-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.text-muted { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ===== KPI GRID ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 800; }
.kpi-card.green { border-color: var(--green); }
.kpi-card.yellow { border-color: var(--yellow); }
.kpi-card.red { border-color: var(--red); }
.kpi-card.green .kpi-value { color: var(--green); }
.kpi-card.yellow .kpi-value { color: var(--yellow); }
.kpi-card.red .kpi-value { color: var(--red); }

/* ===== ALERT BANNERS ===== */
#alerts-section { margin-bottom: 24px; }
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
}
.alert-banner.red { background: var(--red-bg); border: 1px solid var(--red); }
.alert-banner.yellow { background: var(--yellow-bg); border: 1px solid var(--yellow); }
.alert-banner.green { background: var(--green-bg); border: 1px solid var(--green); }

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== PANEL CONTENT ===== */
.panel-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}
.panel-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; margin-bottom: 24px; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg3);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.badge-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow); }
.badge-red { background: var(--red-bg); color: var(--red); border: 1px solid var(--red); }

/* ===== BAR CHARTS ===== */
.chart-section { margin-bottom: 32px; }
.chart-section h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.chart-section .chart-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-item { display: flex; align-items: center; gap: 12px; }
.bar-item-label {
  width: 180px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  flex: 1;
  height: 20px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .5s ease;
}
.bar-fill.green { background: var(--green); }
.bar-fill.yellow { background: var(--yellow); }
.bar-fill.red { background: var(--red); }
.bar-fill.blue { background: var(--accent); }
.bar-value {
  width: 80px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* ===== HEATMAP ===== */
.heatmap-wrap { overflow-x: auto; margin-bottom: 24px; }
.heatmap-grid {
  display: grid;
  gap: 3px;
  min-width: 600px;
}
.heatmap-cell {
  border-radius: 3px;
  aspect-ratio: 1;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  cursor: default;
  position: relative;
}
.heatmap-label { font-size: 11px; color: var(--muted); text-align: center; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}
.legend-gradient {
  height: 10px;
  width: 120px;
  border-radius: 99px;
  background: linear-gradient(to right, #1e3a5f, #22c55e);
}

/* ===== GRID HELPERS ===== */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

/* ===== EXCLUSION LIST ===== */
.exclusion-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.exclusion-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  flex-wrap: wrap;
  gap: 8px;
}
.exclusion-name { font-weight: 600; word-break: break-all; }
.exclusion-stats { color: var(--muted); font-size: 12px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 14px;
}

/* ===== UTILS ===== */
.hidden { display: none !important; }
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.mb-24 { margin-bottom: 24px; }

/* ===== FOOTER ===== */
footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
