/* Rawstock Admin. One file, no dependencies. Phone first; wide screens get a table and more room. */
:root {
  --ground: #0b0a09; --surface: #161412; --raised: #201c19; --line: #2e2823;
  --text: #f5f3ee; --muted: #a09b92; --amber: #ffa630; --red: #ff5a4f; --green: #5fd08a;
  --radius: 12px;
  /* The page column: the bar's contents and the page share it, so their edges line up. */
  --column: 1040px;
  --gutter-left: max(16px, env(safe-area-inset-left)); --gutter-right: max(16px, env(safe-area-inset-right));
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
/* Weights are 500, 600 and 700 only: in-between values fall back unevenly on fonts that are not variable. */
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.wrap { overflow-wrap: anywhere; }
.gold { color: var(--amber); }
.hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.bar {
  position: sticky; top: 0; z-index: 2;
  background: color-mix(in srgb, var(--ground) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar-in {
  max-width: var(--column); margin: 0 auto; display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter-right) 10px var(--gutter-left);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; margin-right: auto; }
.brand:hover { text-decoration: none; }
.mark { width: 14px; height: 14px; border-radius: 50%; display: inline-block;
  background: conic-gradient(from 245deg, var(--amber) 0 180deg, var(--raised) 180deg 360deg); }
.bar nav { display: flex; gap: 4px; order: 3; width: 100%; }
.bar nav a, .tabs a {
  flex: 1; text-align: center; min-height: 44px; display: grid; place-items: center; padding: 0 14px;
  color: var(--muted); border-radius: 10px; font-weight: 500;
}
.bar nav a.on, .tabs a.on { background: var(--raised); color: var(--text); }
.bar nav a:hover, .tabs a:hover { text-decoration: none; color: var(--text); }
/* The button's own padding would set its words in from the column's edge. */
.bar form { margin-right: -8px; }

/* The first line of every page, title or back link, starts the same distance under the bar. */
main { max-width: var(--column); margin: 0 auto; padding: 24px var(--gutter-right) 48px var(--gutter-left); }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 16px; letter-spacing: -0.01em; }
h1.mono { font-size: 17px; font-weight: 600; line-height: 1.4; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 16px; font-weight: 600; margin: 0; }
.count { color: var(--muted); font-weight: 500; font-size: 18px; margin-left: 6px; }
section { margin-top: 28px; }
.head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
/* A 44px target whose words sit where a title's would: the 10px above them is taken back. */
.back { display: inline-flex; align-items: center; min-height: 44px; margin-top: -10px; }
.back::before { content: "‹"; margin-right: 6px; font-size: 20px; line-height: 1; }

button, input[type=search], input[type=text], input[type=password], input[type=date] {
  font: inherit; color: var(--text); min-height: 48px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 14px; width: 100%;
}
input::placeholder { color: #7d776e; }
button { cursor: pointer; font-weight: 600; width: auto; background: var(--raised); }
button:hover { border-color: #4a4139; }
button.primary { background: var(--amber); color: #1a1206; border-color: var(--amber); width: 100%; }
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--red); background: transparent; border-color: #5a2a26; width: 100%; }
button.quiet { background: transparent; border-color: transparent; color: var(--muted); min-height: 44px; padding: 0 8px; }
button.quiet:hover { color: var(--text); }
label { display: block; font-size: 14px; color: var(--muted); margin: 0; }

/* A form is a stack with one gap; nothing in it carries a margin of its own. */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.form > * { margin: 0; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.form button { justify-self: start; }

.note { padding: 12px 14px; border-radius: 10px; margin: 0 0 16px; border: 1px solid var(--line); background: var(--surface); }
.note.ok { border-color: #2c5a40; color: var(--green); }
.note.bad { border-color: #5a2a26; color: var(--red); }
.empty { color: var(--muted); padding: 22px 16px; border: 1px dashed var(--line); border-radius: var(--radius); margin: 0; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stats dt { color: var(--muted); font-size: 14px; }
.stats dd { margin: 2px 0 0; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }

.search { display: flex; gap: 8px; }
.search input { min-width: 0; }
.search button { flex: none; }
.tools { display: grid; gap: 4px; margin: 12px 0 10px; }
.tabs { display: flex; gap: 4px; background: var(--surface); border-radius: 12px; padding: 4px; }
/* Which order the cards are in, and the way to change it. Wide screens use the table's heading instead. */
.sortby { display: flex; align-items: center; justify-content: flex-end; gap: 2px; font-size: 14px; }
.sortby span { margin-right: 6px; }
.sortby a { min-height: 44px; display: grid; place-items: center; padding: 0 10px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.sortby a.on { color: var(--text); }
.sortby a.on::after, .row.heading .sorted::after { content: " ↓"; white-space: pre; color: var(--amber); }
.sortby a.on::after { display: contents; }
.sortby a:hover { text-decoration: none; color: var(--text); }

/* A user: a card on a phone. Every cell may shrink and cuts what does not fit with an ellipsis. */
.rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); min-height: 56px;
}
a.row:hover { text-decoration: none; border-color: #4a4139; }
.row.heading { display: none; }
.row .cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .id { font-weight: 600; }
.row .id.mono { font-size: 15px; }
.row .plan { justify-self: end; overflow: visible; }
.row .device, .row .version, .row .seen, .row .joined { color: var(--muted); font-size: 14px; }
.row .device { grid-column: 1 / -1; }
.row .joined { justify-self: end; }
.row .version { display: none; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.gold { color: var(--amber); border-color: #6b4a1a; background: #2a1d0a; }

/* Three slots, so the page count is in the middle whether or not there is a link on either side. */
.pager { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; margin-top: 18px; }
.pager .prev { justify-self: start; }
.pager .next { justify-self: end; }
.pager a { min-height: 44px; display: grid; place-items: center; padding: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }

/* A panel is a stack too: one gap between its parts, and a ruled line above each part that starts something new. */
.panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; }
.panel > * { margin: 0; }
.part { border-top: 1px solid var(--line); padding-top: 18px; }
div.part { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.state { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.facts { margin: 0; display: grid; gap: 0; }
.facts div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.facts div:last-child { padding-bottom: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; margin-bottom: 12px; float: left; width: 100%; }
/* Two to a line; a last one left on its own takes the whole line instead of half of it. */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; clear: both; }
.choices label { margin: 0; position: relative; }
.choices label:last-child:nth-child(odd) { grid-column: 1 / -1; }
.choices input { position: absolute; opacity: 0; inset: 0; }
.choices span { display: grid; place-items: center; min-height: 48px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 15px; font-weight: 500; background: var(--ground); cursor: pointer; text-align: center; padding: 0 8px; }
.choices input:checked + span { border-color: var(--amber); color: var(--amber); background: #2a1d0a; }
.choices input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 2px; }
/* The end date is asked for only while “Until a date” is the choice. A browser without :has() shows it always. */
.grant .until { display: none; }
.grant:has(input[value="date"]:checked) .until { display: grid; }
@supports not selector(:has(*)) { .grant .until { display: grid; } }
.check { display: flex; gap: 12px; align-items: flex-start; color: var(--text); font-size: 15px; min-height: 44px; padding: 10px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--red); }

/* A change-log line: what happened and to whom, then the detail and the time. Two lines on a phone, always. */
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 12px 0; border-top: 1px solid var(--line); }
.panel .log li:first-child { border-top: 0; padding-top: 0; }
.panel .log li:last-child { padding-bottom: 0; }
.log .what { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.log .act { flex: none; }
.log .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .who.mono { font-size: 14px; }
.log .meta { display: flex; align-items: baseline; gap: 12px; min-width: 0; color: var(--muted); font-size: 14px; }
.log .detail { min-width: 0; overflow-wrap: anywhere; }
.log .detail.mono { font-size: 13px; }
.log time { flex: none; margin-left: auto; white-space: nowrap; }

.center { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; padding: 0; }
.login h1 { display: flex; align-items: center; gap: 10px; font-size: 22px; margin-bottom: 20px; }
.login .form button { justify-self: stretch; }

@media (min-width: 760px) {
  .bar nav { order: 0; width: auto; }
  .bar nav a { flex: none; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .choices { grid-template-columns: repeat(5, 1fr); }
  .choices label:last-child:nth-child(odd) { grid-column: auto; }
  .tools { margin-bottom: 14px; }
  .tabs { display: inline-flex; justify-self: start; }
  .tabs a { flex: none; min-width: 96px; }
  .sortby { display: none; }
  .search { max-width: 520px; }
  /* A user: a table row. */
  .rows { gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
  .row, .row.heading {
    display: grid; grid-template-columns: minmax(0, 2fr) 124px minmax(0, 1.2fr) 64px 108px 108px;
    border: 0; border-radius: 0; border-top: 1px solid var(--line); padding: 12px 16px; background: transparent;
  }
  .rows > :first-child { border-top: 0; }
  a.row:hover { background: var(--raised); }
  .row.heading { color: var(--muted); font-size: 13px; font-weight: 600; min-height: 0; }
  .row.heading a { color: inherit; }
  .row.heading a[href]:hover { color: var(--text); text-decoration: none; }
  .row.heading .sorted { color: var(--text); }
  .row .device, .row .version, .row .seen, .row .joined, .row .plan { grid-column: auto; justify-self: start; display: block; font-size: 15px; }
  .row .device, .row .version, .row .seen, .row .joined { justify-self: stretch; }
  .row.heading .cell { font-size: 13px; }
  .row .id.mono { font-size: 14px; }
  .row .label { display: none; }
  .panel { padding: 22px; }
  .panel .form, .panel .field { max-width: 720px; }
  button.primary, button.danger { width: auto; padding: 0 22px; }
  .facts div { grid-template-columns: 160px minmax(0, 1fr); }
  /* A change-log line: one line, the time in a column of its own. */
  .log li { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; align-items: baseline; }
  .login button.primary { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .row, button, .choices span { transition: border-color .15s ease, background-color .15s ease, color .15s ease; }
}
