:root {
  color-scheme: light;
  --bg: #f7f8f6;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-soft: rgba(247, 248, 246, 0.88);
  --text: #121820;
  --muted: #69717c;
  --line: #d3d8d3;
  --line-strong: #2e3a3f;
  --accent: #126f6a;
  --accent-strong: #0b4f4c;
  --accent-soft: rgba(18, 111, 106, 0.08);
  --chart-bar: #b78224;
  --warn: #9a620d;
  --danger: #a23932;
  --shadow: 0 1px 0 rgba(18, 24, 32, 0.05);
  --dot: rgba(46, 58, 63, 0.08);
  --grid: rgba(46, 58, 63, 0.055);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  background-image:
    radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 0),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-position: 0 0, 0 0, 0 0;
  background-size: 18px 18px, 72px 72px, 72px 72px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 14px;
  background: rgba(18, 111, 106, 0.09);
  color: var(--accent-strong);
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease, color 150ms ease, transform 150ms ease;
}

button:hover {
  background: rgba(18, 111, 106, 0.14);
  box-shadow: inset 0 0 0 1px var(--accent-strong);
  color: var(--text);
}

button:active {
  transform: scale(0.985);
}

button.secondary {
  background: transparent;
  color: var(--muted);
}

button.secondary:hover {
  background: rgba(18, 24, 32, 0.035);
  color: var(--text);
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--text);
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

input:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(18, 111, 106, 0.28);
  outline-offset: 2px;
}

input:hover,
input:focus {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.9);
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 30px 22px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(18, 24, 32, 0.035) 1px, transparent 1px) 0 0 / 18px 18px,
    rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  font-size: 28px;
  line-height: 1.15;
}

h3 {
  font-size: 18px;
  line-height: 1.25;
}

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

nav a {
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--muted);
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

nav a:hover {
  background: var(--accent-soft);
  border-color: rgba(18, 111, 106, 0.35);
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--accent-strong);
}

.settings-panel {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

main {
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 28px;
}

.topbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions input {
  width: 160px;
}

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

.metric {
  position: relative;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(18, 24, 32, 0.035) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.metric::before,
.metric::after {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--line-strong);
  border-style: solid;
  content: "";
  opacity: 0.72;
  pointer-events: none;
}

.metric::before {
  top: 9px;
  left: 9px;
  border-width: 1px 0 0 1px;
}

.metric::after {
  right: 9px;
  bottom: 9px;
  border-width: 0 1px 1px 0;
}

.metric:hover {
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px rgba(46, 58, 63, 0.34);
}

.metric span {
  display: block;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.metric strong {
  display: block;
  margin-top: 14px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(18, 24, 32, 0.025) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--panel);
  box-shadow: var(--shadow);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.panel:hover {
  border-color: rgba(46, 58, 63, 0.46);
}

.panel > .section-heading {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
}

.section-heading input {
  max-width: 220px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.chart {
  min-height: 300px;
  padding: 16px 18px 20px;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

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

.axis-label {
  fill: var(--muted);
  font-size: 12px;
}

.chart-grid {
  stroke: var(--line);
  stroke-dasharray: 3 7;
  stroke-linecap: round;
}

.chart-axis {
  stroke: var(--line-strong);
  stroke-opacity: 0.42;
}

.chart-bar {
  fill: var(--chart-bar);
  fill-opacity: 0.1;
  stroke: var(--chart-bar);
  stroke-opacity: 0.72;
}

.chart-line {
  stroke: var(--accent);
}

.chart-point {
  fill: var(--panel);
  stroke: var(--accent);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(247, 248, 246, 0.94);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

tbody tr {
  transition: background 150ms ease, box-shadow 150ms ease;
}

tbody tr:hover {
  background: rgba(18, 111, 106, 0.045);
  box-shadow: inset 2px 0 0 var(--accent);
}

td code {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(18, 111, 106, 0.34);
  border-radius: 4px;
  padding: 0 9px;
  background: rgba(18, 111, 106, 0.055);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.tag.warn {
  border-color: rgba(154, 98, 13, 0.38);
  background: rgba(154, 98, 13, 0.08);
  color: var(--warn);
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

#toast.error {
  border-color: rgba(162, 57, 50, 0.52);
  color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }
}

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

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

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

  nav a {
    text-align: center;
  }

  main {
    padding: 20px 14px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .topbar-actions input,
  .section-heading input {
    max-width: none;
    width: 100%;
  }

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

@media (max-width: 520px) {
  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 23px;
  }

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

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