:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #e2e5ea;
  --ink: #12161c;
  --muted: #626b78;
  --accent: #0f6fd8;
  --accent-ink: #ffffff;
  --down: #0f7b52;
  --up: #b4341f;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 8px 24px -12px rgb(16 24 40 / 18%);
  --gap: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #171b22;
    --line: #262c36;
    --ink: #e8ecf1;
    --muted: #98a2b3;
    --accent: #58a9ff;
    --accent-ink: #06121f;
    --down: #4ec98f;
    --up: #ff8b73;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 10px 28px -14px rgb(0 0 0 / 70%);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 0 var(--gap) 3rem;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.1rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 0.8rem; margin: 0 0 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

main, .bar { max-width: 52rem; margin-inline: auto; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 1rem 0;
  flex-wrap: wrap;
}

footer.bar { border-top: 1 solid var(--line); margin-top: 2rem; padding-top: 1rem; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 0.5rem; top: 0.5rem; z-index: 10; background: var(--accent); color: var(--accent-ink); padding: 0.5rem 0.75rem; border-radius: 8px; }

.status:empty { display: none; }
.status {
  max-width: 52rem;
  margin: 0 auto 0.5rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-size: 0.9rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: var(--gap);
}

.row { display: flex; gap: var(--gap); flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.8rem; min-width: 9rem; }
.field.grow { flex: 1; }
label { font-size: 0.85rem; font-weight: 600; }

input {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  min-height: 44px;
  width: 100%;
}

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

#weight { font-size: 1.35rem; font-variant-numeric: tabular-nums; }

button, .button {
  font: inherit;
  font-weight: 600;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

button:hover, .button:hover { border-color: var(--accent); }

.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.danger { color: var(--up); }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.units { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.units .unit { border: 0; border-radius: 0; min-height: 40px; background: transparent; }
.units .unit[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.hint { color: var(--muted); font-weight: 400; font-size: 0.82rem; }
.sub { color: var(--muted); font-size: 0.82rem; display: block; }
.error { color: var(--up); font-size: 0.85rem; min-height: 1.2em; margin: 0 0 0.5rem; }
.error:empty { min-height: 0; margin: 0; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; }
.figure { display: flex; flex-direction: column; gap: 0.15rem; }
.label { font-size: 0.78rem; color: var(--muted); }
.big { font-size: 1.9rem; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.down { color: var(--down); }
.up { color: var(--up); }

.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.7; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .point { fill: var(--accent); }
.chart .average { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.chart .trend-line { fill: none; stroke: var(--down); stroke-width: 2; stroke-dasharray: 6 4; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
.note-cell { color: var(--muted); }
.row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.row-actions button { min-height: 36px; padding: 0.3rem 0.6rem; font-size: 0.85rem; }

.scroll { overflow-x: auto; }

.empty { color: var(--muted); font-size: 0.9rem; margin: 0; }

@media (max-width: 30rem) {
  .row { flex-direction: column; }
  .field { min-width: 0; }
}

@media (max-width: 34rem) {
  th, td { padding-inline: 0.3rem; font-size: 0.85rem; }
  th:nth-child(4), td:nth-child(4) { display: none; }
  th:first-child, td:first-child { white-space: nowrap; }
  .row-actions button { padding: 0.3rem 0.45rem; }
  .chart text { font-size: 15px; }
  .big { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { transition: background-color 120ms ease; }
}