:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18202a;
  background: #f5f7fa;
}

body {
  margin: 0;
}

button, input, select {
  font: inherit;
}

button {
  border: 1px solid #1c5d99;
  background: #1c5d99;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary, nav button {
  background: #ffffff;
  color: #1c5d99;
}

button.smallButton {
  padding: 4px 8px;
  font-size: 13px;
}

nav button.active {
  background: #1c5d99;
  color: white;
}

input, select {
  border: 1px solid #c8d1dc;
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login {
  width: min(420px, calc(100vw - 32px));
  margin: 12vh auto;
  background: white;
  border: 1px solid #dce3eb;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(20, 40, 70, 0.08);
}

.login form, .login label {
  display: grid;
  gap: 8px;
}

.login form {
  gap: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid #dce3eb;
}

.topbar h1, h2 {
  margin: 0;
}

nav {
  display: flex;
  gap: 8px;
}

.view {
  padding: 24px;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar input {
  min-width: 280px;
}

.inlineCheck {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.inlineCheck input {
  min-width: auto;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.cardGroup {
  margin-bottom: 20px;
  border: 1px solid #dce3eb;
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.cardGroup summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.cardGroup summary::-webkit-details-marker {
  display: none;
}

.cardGroup summary::before {
  content: "▸";
  color: #315d9c;
  font-size: 16px;
  transition: transform 120ms ease;
}

.cardGroup[open] summary::before {
  transform: rotate(90deg);
}

.cardGroup h3 {
  flex: 1;
  margin: 0;
}

.cardGroup summary span {
  color: #526070;
  font-size: 12px;
}

.cardGroup[open] summary span {
  color: #315d9c;
}

.cardGroup .cards {
  padding: 0 16px 16px;
}

.card {
  background: #f8fafc;
  border: 1px solid #dce3eb;
  border-radius: 8px;
  padding: 16px;
  min-height: 96px;
}

.card strong {
  display: block;
  font-size: 28px;
  overflow-wrap: anywhere;
}

.card small {
  display: block;
  margin-top: 6px;
  color: #526070;
  overflow-wrap: anywhere;
}

.actionCard {
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.actionCard:hover {
  border-color: #1c5d99;
  transform: translateY(-1px);
}

.chips, .inlineStats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chip {
  background: #ffffff;
  color: #1c5d99;
}

.linkButton {
  border: 0;
  background: transparent;
  color: #1c5d99;
  padding: 0;
  font-weight: 700;
  text-align: left;
}

.linkButton:hover {
  text-decoration: underline;
}

.inlineStats {
  margin: 8px 0 12px;
}

.inlineStats span {
  background: #ffffff;
  border: 1px solid #dce3eb;
  border-radius: 6px;
  padding: 6px 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid #dce3eb;
}

.tableScroll {
  width: 100%;
  overflow-x: auto;
}

.compactTable {
  max-width: 920px;
  margin-bottom: 18px;
}

.compactTable table {
  table-layout: fixed;
}

.numberCell {
  text-align: right;
  white-space: nowrap;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f6;
  vertical-align: top;
}

th {
  background: #f0f4f8;
}

.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.ok {
  background: #e5f7ed;
  color: #136b38;
}

.badge.warn {
  background: #fff4d8;
  color: #805600;
}

.badge.off {
  background: #eef2f6;
  color: #526070;
}

.json {
  margin-top: 16px;
  padding: 16px;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  overflow: auto;
  max-height: 520px;
}

.json.compact {
  max-height: 220px;
}

.json.small {
  max-height: 260px;
  font-size: 12px;
}

.copyBox {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #dce3eb;
  border-radius: 6px;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.successText {
  color: #136b38;
}

.warningText {
  color: #805600;
}

.detailsPanel {
  margin-top: 16px;
  background: white;
  border: 1px solid #dce3eb;
  border-radius: 8px;
  padding: 16px;
}

.detailsRow td {
  background: #f8fafc;
  padding: 0 12px 12px;
}

.smallButton {
  padding: 6px 10px;
  font-size: 13px;
}

.smallButton.active {
  background: #2f5f9f;
  color: #ffffff;
}

.historyHeader {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.historyControls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.controlLabel {
  color: #526070;
  font-size: 12px;
  font-weight: 700;
  margin-right: 4px;
}

.historyStats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.historyStats span {
  border: 1px solid #dce3eb;
  border-radius: 6px;
  background: #ffffff;
  padding: 6px 10px;
}

.historyChart {
  border: 1px solid #dce3eb;
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.historySvg {
  display: block;
  width: 100%;
  max-height: 420px;
}

.historySvg text {
  fill: #526070;
  font-size: 11px;
}

.historyGrid {
  stroke: #e5ebf2;
  stroke-width: 1;
}

.historyLine {
  fill: none;
  stroke: #2f5f9f;
  stroke-width: 2;
}

.historyPoint {
  fill: #2f5f9f;
  transition: r 120ms ease, filter 120ms ease;
}

.historyPreviousPoint {
  fill: #0f766e;
  stroke: #ffffff;
  stroke-width: 2;
}

.historyHitPoint {
  fill: transparent;
  cursor: crosshair;
}

.historyHitPoint:hover + .historyPoint,
.historyPoint:hover {
  filter: drop-shadow(0 0 3px rgba(47, 95, 159, 0.55));
}

.historyCompareLine {
  stroke: #805600;
  stroke-dasharray: 6 4;
  stroke-width: 2;
}

.historyRejectLabel {
  fill: #b42318 !important;
  font-weight: 700;
}

.historyRejectLine {
  stroke: #b42318;
  stroke-dasharray: 5 5;
  stroke-width: 1.5;
}

.historyRejectPoint {
  fill: #b42318;
  stroke: #ffffff;
  stroke-width: 2;
  cursor: crosshair;
  transition: r 120ms ease, filter 120ms ease;
}

.historyRejectPoint:hover {
  filter: drop-shadow(0 0 4px rgba(180, 35, 24, 0.6));
}

.aggregateSection {
  margin-top: 16px;
}

.aggregateSection h4 {
  margin: 0 0 6px;
}

.aggregateHeader {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.aggregateChart {
  margin-top: 10px;
}

.historyAggregateLine {
  fill: none;
  stroke-width: 2;
}

.historyAggregateLine.day {
  stroke: #0f766e;
}

.historyAggregateLine.month {
  stroke: #7c3aed;
  stroke-dasharray: 6 4;
}

.historyAggregatePoint {
  stroke: #ffffff;
  stroke-width: 2;
  cursor: crosshair;
}

.historyAggregatePoint.day {
  fill: #0f766e;
}

.historyAggregatePoint.month {
  fill: #7c3aed;
}

.chartLegend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  color: #526070;
  font-size: 13px;
}

.legendDot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
}

.legendDot.accepted {
  background: #2f5f9f;
}

.legendDot.rejected {
  background: #b42318;
}

.legendDot.aggregateDay {
  background: #0f766e;
}

.legendDot.aggregateMonth {
  background: #7c3aed;
}

.legendDot.corrected {
  background: #0f766e;
}

.legendLine {
  display: inline-block;
  width: 20px;
  height: 0;
  border-top: 2px dashed #805600;
  margin: 0 5px 3px 0;
}

.historyPointsTable {
  margin-top: 12px;
}

.counterCorrectionBox {
  border: 1px solid #dce3eb;
  border-radius: 8px;
  background: #f8fbff;
  margin-top: 14px;
  padding: 14px;
}

.counterCorrectionBox h4 {
  margin: 0 0 8px;
}

.compactDiagnosticBox {
  padding: 10px 12px;
}

.aggregateBackcastBox {
  border-top: 1px solid #dce3eb;
  margin-top: 10px;
  padding-top: 10px;
}

.aggregateBackcastBox h5 {
  font-size: 14px;
  margin: 0 0 8px;
}

.counterCorrectionChart {
  background: #ffffff;
}

.historyCorrectedLine {
  fill: none;
  stroke: #0f766e;
  stroke-width: 2.5;
}

.historyCorrectedPoint {
  fill: #0f766e;
  stroke: #ffffff;
  stroke-width: 2;
  cursor: crosshair;
}

.rawSampleBox {
  margin-top: 12px;
}

.rawSampleBox summary {
  cursor: pointer;
  font-weight: 600;
}

.detailGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.detailGrid h3, .detailsPanel h3 {
  margin: 0 0 10px;
}

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 12px;
  margin: 0;
}

dt {
  color: #526070;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.plainList {
  margin: 0;
  padding-left: 18px;
}

.listRows {
  display: grid;
  gap: 8px;
}

.listRow {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid #dce3eb;
  border-radius: 6px;
  background: #ffffff;
  padding: 10px 12px;
}

.backupList {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 560px;
  overflow: auto;
}

.backupItem {
  border: 1px solid #dce3eb;
  border-radius: 6px;
  background: #ffffff;
}

.backupItem summary {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
}

.backupItem p {
  margin: 0;
  padding: 0 12px 12px;
}

.pager {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.error {
  color: #b42318;
  min-height: 20px;
}

.muted {
  color: #526070;
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .backupItem summary {
    grid-template-columns: 1fr;
  }

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