:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #5d6670;
  --line: #d8dce1;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok: #1e7b34;
  --warn-bg: #fff4d6;
  --warn-text: #6b4a00;
  --focus: #ffb000;
  --row-hover: #eef3fb;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --card: #1c1f24;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --line: #333941;
    --accent: #5b9bff;
    --accent-text: #0b1220;
    --danger: #ff6b61;
    --ok: #5fd27a;
    --warn-bg: #3a2f10;
    --warn-text: #ffd77a;
    --row-hover: #252b33;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1 { font-size: 1.25rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; overflow-wrap: anywhere; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
a { color: var(--accent); }
code, .mono, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: .25rem .5rem; border-radius: 4px; }
.strong { font-weight: 600; }
[hidden] { display: none !important; }

/* Header */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { margin-right: auto; }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.top nav a[aria-current="page"] { font-weight: 700; text-decoration: none; }
.demo-banner { background: var(--warn-bg); color: var(--warn-text); font-weight: 700; padding: .15rem .6rem; border-radius: 4px; }

main { padding: 1rem; max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1rem; min-width: 0; }
.narrow { max-width: 380px; width: 100%; margin: 2rem auto; }

/* Forms */
label { display: block; margin: .6rem 0 .2rem; font-weight: 600; }
label.check { font-weight: 400; display: flex; gap: .4rem; align-items: flex-start; }
input, select, textarea, button, .button {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 4px; padding: .4rem .55rem;
}
input:not([type=checkbox]), select, textarea { width: 100%; }
textarea { resize: vertical; }
button, .button {
  cursor: pointer; background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  font-weight: 600; text-decoration: none; display: inline-block;
}
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.row { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; }
.row.wrap { flex-wrap: wrap; }
.row.spread { justify-content: space-between; margin-top: 0; }
.toolbar { display: grid; grid-template-columns: 1fr 160px auto; gap: .5rem; align-items: end; margin-bottom: .75rem; }
.toolbar label { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1rem; }
.grid .full { grid-column: 1 / -1; }

/* Tables: the wrapper scrolls sideways so the page itself never does. */
.scroll { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
td.num { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--row-hover); }
.tier { font-weight: 600; }
.tier-free { color: var(--muted); }
.diff { margin: 0; padding-left: 1rem; white-space: normal; font-family: ui-monospace, Consolas, monospace; font-size: .85em; }

/* User detail */
.fields { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; margin: .5rem 0; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; }

/* Dialog and results */
dialog {
  width: min(480px, calc(100vw - 2rem)); background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 1rem;
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.result { margin-top: .75rem; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: .5rem; overflow-x: auto; }
pre.codes { max-height: 50vh; overflow: auto; }
.qr { display: block; background: #fff; padding: 8px; margin: .5rem 0; }

@media (max-width: 600px) {
  main { padding: .5rem; }
  .toolbar { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .fields dd { margin-bottom: .4rem; }
}

/* Text-style button, e.g. "Forgot password?" next to Sign in. */
button.link {
  background: none;
  border: 0;
  color: var(--accent, #5b9cff);
  text-decoration: underline;
  padding: 0 4px;
  cursor: pointer;
}
