:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --line: #dbe4f1;
  --line-2: #bfcee2;
  --text: #142037;
  --muted: #66758d;
  --muted-2: #8a98ac;
  --navy: #172b67;
  --brand-blue: #1f66cf;
  --soft-blue: #dcecff;
  --accent: #1f66cf;
  --accent-2: #1f66cf;
  --accent-bg: #e7f0ff;
  --selected-bg: #dcecff;
  --warn: #936000;
  --warn-bg: #fff4dc;
  --bad: #b13b4a;
  --bad-bg: #fde8eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f7f9ff 0, var(--bg) 180px);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
select,
input {
  font: inherit;
}

.appHeader {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topLine,
.filterPanel,
.workspaceHeader,
.detailHeader,
main {
  max-width: 1480px;
  margin: 0 auto;
}

.topLine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 22px 5px;
}

.topLine h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 760;
  color: var(--navy);
  letter-spacing: 0;
}

.topLine p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

#generated::before {
  content: " · ";
}

.headerActions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.topLine .headerStats {
  margin-left: auto;
}

.topLine .headerStats > div {
  min-width: 78px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f7fbff;
}

.topLine .headerStats strong {
  font-size: 15px;
}

.pageNav {
  display: flex;
  gap: 3px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 22px;
  border-top: 1px solid #eef1f4;
}

.pageNav button {
  min-width: 86px;
  min-height: 31px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 720;
}

.pageNav button.active {
  color: var(--navy);
  border-color: var(--brand-blue);
}

.filterPanel {
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(180px, 220px) minmax(240px, 310px) 1fr;
  gap: 10px;
  align-items: end;
  padding: 6px 22px;
}

label,
fieldset {
  display: grid;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  color: #354255;
  font-size: 12px;
  font-weight: 760;
}

legend {
  margin-bottom: 4px;
  color: #354255;
  font-size: 12px;
  font-weight: 760;
}

select {
  width: 100%;
  min-height: 31px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 5px 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  min-height: 29px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 760;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: #fff;
  background: var(--brand-blue);
}

.ruleText {
  align-self: center;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.secondary,
.download {
  min-height: 30px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 5px 10px;
  text-decoration: none;
  font-weight: 700;
}

.secondary {
  cursor: pointer;
}

.download {
  display: inline-flex;
  align-items: center;
}

.secondary:hover,
.download:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

main {
  padding: 10px 22px 22px;
}

.workspaceHeader {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 22px 4px;
  margin-bottom: 0;
  border-top: 1px solid #eef1f4;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  font-size: 17px;
}

#subtitle {
  margin: 3px 0 0;
  color: var(--muted);
}

.headerStats,
.metrics,
.summaryGrid {
  display: grid;
  gap: 10px;
}

.headerStats {
  grid-template-columns: repeat(2, minmax(92px, 1fr));
}

.metrics,
.summaryGrid {
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  margin-bottom: 12px;
}

.headerStats > div,
.metrics > div,
.summaryGrid > div,
figure,
.tableWrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.headerStats > div,
.metrics > div,
.summaryGrid > div {
  padding: 6px 9px;
}

.headerStats span,
.metrics span,
.summaryGrid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.headerStats strong,
.metrics strong,
.summaryGrid strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.15;
}

.summaryGrid p {
  margin: 6px 0 0;
  color: var(--muted);
}

.controlBar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.controlBar label,
.inlineControls label {
  min-width: 170px;
}

.controlBar .check {
  display: flex;
  align-items: center;
  min-height: 31px;
  min-width: 0;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.detailHeader {
  display: grid;
  grid-template-columns: minmax(430px, 0.95fr) minmax(520px, 1.45fr);
  gap: 12px;
  align-items: end;
  padding: 6px 22px 9px;
}

.detailHeader .metrics {
  grid-template-columns: minmax(110px, 0.75fr) minmax(110px, 0.75fr) minmax(210px, 1.25fr) minmax(120px, 0.8fr);
  gap: 8px;
  margin-bottom: 0;
}

.tableTitle {
  margin: 14px 0 7px;
  color: #263244;
}

.tableWrap {
  margin: 0 0 14px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  white-space: nowrap;
}

th,
td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf5ff;
  color: #263a72;
  font-size: 12px;
  font-weight: 800;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
}

th:first-child {
  z-index: 3;
}

td:first-child {
  background: var(--surface);
  font-weight: 740;
}

tbody tr:nth-child(even) td {
  background: #fbfdff;
}

tbody tr:hover td {
  background: #f0f7ff;
}

tbody tr.selected > td,
tbody tr.selected:nth-child(even) > td,
tbody tr.selected:hover > td,
tbody tr.selected > td:first-child {
  background: var(--selected-bg);
  color: #10295f;
  font-weight: 760;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #edf1f5;
  color: #445265;
  font-size: 12px;
  font-weight: 760;
}

.badge.ok {
  background: var(--accent-bg);
  color: var(--accent);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.sectionHead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 18px 0 8px;
}

.inlineControls {
  display: flex;
  gap: 10px;
  align-items: end;
}

figure {
  margin: 0;
  padding: 10px;
}

figure img {
  display: block;
  width: 100%;
  max-height: 660px;
  object-fit: contain;
  background: #fff;
}

figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 18px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

select:focus,
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(44, 111, 170, 0.18);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .topLine,
  .workspaceHeader,
  .sectionHead {
    display: block;
  }

  .headerActions,
  .headerStats,
  .inlineControls {
    margin-top: 12px;
  }

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

  .ruleText {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topLine,
  .pageNav,
  .filterPanel,
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .filterPanel,
  .controlBar,
  .inlineControls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .controlBar label,
  .inlineControls label {
    min-width: 0;
  }

  h2 {
    font-size: 22px;
  }
}
