/* Phone-first. No framework, no build step. */

:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --text: #13232f;
  --muted: #5b6b77;
  --border: #d8e0e6;
  --accent: #0a6b8a;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --off: #9aa5ad;
  --warn-bg: #fff4d6;
  --warn-text: #6b4e00;
  --error: #b3261e;
  --radius: 10px;
  --gap: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d171e;
    --surface: #15232d;
    --text: #e3ebf0;
    --muted: #9aabb7;
    --border: #2a3b47;
    --accent: #4fb3d6;
    --accent-text: #08141b;
    --ok: #4cc27f;
    --off: #5e6c76;
    --warn-bg: #3a2f10;
    --warn-text: #f3d98b;
    --error: #ff8a80;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

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

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 12px var(--gap);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.brand span { color: var(--accent); }
.site-header nav { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; font-size: 15px; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--gap);
}

.site-footer {
  padding: var(--gap);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

h1 { font-size: 1.5rem; margin: 0 0 12px; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.muted { color: var(--muted); }

.banner {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: var(--radius);
  padding: 12px var(--gap);
  margin-bottom: var(--gap);
}
.error { color: var(--error); }

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=number], select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input.code { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; }

button, .button {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
button.secondary {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
}
button.danger { background: var(--error); color: #fff; }
form.inline { display: inline; }

/* Tables become stacked rows on phones. */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { font-size: 13px; color: var(--muted); font-weight: 600; }

@media (max-width: 600px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.stack td {
    position: relative;
    min-height: 1.5em;
    padding: 2px 0 2px 7.5rem;
    border: 0;
    overflow-wrap: anywhere;
  }
  table.stack td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 7rem;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5rem;
  }
  table.stack td.actions { padding-left: 0; margin-top: 6px; }
}

/* Online dot */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--off);
  vertical-align: middle;
  margin-right: 6px;
}
.dot.online { background: var(--ok); }

/* htmx indicator styles (htmx's own are inline, which the CSP blocks). */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }

pre.secret, code.secret {
  display: block;
  padding: 12px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 15px;
}

.card.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
button.link {
  margin: 0;
  padding: 0;
  color: var(--accent);
  background: none;
  font-weight: 400;
  text-decoration: underline;
}

.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr svg { width: 100%; max-width: 240px; height: auto; border-radius: 6px; }
pre.recovery { font-size: 17px; line-height: 1.8; text-align: center; }

.flash {
  background: var(--surface);
  border-left: 4px solid var(--ok);
  border-radius: var(--radius);
  padding: 10px var(--gap);
  margin-bottom: var(--gap);
}
button.small { margin-top: 0; padding: 6px 10px; font-size: 14px; }
td.actions { display: flex; flex-wrap: wrap; gap: 6px; }
td.actions a.small { align-self: center; font-size: 14px; padding: 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
td .muted { display: block; font-size: 13px; }
.card > h1:first-child, .card > h2:first-child { margin-top: 0; }
