:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #e3e6eb;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #c62828;
  --ok-bg: #e6f4ea;  --ok-fg: #1e7a3a;
  --wait-bg: #fff4e0; --wait-fg: #9a5b00;
  --info-bg: #e8effd; --info-fg: #1d4fbf;
  --paid-bg: #efe7fb; --paid-fg: #6b3fb8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1d2128;
    --text: #e6e8eb;
    --muted: #9aa1ac;
    --border: #2c323b;
    --accent: #4f8cff;
    --danger: #ff6b6b;
    --ok-bg: #173323;  --ok-fg: #7ad69a;
    --wait-bg: #3a2c12; --wait-fg: #f2c46d;
    --info-bg: #1b2a4a; --info-fg: #9dbcff;
    --paid-bg: #2e2347; --paid-fg: #c9b0ff;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .25rem; }
.card h2 { margin-top: 0; }

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.who { display: flex; align-items: center; gap: .75rem; color: var(--muted); }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}
.narrow { max-width: 480px; margin: 2rem auto; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

.stats { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.stats div {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .75rem 1.25rem; min-width: 160px;
}
.stats span { display: block; color: var(--muted); font-size: .85rem; }
.stats strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.reason { max-width: 380px; overflow-wrap: anywhere; white-space: pre-line; }
.actions { white-space: nowrap; text-align: right; }
.actions > * { display: inline-block; margin-left: .6rem; vertical-align: middle; }
.muted { color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.filters { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters .total { margin-left: auto; color: var(--muted); }
.filters .total strong { color: var(--text); }

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .4rem; padding-bottom: .5rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 7px; padding: .5rem .65rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; }
small.err { color: var(--danger); font-weight: 400; }

button, .button {
  font: inherit; cursor: pointer; display: inline-block;
  padding: .5rem 1rem; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover, .button:hover { text-decoration: none; filter: brightness(.97); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.small { padding: .25rem .7rem; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
button.link:hover { text-decoration: underline; }
.danger, button.link.danger { color: var(--danger); }

.badge {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; text-transform: capitalize;
}
.badge.approved  { background: var(--ok-bg);   color: var(--ok-fg); }
.badge.pending   { background: var(--wait-bg); color: var(--wait-fg); }
.badge.paid      { background: var(--paid-bg); color: var(--paid-fg); }
.badge.unclaimed, .badge.admin { background: var(--info-bg); color: var(--info-fg); }

.flash {
  background: var(--ok-bg); color: var(--ok-fg);
  border-radius: 8px; padding: .65rem 1rem; margin-bottom: 1rem;
}
.flash.error { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }

@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .filters .total { margin-left: 0; width: 100%; }
}
