:root {
  --ink: #171a17;
  --muted: #68706a;
  --paper: #f3f1e9;
  --panel: rgba(255, 255, 252, 0.78);
  --line: #d8d8ce;
  --green: #174f3a;
  --lime: #c9f26b;
  --orange: #e57b42;
  --blue: #5677df;
  --purple: #8d65c5;
  --shadow: 0 14px 45px rgba(32, 42, 32, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 5%, rgba(201, 242, 107, .28), transparent 24rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, select, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 26, 23, .1);
  background: rgba(243, 241, 233, .82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-weight: 700; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
  color: white; background: var(--green); font-family: Georgia, serif; font-size: 21px;
}
.top-actions { display: flex; align-items: center; gap: 18px; }
.freshness { color: var(--muted); font-size: 13px; }

main { max-width: 1240px; margin: 0 auto; padding: 66px 24px 80px; }
.hero { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: end; margin-bottom: 38px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { max-width: 760px; margin: 0; font: 500 clamp(48px, 7vw, 88px)/.94 Georgia, serif; letter-spacing: -.055em; }
h2 { margin: 0; font: 500 29px/1.1 Georgia, serif; letter-spacing: -.025em; }
.lede { max-width: 650px; margin: 24px 0 0; color: var(--muted); font-size: 17px; line-height: 1.55; }
.hero-stat {
  width: 210px; padding: 20px; border-left: 1px solid var(--line); display: grid; gap: 5px;
}
.hero-stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.hero-stat strong { font: 500 38px Georgia, serif; }
.hero-stat span:last-child { color: var(--muted); font-size: 12px; }

.panel { background: var(--panel); border: 1px solid rgba(23, 26, 23, .1); border-radius: 18px; box-shadow: var(--shadow); }
.controls { padding: 16px; display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 12px; align-items: end; }
label { display: grid; gap: 7px; }
label > span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
select, input {
  min-width: 0; height: 43px; padding: 0 12px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
select:focus, input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,79,58,.1); }
select:disabled { color: #4f5751; background: #f1f1eb; opacity: 1; }
.segmented { display: flex; padding: 4px; background: #e9e8df; border-radius: 11px; }
.segmented button { height: 35px; padding: 0 12px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; }
.segmented button.active { color: white; background: var(--green); }
.button { height: 42px; padding: 0 17px; border: 0; border-radius: 10px; font-weight: 700; }
.button.primary { color: #122016; background: var(--lime); }
.button.secondary { width: 100%; color: white; background: var(--green); }
.button:disabled { opacity: .55; cursor: wait; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 14px 0; }
.kpi { padding: 20px; display: grid; gap: 8px; }
.kpi span { color: var(--muted); font-size: 12px; }
.kpi strong { font: 500 31px Georgia, serif; }
.kpi small { color: var(--muted); min-height: 16px; }

.chart-panel { padding: 25px; }
.section-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 22px; }
.chart { min-height: 420px; position: relative; }
.chart svg { width: 100%; height: 420px; overflow: visible; }
.grid-line { stroke: #deded5; stroke-width: 1; }
.axis-label { fill: #7d837e; font-size: 11px; }
.series-line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.point { stroke: white; stroke-width: 2; cursor: pointer; }
.point:hover { r: 6; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 15px; max-width: 55%; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.chart-note { margin: 10px 0 0 52px; color: var(--muted); font-size: 11px; }
.chart-note a { color: var(--green); font-weight: 700; text-decoration: none; }
.empty { height: 390px; display: grid; place-items: center; color: var(--muted); text-align: center; }
.tooltip {
  position: fixed; z-index: 20; width: 220px; padding: 12px; pointer-events: none;
  color: white; background: rgba(18, 24, 20, .94); border-radius: 10px; box-shadow: var(--shadow); font-size: 12px;
}
.tooltip strong { display: block; margin-bottom: 5px; font-size: 14px; }
.tooltip a { color: var(--lime); }

.lower-grid { display: grid; grid-template-columns: 1.45fr .75fr; gap: 14px; margin: 14px 0; }
.source-panel, .archive-panel, .table-panel { padding: 24px; }
.sources { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.source-card { padding: 14px; background: rgba(244,244,238,.65); border: 1px solid var(--line); border-radius: 12px; }
.source-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.source-name { font-weight: 750; }
.badge { padding: 4px 7px; border-radius: 999px; color: var(--green); background: rgba(201,242,107,.45); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.source-meta { margin-top: 8px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.source-link { display: inline-block; margin-top: 9px; color: var(--green); font-size: 12px; font-weight: 750; text-decoration: none; }
.sources.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.empty-source { padding: 14px; color: var(--muted); background: rgba(244,244,238,.65); border: 1px dashed var(--line); border-radius: 12px; font-size: 12px; line-height: 1.45; }
.archive-panel > p:not(.eyebrow,.status) { color: var(--muted); font-size: 13px; line-height: 1.5; }
.archive-panel form { display: grid; gap: 13px; margin-top: 18px; }
.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status { min-height: 17px; margin-bottom: 0; color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; color: var(--muted); text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
td { padding: 13px 12px; border-bottom: 1px solid #e5e4db; white-space: nowrap; }
td a { color: var(--green); font-weight: 700; text-decoration: none; }
.rate { font-variant-numeric: tabular-nums; font-weight: 750; }
.provider-type { margin-left: 7px; color: var(--muted); font-size: 10px; }
.link-button {
  padding: 0; color: var(--green); background: transparent; border: 0;
  font: inherit; font-weight: 750; text-decoration: none;
}

.source-dialog {
  width: min(960px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 24px;
  color: var(--ink);
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 90px rgba(23, 26, 23, .24);
}
.source-dialog::backdrop { background: rgba(23, 26, 23, .42); backdrop-filter: blur(3px); }
.dialog-top { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 20px; }
.icon-button {
  width: 34px; height: 34px; display: grid; place-items: center;
  color: var(--muted); background: #f0f0e8; border: 1px solid var(--line); border-radius: 50%;
  font-size: 24px; line-height: 1;
}
.source-dialog-body { display: grid; gap: 22px; }
.dialog-section { display: grid; gap: 12px; }
.dialog-section h3 { margin: 0; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.selected-point {
  display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center;
  padding: 14px; background: #f5f4ed; border: 1px solid var(--line); border-radius: 12px;
}
.selected-point span { color: var(--muted); font-size: 13px; }
.selected-point strong { font: 500 28px Georgia, serif; }

.toast {
  position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 14px 17px;
  color: white; background: var(--ink); border-radius: 11px; box-shadow: var(--shadow);
  transform: translateY(90px); opacity: 0; transition: .25s ease; z-index: 30; font-size: 13px;
}
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-stat { width: 100%; border-left: 0; border-top: 1px solid var(--line); padding-left: 0; }
  .controls { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .lower-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .freshness { display: none; }
  .brand span:last-child { display: none; }
  main { padding: 42px 14px 60px; }
  h1 { font-size: 50px; }
  .controls, .kpis { grid-template-columns: 1fr; }
  .segmented { justify-content: space-between; }
  .sources { grid-template-columns: 1fr; }
  .sources.compact { grid-template-columns: 1fr; }
  .selected-point { grid-template-columns: 1fr; gap: 7px; }
  .section-heading { display: block; }
  .legend { max-width: 100%; justify-content: flex-start; margin-top: 16px; }
  .chart-panel { padding: 18px 10px; }
}
