:root {
  --bg: #e4ebe0;
  --bg-deep: #cfd9c8;
  --ink: #142018;
  --muted: #556156;
  --line: #b4c0b0;
  --accent: #134734;
  --gain: #134734;
  --loss: #8f3224;
  --paper: rgba(250, 252, 247, 0.35);
  --display: "Syne", sans-serif;
  --body: "Atkinson Hyperlegible", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--body);
  background:
    radial-gradient(1100px 640px at 8% -8%, #d7e4cc 0%, transparent 58%),
    radial-gradient(800px 480px at 100% 0%, #bccbb6 0%, transparent 52%),
    linear-gradient(165deg, #e8eee4 0%, #d3ddd0 48%, #c5d0c2 100%);
  background-attachment: fixed;
}

body {
  animation: wash 1.1s ease both;
}

@keyframes wash {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.4rem 6vw 0;
}

.mark {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: -0.05em;
}

.switcher {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

select, input, button {
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
}

select, input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="search"], input[type="password"], input:not([type]) {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.35rem 0;
  outline: none;
}

select:focus, input:focus {
  border-bottom-color: var(--accent);
}

button {
  background: none;
  border: 1px solid var(--ink);
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

button:hover {
  background: var(--ink);
  color: #e8eee4;
}

button.primary {
  background: var(--accent);
  color: #eef6ea;
  border-color: var(--accent);
}

button.primary:hover {
  background: var(--ink);
  border-color: var(--ink);
}

.text-btn {
  border: 0;
  padding: 0.3rem 0;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.text-btn:hover {
  background: none;
  color: var(--accent);
}

body.locked > header,
body.locked > main {
  display: none;
}

body.viewer .owner-only {
  display: none !important;
}

.gate {
  display: none;
  min-height: 100vh;
  padding: 8vh 6vw 4rem;
  align-items: center;
}

body.locked .gate {
  display: grid;
}

.gate-card {
  max-width: 28rem;
}

.gate h1 {
  margin: 0.4rem 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.2rem, 9vw, 6.4rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.gate form {
  display: grid;
  gap: 0.9rem;
  margin-top: 2rem;
}

.gate label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.gate button[type="submit"] {
  justify-self: start;
  margin-top: 0.4rem;
}

#gate-error {
  color: var(--loss);
  margin: 0;
}

.hero {
  padding: 8vh 6vw 3rem;
  max-width: 1200px;
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.2rem, 9vw, 7.4rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
  animation: rise 0.8s ease both;
}

@keyframes rise {
  from { transform: translateY(18px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.lede {
  margin: 1.2rem 0 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.nav-figure {
  margin: 2.4rem 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  letter-spacing: -0.04em;
  animation: rise 1s 0.15s ease both;
}

.nav-meta {
  margin: 0.4rem 0 0;
  color: var(--muted);
  min-height: 1.4em;
}

.nav-meta .up { color: var(--gain); }
.nav-meta .down { color: var(--loss); }

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 2rem;
}

.cta.compact { margin-top: 0; }

.chart-plane {
  width: 100%;
  padding: 0 0 2rem;
  min-height: 42vh;
  position: relative;
}

.chart-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 6vw 0.6rem;
}

.chart-label {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--muted);
}

.ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.1rem;
  justify-content: flex-end;
}

.ranges button {
  border: 0;
  padding: 0.2rem 0.45rem;
  color: var(--muted);
}

.ranges button.on,
.ranges button:hover {
  background: none;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.custom-range {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  justify-content: flex-end;
  padding: 0 6vw 0.8rem;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.custom-range label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.custom-range input[type="date"] {
  font-size: 0.85rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  max-width: 10.5rem;
}

.chart-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem 1.5rem;
  padding: 0.4rem 6vw 1rem;
  max-width: 1400px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.metric-label {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--muted);
}

.metric-value {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  letter-spacing: -0.03em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-value.up { color: var(--gain); }
.metric-value.down { color: var(--loss); }

.metric-value .metric-sub {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--body);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

#perf-chart {
  display: block;
  width: 100% !important;
  height: 42vh !important;
}

.chart-empty {
  position: absolute;
  left: 6vw;
  bottom: 3rem;
  color: var(--muted);
  margin: 0;
}

.chart-empty.hidden,
.hidden { display: none !important; }

.block {
  padding: 3.5rem 6vw 2rem;
  max-width: 1400px;
}

.block h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: -0.04em;
  margin: 0 0 0.4rem;
}

.hint {
  margin: 0 0 1.4rem;
  color: var(--muted);
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.block-head .hint { margin-bottom: 0; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.6rem 0.75rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: baseline;
}

th {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }

td .muted { color: var(--muted); font-size: 0.9em; }

.up { color: var(--gain); }
.down { color: var(--loss); }

.stale-flag {
  display: inline;
  margin-left: 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--loss);
}

.row-btn {
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  margin-left: 0.6rem;
}

.row-btn:hover { background: none; color: var(--accent); }

.approval-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.approval-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
  animation: rise 0.5s ease both;
}

.file-btn {
  display: inline-block;
  border: 1px solid var(--ink);
  padding: 0.55rem 1rem;
  cursor: pointer;
}

.file-btn input { display: none; }

.file-btn:hover {
  background: var(--ink);
  color: #e8eee4;
}

dialog {
  border: 0;
  padding: 1.8rem 1.8rem 1.4rem;
  width: min(32rem, calc(100vw - 2rem));
  background: #eef3ea;
  color: var(--ink);
  box-shadow: none;
}

dialog::backdrop {
  background: rgba(20, 32, 24, 0.35);
}

dialog h3 {
  font-family: var(--display);
  margin: 0 0 1.2rem;
  letter-spacing: -0.03em;
}

dialog form {
  display: grid;
  gap: 0.85rem;
}

dialog label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

dialog menu {
  display: flex;
  gap: 0.6rem;
  margin: 0.6rem 0 0;
  padding: 0;
}

.extra { display: grid; gap: 0.85rem; }

.suggest {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  max-height: 16rem;
  overflow: auto;
}

.suggest li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  color: var(--ink);
}

.suggest li:hover,
.suggest li.on {
  color: var(--accent);
}

.suggest li.empty {
  cursor: default;
  color: var(--muted);
}

.suggest li.empty:hover {
  color: var(--muted);
}

dialog[open] {
  display: grid;
  gap: 0.7rem;
}

.status {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  margin: 0;
  padding: 0.6rem 0.9rem;
  background: var(--ink);
  color: #e8eee4;
  animation: rise 0.3s ease both;
}

.empty-row td {
  color: var(--muted);
  padding: 1.4rem 0;
}

@media (max-width: 720px) {
  .top { flex-direction: column; align-items: flex-start; }
  .hero { padding-top: 4vh; }
  .nav-figure { font-size: 2.2rem; }
  #perf-chart { height: 28vh !important; }
  .chart-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem 1rem; }
  .cta button, .file-btn { width: 100%; text-align: center; }
}
