:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --ink: #171b1f;
  --muted: #69717b;
  --line: #dfe4e8;
  --line-strong: #c9d1d8;
  --teal: #0c6871;
  --teal-soft: #e8f4f4;
  --blue: #2754a6;
  --amber: #a8670d;
  --green: #177245;
  --red: #b42318;
  --shadow: 0 14px 34px rgba(31, 38, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 6px 0 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.api-status,
.score,
.status,
.verdict {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.api-status {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.api-status.success,
.score.success,
.verdict.success,
.status.ok {
  background: #e7f5ee;
  color: var(--green);
}

.api-status.warning,
.score.warning,
.verdict.warning {
  background: #fff4df;
  color: var(--amber);
}

.score.danger,
.verdict.danger,
.status.fail {
  background: #fff0ee;
  color: var(--red);
}

.score.neutral,
.verdict.neutral,
.status.skip {
  background: #eef1f3;
  color: var(--muted);
}

.control-panel,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(260px, 1.6fr) minmax(150px, 0.65fr) minmax(190px, 0.7fr) 128px;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
}

.field {
  min-width: 0;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

select,
input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.period-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-action,
.rank-item {
  border: 0;
  cursor: pointer;
}

.primary-action {
  width: 100%;
  height: 42px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-weight: 850;
}

.primary-action:hover {
  background: var(--teal);
}

.dashboard-grid,
.detail-grid {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
}

.detail-grid {
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  margin-top: 16px;
}

.detail-grid.compact {
  grid-template-columns: minmax(320px, 0.65fr) minmax(520px, 1.35fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.panel-title b {
  text-transform: none;
}

.result-panel h2 {
  max-width: 780px;
}

.result-copy,
.source-note {
  color: var(--muted);
  line-height: 1.55;
}

.source-note {
  margin-bottom: 0;
  font-size: 13px;
}

.rule-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.rule-pair div,
.weather-profile div,
.matrix-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 12px;
}

.rule-pair dt,
.weather-profile span,
.matrix-grid span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.rule-pair dd {
  margin: 6px 0 0;
  font-weight: 800;
}

.chart {
  width: 100%;
  height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.axis {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.bar-ok {
  fill: var(--green);
}

.bar-fail {
  fill: var(--red);
}

.bar-skip {
  fill: #bfc8cf;
}

.year-labels text {
  fill: var(--muted);
  font-size: 11px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric {
  min-height: 86px;
  padding: 14px;
  box-shadow: none;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1;
}

.metric.accent {
  border-color: #b7d9dc;
  background: var(--teal-soft);
}

.metric.success strong {
  color: var(--green);
}

.metric.danger strong {
  color: var(--red);
}

.weather-profile {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.weather-profile strong,
.matrix-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 19px;
}

.monthly-chart {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  gap: 6px;
  min-height: 132px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.month {
  display: grid;
  align-items: end;
  justify-items: center;
  gap: 7px;
  min-width: 0;
}

.month-bar {
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--blue);
}

.month small {
  color: var(--muted);
  font-size: 11px;
}

.ranking-list {
  display: grid;
  gap: 8px;
}

.rank-item {
  display: grid;
  grid-template-columns: 34px 1fr 46px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
}

.rank-item:hover {
  outline: 2px solid var(--teal-soft);
  background: #f2f8f8;
}

.rank-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  font-weight: 850;
}

.rank-copy {
  min-width: 0;
}

.rank-copy b,
.rank-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-copy small {
  margin-top: 4px;
  color: var(--muted);
}

.rank-item strong {
  color: var(--teal);
  text-align: right;
}

.matrix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f6f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.loading-block,
.empty {
  display: grid;
  place-items: center;
  min-height: 190px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .control-panel,
  .dashboard-grid,
  .detail-grid,
  .detail-grid.compact {
    grid-template-columns: 1fr 1fr;
  }

  .control-panel .wide {
    grid-column: span 2;
  }

  .metrics-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 780px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .control-panel,
  .dashboard-grid,
  .detail-grid,
  .detail-grid.compact,
  .rule-pair {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .control-panel .wide {
    grid-column: auto;
  }

  .metrics-row,
  .weather-profile,
  .matrix-grid {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 24px;
  }
}

@media (max-width: 520px) {
  .period-fields,
  .metrics-row,
  .weather-profile,
  .matrix-grid {
    grid-template-columns: 1fr;
  }

  .monthly-chart {
    gap: 4px;
  }

  .rank-item {
    grid-template-columns: 28px 1fr;
  }

  .rank-item strong {
    grid-column: 2;
    text-align: left;
  }
}
