:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-strong: #f0f3ee;
  --ink: #19201d;
  --muted: #65706a;
  --line: #d9ded6;
  --accent: #0b7261;
  --accent-2: #c87929;
  --danger: #b64242;
  --success: #257a45;
  --shadow: 0 14px 34px rgba(27, 35, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 780;
  letter-spacing: 0;
  line-height: 1.1;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.nav a:hover,
.nav a.active {
  background: var(--surface-strong);
  color: var(--accent);
}

.sidebar-links {
  margin-top: auto;
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.content {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 46px 32px 72px;
}

.content:focus {
  outline: none;
}

.page-title {
  margin: 0 0 20px;
  font-size: clamp(2.1rem, 3vw, 4.2rem);
  line-height: 1;
  letter-spacing: 0;
}

.lead {
  font-size: 18px;
  color: #334039;
}

.section {
  padding: 36px 0;
  border-top: 1px solid var(--line);
}

.section:first-child {
  border-top: 0;
  padding-top: 0;
}

.section h2 {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 1.15;
}

.section h3 {
  margin: 22px 0 10px;
  font-size: 21px;
  line-height: 1.25;
}

.section h4 {
  margin: 18px 0 10px;
  font-size: 17px;
}

.section p,
.section li {
  color: #334039;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  margin: 18px 0;
}

.control {
  min-width: 220px;
  display: grid;
  gap: 7px;
}

.control label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.control output {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 760;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select,
input[type="search"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 10px;
  font: inherit;
  font-size: 14px;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 8px 13px;
  font: inherit;
  font-size: 14px;
  font-weight: 760;
  text-decoration: none;
  cursor: pointer;
}

button.secondary,
.button-link.secondary {
  background: var(--surface);
  color: var(--accent);
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

summary {
  cursor: pointer;
  padding: 13px 15px;
  font-weight: 760;
}

.details-body {
  padding: 0 15px 15px;
}

.note {
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-strong);
  color: #334039;
}

.outcome {
  font-weight: 800;
}

.outcome.yes {
  color: var(--success);
}

.outcome.no {
  color: var(--danger);
}

.chart {
  width: 100%;
  min-height: 340px;
  margin: 18px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chart.small {
  min-height: 250px;
}

.chart.tall {
  min-height: 460px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

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

.metric .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric .value {
  display: block;
  margin-top: 5px;
  font-size: 28px;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
}

.metric .delta {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.page-card {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.page-card:hover {
  border-color: var(--accent);
}

.page-card h3 {
  margin: 0;
  font-size: 20px;
}

.page-card p {
  margin: 10px 0 0;
  color: var(--muted);
}

.table-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

td.long {
  min-width: 360px;
  white-space: normal;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

.equation {
  display: inline-block;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--surface-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.loading {
  color: var(--muted);
  padding: 24px 0;
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 30px 16px 54px;
  }

  .chart-grid,
  .two-col,
  .metric-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }
}
