:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c1f23;
  --muted: #667085;
  --line: #e2e5ea;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok-bg: #e7f5ec;
  --error-bg: #fdecec;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1f26;
    --text: #e8eaed;
    --muted: #9aa3af;
    --line: #2b323c;
    --accent: #6b9bf5;
    --accent-text: #0b1220;
    --ok: #4ade80;
    --warn: #fbbf24;
    --danger: #f87171;
    --ok-bg: #12301d;
    --error-bg: #3a1717;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar form { margin: 0; }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
p { margin: 8px 0; }

.muted { color: var(--muted); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 12px; }
.auth { max-width: 380px; margin: 8vh auto 0; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 92px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
}
.tile:hover, a.list-item:hover { border-color: var(--accent); }
.tile-title { font-weight: 600; font-size: 1.05rem; }
.tile-note { font-size: 0.85rem; color: var(--muted); }
.tile-later .tile-title { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-top: 14px;
}
.badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  vertical-align: middle;
}

.list { display: grid; gap: 10px; margin-top: 16px; }
.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
}
.list-item-later { color: var(--muted); }

form.stack { display: grid; gap: 12px; margin-top: 16px; }
label { display: grid; gap: 4px; font-size: 0.9rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, a.button {
  display: inline-block;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}
button.secondary, a.button.secondary { color: var(--text); background: transparent; border-color: var(--line); }
button.danger { color: var(--danger); background: transparent; border-color: var(--danger); }
button.link {
  padding: 0;
  font-weight: 400;
  color: var(--accent);
  background: none;
  border: 0;
  text-decoration: underline;
}

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row input, .row select { flex: 1 1 160px; width: auto; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; }
.toolbar form { flex: 1 1 220px; margin: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card > h2 + form { margin-top: 0; }

.line {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
}
.line:hover .line-main { color: var(--accent); }
.line-time { min-width: 3.2em; font-weight: 600; font-variant-numeric: tabular-nums; }
.line-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.status {
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  white-space: nowrap;
}
.status-arrived { color: var(--ok); }
.status-no_show { color: var(--danger); }
.status-cancelled { color: var(--muted); text-decoration: line-through; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.tab {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
}
.tab-active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 8px 6px; text-align: left; border-top: 1px solid var(--line); }
.table thead th { border-top: 0; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.rate { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.rate-name { flex: 1 1 180px; }
.rate input { flex: 1 1 110px; width: auto; }
.comment { padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.comment:first-of-type { margin-top: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions form { margin: 0; }

details { margin-top: 12px; }
summary { cursor: pointer; color: var(--accent); }

code {
  font-size: 1.05em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg);
  letter-spacing: 0.05em;
}

.flash {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  background: var(--ok-bg);
  overflow-wrap: anywhere;
}
.flash-error { background: var(--error-bg); }
