:root {
  color-scheme: light dark;
  --surface: light-dark(#ffffff, #151a21);
  --canvas: light-dark(#f3f5f8, #10151c);
  --text: light-dark(#1c2430, #e7edf5);
  --muted: light-dark(#5d6b7c, #9aa8b8);
  --line: light-dark(#d5dde6, #2c3644);
  --accent: light-dark(#1f6feb, #3d8bfd);
  --accent-ink: #ffffff;
  --ok: light-dark(#1f7a4d, #3cba7a);
  --danger: light-dark(#b42318, #f04438);
  --hover: light-dark(#f6f8fb, #202733);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.4;
}

html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--text);
}

body:not(.sign-in) {
  display: grid;
  grid-template-columns: 240px 1fr;
}

.menu {
  position: sticky;
  top: 0;
  height: 100vh;
  box-sizing: border-box;
  overflow: auto;
  background: var(--canvas);
  border-right: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  margin: 8px 8px 16px;
  font-weight: 500;
  font-size: 16px;
}

.group {
  margin: 16px 8px 4px;
  color: var(--muted);
  font-size: 13px;
}

.menu a {
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  padding: 8px;
}

.menu a:hover { background: var(--hover); }

.menu a.current {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-weight: 500;
}

h1, h2 { font-weight: 500; }

h1 { font-size: 22px; margin: 0; }

h2 { font-size: 18px; margin: 0; }

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

main {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.title-row { margin-bottom: 0; }

.summary, .summary-bars {
  display: grid;
  gap: 12px;
  margin: 0;
}

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

.summary-bars { grid-template-columns: 1fr 1fr; }

.summary .count,
.summary-bars .split {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--canvas);
}

.summary .count span,
.split h2,
.bar-row span,
.bar-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.summary .count strong {
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.split h2 { margin: 0; font-size: 13px; }

.summary-bars .split:only-child { grid-column: 1 / -1; }

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

.bar-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  margin: 0;
}

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

.meter {
  display: block;
  height: 8px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.meter::before {
  content: "";
  display: block;
  height: 8px;
  width: calc(var(--share) * 100%);
  background: var(--accent);
  border-radius: 8px;
}

.progress { margin: 0 0 16px; }

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

table.list th {
  text-align: left;
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

table.list td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.list tbody tr { transition: background 140ms; }

table.list tbody tr:hover { background: var(--hover); }

table.list tbody tr[data-href] { cursor: pointer; }

table.list a { color: var(--accent); }

td .meter { margin-top: 8px; max-width: 160px; }

.note { color: var(--muted); }

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 13px;
}

.status.ok {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  color: var(--ok);
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  margin: 0 0 24px;
  max-width: 720px;
}

.fields div { margin: 0; }

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

.fields dd { margin: 4px 0 0; font-weight: 500; }

.backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, #10151c 45%, transparent);
  display: grid;
  place-items: start center;
  padding: 48px 16px;
  overflow: auto;
}

.dialog {
  width: min(720px, 100%);
  max-height: 640px;
  overflow: auto;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog-header .muted { display: block; margin: 4px 0 0; }

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  counter-reset: step;
  color: var(--muted);
  font-size: 13px;
}

.steps li { counter-increment: step; }

.steps li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 12px;
}

.steps .current { color: var(--text); font-weight: 500; }

.steps .current::before {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

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

.stages li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.stages .current { font-weight: 500; }

.summary-block { margin-top: 16px; }

.summary-block p { margin: 8px 0 0; }

.choice { display: flex; align-items: center; gap: 8px; min-height: 40px; }

select, input, button, a.secondary, a.primary {
  height: 40px;
  border-radius: 8px;
  font: inherit;
  box-sizing: border-box;
}

select, input {
  display: block;
  width: 100%;
  margin-top: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

select { padding: 0 8px; }

input { padding: 0 8px; }

label { display: block; margin-bottom: 12px; }

.choice input {
  display: inline-block;
  width: auto;
  height: auto;
  margin: 0;
}

button, a.secondary, a.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
}

button { border: 0; }

button:active, a.secondary:active, a.primary:active { transform: translateY(1px); }

.primary { background: var(--accent); color: var(--accent-ink); }

.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }

.danger { color: var(--danger); }

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

.sign-in {
  display: grid;
  place-items: center;
  background: var(--canvas);
}

.card {
  width: min(360px, calc(100% - 32px));
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
}

.card .brand { margin: 0 0 16px; }

.card h1 { margin-bottom: 8px; }

.card button { width: 100%; }

.menu form { margin-top: auto; padding-top: 16px; }

.menu .secondary { width: 100%; }

@media (max-width: 719px) {
  body:not(.sign-in) { grid-template-columns: 1fr; }

  .menu {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand, .group { width: 100%; }

  .menu form { margin-top: 0; width: 100%; }

  .summary, .summary-bars { grid-template-columns: 1fr; }

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

  table.list thead { display: none; }

  table.list, table.list tbody, table.list tr, table.list td { display: block; width: auto; }

  table.list tr { padding: 8px 0; }

  table.list td { border: 0; padding: 4px 8px; }

  table.list td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none; }
  button:active, a.secondary:active, a.primary:active { transform: none; }
}
