:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --surface: #fff;
  --sidebar: #f7f7f7;
  --border: #e6e6e6;
  --border-strong: #d8d8d8;
  --text: #212121;
  --muted: #6b6b6b;
  --purple: #c2410c;
  --purple-soft: #fff1eb;
  --accent: #ff6c37;
  --focus: #0265d2;
  --green: #087c6e;
  --green-fill: #0ab39c;
  --green-soft: #eaf9f6;
  --red: #b9472e;
  --red-fill: #f06548;
  --red-soft: #fff1ee;
  --orange: #805b14;
  --orange-fill: #f7b84b;
  --orange-soft: #fff8e8;
  --technical: #4b556d;
  --technical-fill: #878a99;
  --technical-soft: #f2f4f7;
  --chart-track: #eef0f3;
  --sidebar-width: 232px;
  --topbar-height: 56px;
  --card-radius: 6px;
  --card-header-bg: #fafafa;
  --table-header-bg: #f7f7f7;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }
.is-hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 5px;
  color: #8a8a8a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.brand-mark, .sidebar-brand { font-size: 25px; font-weight: 800; letter-spacing: -0.06em; }
.brand-mark span, .sidebar-brand span { color: var(--purple); }
textarea, select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
textarea { resize: vertical; padding: 10px; }
input:focus, textarea:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-soft); }
.form-message { min-height: 18px; margin: 10px 0 0; color: var(--red); font-size: 12px; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 18px;
}
.menu-title {
  margin: 0;
  padding: 14px 16px 6px;
  color: #969696;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.menu { display: grid; gap: 2px; }
.menu-link {
  position: relative;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1px 8px;
  padding: 7px 10px;
  border-radius: 4px;
  color: #4b4b4b;
  font-weight: 500;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease;
}
.menu-link:hover { background: #efefef; }
.menu-link.is-active { background: #eaeaea; color: var(--text); font-weight: 600; }
.menu-link.is-active::before {
  position: absolute;
  inset: 7px auto 7px 0;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  content: "";
}
.menu-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.menu-link > span:first-child { width: 20px; color: #666; text-align: center; }
.menu-count {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.sidebar-account {
  margin-top: auto;
  display: grid;
  grid-template-columns: 32px 1fr 28px;
  align-items: center;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-account strong, .sidebar-account span { display: block; }
.sidebar-account span { margin-top: 1px; color: var(--muted); font-size: 11px; }
.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 11px;
  font-weight: 800;
}

.main-column { min-width: 0; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  z-index: 15;
  top: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.burger { display: none; border: 0; background: none; font-size: 20px; }
.workspace-switch span, .period-label { display: block; color: #919191; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.workspace-switch strong { display: block; margin-top: 2px; font-size: 12px; }
.period-control { display: flex; align-items: center; gap: 9px; margin-left: 18px; }
.period-chips { display: flex; gap: 3px; }
.period-chips button {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: #666;
}
.period-chips button:hover { background: #f2f2f2; }
.period-chips button.is-active {
  border-color: rgba(194, 65, 12, 0.3);
  background: var(--purple-soft);
  color: var(--purple);
  font-weight: 650;
}
.topbar-spacer, .review-spacer { flex: 1; }
.sync-state { color: var(--muted); font-size: 11px; }

.button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 600;
  text-decoration: none;
}
.button:disabled { cursor: not-allowed; opacity: 0.5; }
.button-wide { width: 100%; margin-top: 15px; }
.button-primary { background: var(--text); color: #fff; }
.button-quiet { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.button-success { background: var(--green-fill); color: #fff; }
.button-danger { background: var(--red-soft); border-color: #f5cfd3; color: var(--red); }
.icon-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #666;
  font-size: 18px;
}
.icon-button:hover { background: #ececec; }

.content { padding: 20px; }
.dashboard-tabs {
  position: sticky;
  z-index: 14;
  top: var(--topbar-height);
  max-width: 100%;
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin: 0 0 18px;
  padding: 6px;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(33, 33, 33, 0.1);
}
.dashboard-tab {
  position: relative;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}
.dashboard-tab:hover { color: var(--text); background: #fafafa; }
.dashboard-tab.is-active {
  border-color: rgba(194, 65, 12, 0.16);
  background: var(--purple-soft);
  color: var(--purple);
}
.dashboard-tab.is-active::after {
  position: absolute;
  right: 14px;
  bottom: 3px;
  left: 14px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
  content: "";
}
.dashboard-tab:focus-visible { z-index: 1; outline: 3px solid var(--focus); outline-offset: -3px; }
.dashboard-panel[hidden] { display: none; }
.dashboard-panel:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.page-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.page-title h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.page-title .muted { margin: 5px 0 0; }
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f0f0f0;
  color: #676767;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-success { background: var(--green-soft); color: var(--green); }

.diagnostics-card { border-left: 3px solid var(--orange-fill); }
.diagnostic-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.diagnostic-summary > div { padding: 12px 16px; background: var(--surface); }
.diagnostic-summary span { display: block; color: var(--muted); font-size: 10px; }
.diagnostic-summary strong { display: block; margin-top: 4px; font-size: 12px; }
.diagnostic-events { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.diagnostic-event {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 12px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
}
.diagnostic-event:last-child { border-bottom: 0; }
.diagnostic-event code { color: var(--orange); font-size: 10px; }
.diagnostic-info code { color: var(--green); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi-card, .card { border: 1px solid var(--border); border-radius: var(--card-radius); background: var(--surface); }
.kpi-card { min-height: 112px; padding: 17px; }
.kpi-outcome { border-top-width: 3px; text-decoration: none; }
.kpi-outcome:hover { background: #fafafa; }
.kpi-outcome-pass { border-top-color: var(--green-fill); }
.kpi-outcome-issue { border-top-color: var(--red-fill); }
.kpi-outcome-unable { border-top-color: var(--orange-fill); }
.kpi-outcome-technical { border-top-color: var(--technical-fill); }
.kpi-card > span { color: var(--muted); font-size: 11px; font-weight: 600; }
.kpi-card strong { display: block; margin: 8px 0 5px; font-size: 25px; line-height: 1; letter-spacing: -0.04em; }
.kpi-card small { color: var(--muted); }
.kpi-alert { background: linear-gradient(145deg, #fff 40%, var(--red-soft)); }
.kpi-alert strong { color: var(--red); }

.dashboard-grid { display: grid; grid-template-columns: 2fr minmax(280px, 1fr); gap: 12px; margin-bottom: 12px; }
.card { min-width: 0; margin-bottom: 12px; }
.card-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--card-radius) var(--card-radius) 0 0;
  background: var(--card-header-bg);
}
.card-header h3 { margin: 0; font-size: 14px; }
.card-header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.card-body { padding: 16px; }
.legend { color: var(--muted); font-size: 11px; }

.trend-chart { min-height: 238px; display: flex; align-items: stretch; gap: 8px; overflow-x: auto; }
.trend-day { min-width: 44px; flex: 1; display: grid; grid-template-rows: 1fr auto auto; gap: 7px; text-align: center; }
.trend-track { min-height: 170px; display: flex; align-items: end; justify-content: center; border-bottom: 1px solid var(--border); }
.trend-bar { width: min(24px, 65%); min-height: 3px; border-radius: 4px 4px 0 0; background: #8a8a8a; }
.trend-day strong { font-size: 11px; }
.trend-day small { color: var(--muted); font-size: 9px; }
.category-list { display: grid; gap: 15px; }
.category-row { display: grid; grid-template-columns: minmax(105px, 1fr) 2fr 32px; align-items: center; gap: 9px; }
.category-row strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 7px; overflow: hidden; border-radius: 5px; background: var(--chart-track); }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--purple); }
.category-row > span:last-child { color: var(--muted); text-align: right; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; border-bottom: 1px solid #ededed; text-align: left; vertical-align: middle; }
th { background: var(--table-header-bg); color: var(--muted); font-size: 13px; font-weight: 600; }
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: 0; }
.agent-cell { display: flex; align-items: center; gap: 9px; font-weight: 650; }
.mini-avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #ececec; font-size: 10px; }
.tag, .severity {
  display: inline-flex;
  margin: 2px 3px 2px 0;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f0f0f0;
  color: #5d5d5d;
  font-size: 10px;
  white-space: nowrap;
}
.severity-critical { background: #ffe5e8; color: #a82432; }
.severity-high { background: var(--orange-soft); color: var(--orange); }
.severity-medium { background: #f1ebff; color: #6841bf; }
.severity-low { background: #edf3f8; color: #516879; }
.outcome { font-weight: 750; letter-spacing: 0.02em; }
.outcome-pass { background: var(--green-soft); color: var(--green); }
.outcome-issue { background: var(--red-soft); color: var(--red); }
.outcome-insufficient_evidence { background: var(--orange-soft); color: var(--orange); }
.outcome-technical_failure { background: var(--technical-soft); color: var(--technical); }
.outcome-text { font-weight: 750; }
.outcome-text-pass { color: var(--green); }
.outcome-text-issue { color: var(--red); }
.outcome-text-insufficient_evidence { color: var(--orange); }
.outcome-text-technical_failure { color: var(--technical); }
.human-verdict-unreviewed { background: var(--technical-soft); color: var(--technical); }
.human-verdict-unreviewed-text { color: var(--muted); }
.risk-value { font-weight: 750; }
.risk-high { color: var(--red); }
.risk-medium { color: var(--orange); }
.risk-low { color: var(--green); }
.limited-sample { color: var(--muted); font-size: 10px; }

.repeated-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.repeated-item { display: grid; grid-template-columns: 36px 1fr; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.repeated-item:nth-child(odd) { border-right: 1px solid var(--border); }
.repeated-item strong:first-child { color: var(--purple); font-size: 20px; }
.repeated-item p { margin: 0 0 5px; font-weight: 600; }
.finding-heading { align-items: flex-end; }
.finding-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.finding-filters label span { display: block; margin: 0 0 3px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.finding-filters select { min-width: 112px; height: 31px; padding: 0 27px 0 8px; }
.finding-summary { max-width: 420px; font-weight: 550; }
.row-action { color: #6841bf; font-weight: 650; background: none; border: 0; }
.traceability-error { color: var(--red); font-size: 10px; }
.review-unreviewed { color: var(--orange); }
.review-confirmed { color: var(--green); }
.review-false_positive { color: var(--red); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); }
.pagination span { color: var(--muted); font-size: 11px; }

.finding-dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.finding-dialog::backdrop { background: rgba(20, 20, 20, 0.42); backdrop-filter: blur(2px); }
.dialog-header { display: flex; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: 19px; }
.dialog-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 20px; background: #fafafa; border-bottom: 1px solid var(--border); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; }
.detail-grid section { min-height: 145px; padding: 17px 20px; border-bottom: 1px solid var(--border); }
.detail-grid section:nth-child(odd) { border-right: 1px solid var(--border); }
.detail-grid h3 { margin: 0 0 9px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.detail-grid p, blockquote { margin: 0; line-height: 1.55; white-space: pre-wrap; }
.detail-grid blockquote { padding-left: 12px; border-left: 3px solid var(--border-strong); }
.detail-grid .recommended { background: #f5fbf9; }
.review-form { padding: 16px 20px 18px; }
.review-form label { margin: 0 0 7px; }
.review-form label span { color: var(--muted); font-weight: 400; }
.adjudication-actions { display: flex; align-items: center; gap: 8px; }
.adjudication-actions > span { flex: 1; color: var(--muted); font-size: 11px; }
.adjudication-actions > .outcome-text-pass { color: var(--green); }
.adjudication-actions > .outcome-text-issue { color: var(--red); }
.review-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.toast { position: fixed; z-index: 50; right: 18px; bottom: 18px; padding: 11px 14px; border-radius: 5px; background: #222; color: #fff; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 180ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.empty-state { padding: 38px 18px; color: var(--muted); text-align: center; }

@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .period-control { margin-left: 0; }
  .workspace-switch { display: none; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform 180ms ease; box-shadow: 12px 0 40px rgba(0, 0, 0, 0.12); }
  .sidebar.is-open { transform: translateX(0); }
  .main-column { margin-left: 0; }
  .burger { display: block; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .finding-heading { align-items: flex-start; flex-direction: column; }
  .finding-filters { width: 100%; }
  .finding-filters label { flex: 1; min-width: 130px; }
  .diagnostic-summary { grid-template-columns: repeat(2, 1fr); }
  .diagnostic-event { grid-template-columns: 1fr; gap: 3px; }
}

@media (max-width: 560px) {
  .content { padding: 14px; }
  .topbar { padding: 0 10px; }
  .period-label, .sync-state, #refresh-button { display: none; }
  .period-chips button { padding: 0 6px; font-size: 11px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 94px; }
  .repeated-list { grid-template-columns: 1fr; }
  .repeated-item:nth-child(odd) { border-right: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid section:nth-child(odd) { border-right: 0; }
  .review-actions { align-items: stretch; flex-direction: column; }
  .adjudication-actions { align-items: stretch; flex-direction: column; }
  .review-spacer { display: none; }
  .review-actions .button { width: 100%; }
}
