:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --fg: #17202a;
  --muted: #5c6b7a;
  --card: #ffffff;
  --line: #d5dde5;
  --accent: #0b6e4f;
  --accent-fg: #ffffff;
  --danger: #a33b32;
  --bar: #0b6e4f;
  --input: #ffffff;
  --hover: rgba(11, 110, 79, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171c;
    --fg: #e7eef4;
    --muted: #9aabba;
    --card: #1c242c;
    --line: #2d3a46;
    --accent: #3ddc97;
    --accent-fg: #06281a;
    --danger: #ff8d86;
    --bar: #3ddc97;
    --input: #12171c;
    --hover: rgba(61, 220, 151, 0.1);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.45;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a { color: var(--accent); }

button,
input,
select {
  font: inherit;
  color: inherit;
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  min-height: 2.4rem;
}

button {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
}

button.ghost.on {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
}

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--line);
}

button:disabled { opacity: 0.6; cursor: default; }

header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

header strong { font-size: 1.05rem; }

nav {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

nav a {
  text-decoration: none;
  padding: 0.35rem 0.2rem;
}

nav a.on { font-weight: 600; text-decoration: underline; }

main {
  padding: 1rem;
  max-width: 1180px;
  margin: 0 auto;
}

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.6rem;
}

h1 { font-size: 1.45rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 1.2rem; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  width: min(420px, 100%);
  display: grid;
  gap: 0.75rem;
}

.card label,
.stack label { display: grid; gap: 0.3rem; }

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 0.75rem 0;
}

.inline {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.err { color: var(--danger); min-height: 1.2em; margin: 0; }
.muted { color: var(--muted); }
.banner {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.8rem;
}

.wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

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

th, td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
  white-space: nowrap;
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--card);
}

tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--hover); }

td input.label {
  width: 14rem;
  max-width: 100%;
  min-height: 2rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84em;
}

svg.chart {
  width: 100%;
  height: auto;
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

svg.chart rect { fill: var(--bar); }
svg.chart line { stroke: currentColor; stroke-opacity: 0.35; }

.form-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 0.8rem;
}

.form-row label { display: grid; gap: 0.25rem; }

@media (max-width: 720px) {
  header { align-items: flex-start; flex-direction: column; }
  th, td { font-size: 0.82rem; }
  td input.label { width: 10rem; }
}
