:root {
  color-scheme: light;
  --bg: #eef3f8;
  --bg-2: #f7fafc;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --panel-3: #eef3f8;
  --text: #111827;
  --muted: #687386;
  --line: #d8e0ea;
  --line-strong: #bdc8d7;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #e8efff;
  --steel: #132033;
  --steel-2: #1f2d42;
  --steel-3: #314158;
  --cyan: #23b5d3;
  --good: #0f9f6e;
  --warn: #d99a00;
  --risk: #e37019;
  --bad: #c6283a;
  --neutral: #778395;
  --shadow: 0 18px 42px rgba(23, 35, 57, .10);
  --shadow-sm: 0 7px 18px rgba(23, 35, 57, .08);
  --radius: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 1180px;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(35, 181, 211, .08), transparent 22%),
    radial-gradient(circle at 20% 0%, rgba(37, 99, 235, .18), transparent 32%),
    radial-gradient(circle at 92% 12%, rgba(19, 32, 51, .14), transparent 30%),
    repeating-linear-gradient(90deg, rgba(17, 24, 39, .035) 0, rgba(17, 24, 39, .035) 1px, transparent 1px, transparent 32px),
    linear-gradient(180deg, #f8fbff 0%, #edf2f7 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0) 28%);
  z-index: -1;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3ccd8; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #99a8bc; border: 2px solid transparent; background-clip: content-box; }

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(19, 32, 51, .98), rgba(31, 45, 66, .96) 48%, rgba(15, 23, 42, .98)),
    linear-gradient(135deg, rgba(35,181,211,.28), transparent 42%);
  border-bottom: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 22px 48px rgba(9, 16, 28, .24);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--primary), #f59e0b);
  opacity: .9;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #b8c7dc;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 800;
}
.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34,197,94,.15), 0 0 22px rgba(34,197,94,.70);
}
h1 { font-size: 24px; line-height: 1.12; margin: 6px 0 0; letter-spacing: -.03em; }
h2 { font-size: 16px; line-height: 1.25; margin: 0; letter-spacing: -.015em; }
h3 { font-size: 14px; margin: 0 0 14px; color: #1f2937; }
.top-actions { display: flex; gap: 12px; align-items: center; }

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}
.workspace { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.panel {
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(202, 213, 226, .92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(248,250,252,.82));
}
.panel-header.split { align-items: flex-start; gap: 20px; }
.muted { color: var(--muted); font-size: 13px; }

.queue {
  height: calc(100vh - 132px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 112px;
}
.queue .panel-header {
  background: linear-gradient(135deg, var(--steel), var(--steel-2));
  color: #fff;
}
.queue .panel-header .muted { color: #b8c7dc; }
.toolbox, .filters { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.toolbox label, .filters label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.inline { display: flex; gap: 8px; margin-bottom: 10px; }

.hint.small {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: rgba(255,255,255,.96);
  color: var(--text);
  outline: none;
  font: inherit;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:hover, select:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(37,99,235,.72);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
  background: #fff;
}

.btn {
  border: 0;
  border-radius: 13px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 850;
  color: #0f172a;
  transition: transform .12s ease, opacity .16s ease, box-shadow .16s ease, background .16s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,.55) inset;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #0f4cc9);
}
.btn.primary:hover { background: linear-gradient(135deg, #3473ff, var(--primary-2)); }
.btn.secondary {
  color: #17305d;
  background: linear-gradient(180deg, #f5f8ff, #e6edf9);
  border: 1px solid #d2ddec;
}
.btn.full { width: 100%; }
.upload-label {
  display: block;
  text-align: center;
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed #91a7c4;
  border-radius: 14px;
  color: #17305d;
  cursor: pointer;
  background: linear-gradient(180deg, #f8fbff, #eef4fb);
  font-weight: 800;
}
.upload-label:hover { border-color: var(--primary); background: #eff5ff; }
.upload-label input { display: none; }
.filters { display: flex; flex-direction: column; gap: 9px; }
.case-list { overflow: auto; padding: 12px; }
.case-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 10px;
  background: rgba(255,255,255,.92);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(17,24,39,.04);
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.case-item:hover, .case-item.active {
  transform: translateY(-1px);
  border-color: rgba(37,99,235,.62);
  background: linear-gradient(180deg, #ffffff, #f0f6ff);
  box-shadow: 0 12px 28px rgba(37,99,235,.13);
}
.case-item.active { box-shadow: 0 0 0 3px rgba(37,99,235,.10), 0 12px 28px rgba(37,99,235,.13); }
.case-item .case-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 900; font-size: 13px; }
.case-item .case-name { margin: 8px 0; font-size: 13px; color: #334155; }
.case-item .case-meta { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid transparent;
}
.badge.neutral { background: #eef2f7; color: #465568; border-color: #d9e1eb; }
.badge.good { background: #e5fbf2; color: #067350; border-color: #bcefdc; }
.badge.warn { background: #fff6d7; color: #815700; border-color: #f6df91; }
.badge.risk { background: #fff0dc; color: #963f00; border-color: #f4ca99; }
.badge.bad { background: #ffe8ed; color: #9f1528; border-color: #f3bdc8; }
.badge.running { background: #e8f0ff; color: #174bb0; border-color: #c4d6ff; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.kpi {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(247,250,252,.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 17px 18px;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(180deg, var(--cyan), var(--primary));
}
.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.kpi strong { font-size: 22px; letter-spacing: -.02em; }
.center-grid { display: grid; grid-template-columns: minmax(620px, 1fr) 430px; gap: 18px; }
.viewer { min-height: 540px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stacked-actions { flex-direction: column; align-items: stretch; min-width: 430px; }
.validation-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ai-settings {
  border: 1px solid #cfdae8;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffffff, #eff5fb);
  padding: 11px;
  text-align: left;
  box-shadow: 0 8px 18px rgba(17,24,39,.05) inset;
}
.ai-settings label {
  display: block;
  color: #43516a;
  font-size: 12px;
  margin-bottom: 7px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.ai-settings-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.ai-settings-row input { min-width: 250px; }
.ai-settings .muted { margin-top: 7px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 14px 0;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f9fbfd, #f1f5f9);
}
.tabs button {
  border: 1px solid transparent;
  background: transparent;
  padding: 10px 14px;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  font-weight: 900;
  color: #526073;
}
.tabs button:hover { color: var(--primary); background: rgba(255,255,255,.65); }
.tabs button.active {
  background: #fff;
  color: var(--primary);
  border-color: var(--line);
  border-bottom-color: #fff;
  margin-bottom: -1px;
}
.tab-content { display: none; padding: 18px; max-height: 590px; overflow: auto; }
.tab-content.active { display: block; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.info-card {
  border: 1px solid var(--line);
  border-radius: 17px;
  background: linear-gradient(180deg, #ffffff, #f7fafc);
  padding: 15px;
}
.info-card dt { color: var(--muted); font-size: 12px; font-weight: 800; }
.info-card dd { margin: 4px 0 11px; font-weight: 800; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; overflow: hidden; border-radius: 14px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 10px 9px; text-align: left; vertical-align: top; }
.table th { background: #edf3f9; color: #4b5d73; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table tr:hover td { background: #f8fbff; }
.material-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px;
  margin-bottom: 10px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.json-viewer, .report-viewer {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  background: linear-gradient(180deg, #101827, #162237);
  color: #e7eefc;
  border-radius: 16px;
  padding: 17px;
  overflow: auto;
  box-shadow: 0 16px 34px rgba(15,23,42,.16) inset;
}
.report-viewer { background: #f8fbff; color: var(--text); border: 1px solid var(--line); max-height: 540px; box-shadow: none; }
.report-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }

.process-panel { max-height: 790px; display: flex; flex-direction: column; }
.timeline { padding: 15px 18px; overflow: auto; max-height: 340px; }
.timeline-item { position: relative; padding: 0 0 16px 28px; border-left: 2px solid var(--line); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #aab7c8;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--line);
}
.timeline-item.completed::before { background: var(--good); }
.timeline-item.running::before { background: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.18), 0 0 20px rgba(37,99,235,.32); }
.timeline-item.warning::before { background: var(--warn); }
.timeline-item.failed::before { background: var(--bad); }
.timeline-item .time { color: var(--muted); font-size: 11px; font-weight: 700; }
.timeline-item .stage { font-weight: 900; font-size: 13px; margin-bottom: 3px; }
.timeline-item .msg { font-size: 12px; color: #43536a; }
.agents-header { margin-top: auto; }
.agents { padding: 13px 18px; overflow: auto; max-height: 350px; }
.agent-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
  background: linear-gradient(180deg, #fff, #f7fbff);
  box-shadow: 0 5px 16px rgba(17,24,39,.04);
}
.agent-card .agent-title { font-weight: 900; font-size: 13px; }
.agent-card .agent-summary { font-size: 12px; color: #43546b; margin-top: 8px; }
.conf { height: 8px; background: #e7edf5; border-radius: 999px; overflow: hidden; margin-top: 9px; }
.conf span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--primary)); }

.findings-panel { overflow: hidden; }
.findings-list { padding: 13px 18px; max-height: 340px; overflow: auto; }
.finding {
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 16px;
  padding: 13px;
  margin-bottom: 11px;
  background: linear-gradient(180deg, #fff, #f9fbfd);
}
.finding.critical { border-left-color: var(--bad); }
.finding.major { border-left-color: var(--risk); }
.finding.minor { border-left-color: var(--warn); }
.finding.info { border-left-color: var(--neutral); }
.finding .finding-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 900; }
.finding .finding-msg { margin: 9px 0; color: #334158; }
.finding .finding-rec { color: #50617a; font-size: 13px; }

.analytics-panel { padding-bottom: 17px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 17px; }
.chart-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  min-height: 230px;
  box-shadow: 0 8px 22px rgba(17,24,39,.05);
}
.chart-card.wide { grid-column: 1 / -1; }
.donut {
  width: 166px;
  height: 166px;
  border-radius: 50%;
  margin: 5px auto 15px;
  background: conic-gradient(#d8e2f0 0 100%);
  position: relative;
  box-shadow: 0 12px 24px rgba(17,24,39,.10);
}
.donut::after { content: ""; position: absolute; inset: 36px; background: #fff; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }
.bar-row { display: grid; grid-template-columns: 118px 1fr 38px; align-items: center; gap: 9px; margin: 9px 0; font-size: 12px; }
.bar { height: 13px; border-radius: 999px; background: #e6edf6; overflow: hidden; box-shadow: inset 0 1px 2px rgba(17,24,39,.08); }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--primary)); border-radius: inherit; }
.heatmap table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; overflow: hidden; border-radius: 14px; }
.heatmap th, .heatmap td { border: 1px solid var(--line); padding: 9px; text-align: center; }
.heatmap th { background: #edf3f9; color: #475569; }
.heat-0 { background: #f8fbff; }
.heat-1 { background: #e5fbf2; }
.heat-2 { background: #fff6d7; }
.heat-3 { background: #fff0dc; }
.heat-4 { background: #ffe8ed; }
.ranking-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 9px 0; font-size: 13px; }
.agent-quality .quality-row { display: grid; grid-template-columns: 94px 1fr 48px; gap: 9px; align-items: center; margin: 9px 0; font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 540px;
  padding: 15px 17px;
  background: linear-gradient(135deg, var(--steel), var(--steel-2));
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  box-shadow: 0 22px 52px rgba(9,16,28,.26);
  z-index: 99;
}
.toast.hidden { display: none; }

@media (max-width: 1300px) {
  body { min-width: 1040px; }
  .layout { grid-template-columns: 290px minmax(0, 1fr); }
  .center-grid { grid-template-columns: 1fr; }
  .stacked-actions { min-width: 0; width: 100%; }
  .process-panel { max-height: none; }
  .queue { position: static; height: calc(100vh - 132px); }
}
