:root {
  color-scheme: light;
  --paper: #f8f9f3;
  --surface: #fff;
  --ink: #152c23;
  --muted: #5a6c62;
  --green: #174c38;
  --lime: #ddfa91;
  --line: #dce4d9;
  --soft: #eef2ea;
  --danger: #a3302a;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fdf1d6;
  --ok: #1f6b45;
  --ok-soft: #e2f4e8;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0f1a15;
    --surface: #16241d;
    --ink: #e7efe9;
    --muted: #9db0a5;
    --green: #2f7a57;
    --lime: #d7f87f;
    --line: #29392f;
    --soft: #1d2e25;
    --danger: #f08a80;
    --danger-soft: #3a1f1c;
    --warn: #f2c66b;
    --warn-soft: #382c14;
    --ok: #7fd3a3;
    --ok-soft: #173326;
  }
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 7px 12px; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: wait; }
button.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); }
button.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
button.ghost { border-color: transparent; background: transparent; }
button.small { padding: 4px 9px; font-size: 13px; }
input, select { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 10px; min-width: 0; }
:focus-visible { outline: 3px solid #5b9753; outline-offset: 2px; }
a { color: var(--green); }
@media (prefers-color-scheme: dark) { a { color: var(--lime); } }

.brand { display: flex; align-items: center; gap: 10px; }
.brand div { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 16px; letter-spacing: -.01em; }
.brand span { font-size: 12px; color: var(--muted); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: grid; gap: 16px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { font-size: 15px; color: var(--ink); }
.error { color: var(--danger); min-height: 1em; margin: 0; font-size: 14px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
#tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
#tabs button { border: 0; background: transparent; padding: 8px 12px; white-space: nowrap; color: var(--muted); }
#tabs button[aria-current="page"] { background: var(--soft); color: var(--ink); font-weight: 600; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
@media (max-width: 760px) { #tabs { order: 3; flex-basis: 100%; } .who { margin-left: auto; } }

main { width: min(1240px, 100%); margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 22px; margin: 0 0 16px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 24px 0 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 28px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.alert .value { color: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1 1 220px; }
.count { color: var(--muted); font-size: 13px; align-self: center; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
td .muted, .muted { color: var(--muted); font-size: 13px; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 4px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--soft); }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 760px) {
  table.cards thead { display: none; }
  table.cards tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.cards td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; }
  table.cards td.actions { justify-content: flex-end; padding-top: 8px; }
  table.cards td.actions::before { content: none; }
}

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 0; width: min(720px, calc(100% - 32px)); max-height: calc(100% - 48px); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
#dialog-body { padding: 22px; }
#dialog-body h2 { margin-top: 0; font-size: 18px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin: 12px 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
pre.mail { white-space: pre-wrap; background: var(--soft); border-radius: 10px; padding: 12px; font-size: 13px; overflow-wrap: anywhere; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 12px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
#toast.bad { background: var(--danger); }
.intro { margin: -8px 0 14px; }
.game-image { display: block; width: 100%; max-height: 240px; object-fit: cover; border-radius: 10px; margin: 6px 0 4px; }
