/*
 * Shared styles. One file, plain CSS, no framework — this is a utility.
 *
 * Committed dark theme: `color-scheme: dark` so native controls (checkboxes,
 * scrollbars, focus rings) render dark too rather than punching white holes in
 * the page.
 */

:root {
  color-scheme: dark;

  --bg: #0b0d10;
  --surface: #14171c;
  --surface-hi: #1b1f26;
  --border: #272c35;
  --border-hi: #363d49;

  --text: #e7eaf0;
  --muted: #9aa3b2;
  --faint: #6b7484;

  --accent: #7c9cff;
  --accent-hi: #9db3ff;
  --danger: #ff7b72;
  --danger-bg: #2a1618;
  --ok: #5ed6a4;

  --radius: 12px;
  --radius-sm: 8px;
  --gap: 1rem;
  --maxw: 46rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2.5rem 1.25rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--maxw); margin: 0 auto; }
.wrap-sm { max-width: 26rem; margin: 0 auto; }
/* For the column-heavy tables, which do not fit the default reading width. */
.wrap-wide { max-width: 64rem; }

/* Vertically centred single-purpose screens (login, recovery). */
.center {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

/* ---------------------------------------------------------------- headings */

h1 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 .35rem;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 2rem 0 .75rem;
}

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); text-decoration: underline; }

.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: .875rem; }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); }

/* ------------------------------------------------------------------ header */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
  padding-bottom: 1rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.topbar h1 { flex: 1; margin: 0; }

.topbar nav {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.topbar nav a {
  color: var(--muted);
  padding: .4rem .7rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
}

.topbar nav a:hover {
  color: var(--text);
  background: var(--surface-hi);
  text-decoration: none;
}

.topbar form { margin: 0; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.card-center { text-align: center; }

/* ---------------------------------------------------------------- buttons */

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font: 500 .9rem/1 var(--font);
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hi);
  background: var(--surface-hi);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

button:hover,
.btn:hover {
  background: #232833;
  border-color: #434b59;
  text-decoration: none;
  color: var(--text);
}

button:active, .btn:active { transform: translateY(1px); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d10;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
  color: #0b0d10;
}

.btn-danger {
  color: var(--danger);
  border-color: #4a2b2c;
  background: var(--danger-bg);
}

.btn-danger:hover {
  background: #3a1d1f;
  border-color: #6b3a3c;
  color: var(--danger);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover { background: var(--surface-hi); color: var(--text); }

.btn-sm { padding: .35rem .7rem; font-size: .825rem; }

.actions {
  display: flex;
  gap: .6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

.actions-center { justify-content: center; }

/* ------------------------------------------------------------------ forms */

label { display: block; margin-bottom: .4rem; font-size: .9rem; color: var(--muted); }

input[type=text] {
  width: 100%;
  font: 1rem/1.4 var(--mono);
  padding: .7rem .85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hi);
  background: var(--bg);
  color: var(--text);
}

input[type=text]:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(124, 156, 255, .18);
}

.check {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  margin: 1rem 0;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
}

.check input { margin-top: .2rem; accent-color: var(--accent); }

input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

fieldset { border: 0; padding: 0; margin: 1.5rem 0; }

.choice {
  display: flex;
  gap: .6rem;
  align-items: center;
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
  cursor: pointer;
  color: var(--text);
  font-size: .9rem;
}

.choice:hover { border-color: var(--border-hi); background: var(--surface-hi); }

/* ------------------------------------------------------------------ table */

table { border-collapse: collapse; width: 100%; font-size: .9rem; }

th {
  text-align: left;
  font-weight: 500;
  font-size: .775rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 .7rem .6rem;
  border-bottom: 1px solid var(--border);
}

td {
  padding: .75rem .7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:hover td { background: var(--surface); }
tbody tr:last-child td { border-bottom: 0; }

td.name { overflow-wrap: anywhere; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.when, th.when { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
td.ua { color: var(--muted); font-size: .825rem; }
td.right, th.right { text-align: right; }

/*
 * User-agent strings are long enough to collapse a table column and then wrap
 * one character per line. Clamp to a single line with an ellipsis; the full
 * value stays available as a tooltip. `display:block` is what makes max-width
 * actually bind inside a table cell.
 */
.trunc {
  display: block;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-scroll { overflow-x: auto; }

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .03em;
  padding: .18rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--border-hi);
  color: var(--muted);
  white-space: nowrap;
}

.badge-accent { color: var(--accent); border-color: #33405e; background: #161c2b; }

/* ---------------------------------------------------------------- notices */

.notice {
  padding: .75rem 1rem;
  border: 1px solid var(--border-hi);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 1.5rem;
  font-size: .9rem;
}

.notice-error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.empty {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius);
}

/* -------------------------------------------------------------- login/QR */

/*
 * The QR needs a light background to stay scannable — do not "fix" this to
 * match the dark theme, phones will fail to read it.
 */
.qr {
  display: inline-block;
  background: #fff;
  padding: .9rem;
  border-radius: var(--radius);
  line-height: 0;
}

.qr img { width: 232px; height: 232px; display: block; }

.code {
  font: 600 2.75rem/1 var(--mono);
  letter-spacing: .12em;
  margin: 1.5rem 0 .35rem;
  color: var(--text);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--muted);
  font-size: .875rem;
}

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 0%,100% { opacity: .25 } 50% { opacity: 1 } }

@media (prefers-reduced-motion: reduce) {
  .dot { animation: none; opacity: .8 }
  button:active, .btn:active { transform: none }
}

/* --------------------------------------------------- approval (on phone) */

.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .5rem 1rem;
  font-size: .9rem;
  margin: 0 0 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.meta dt { color: var(--faint); }
.meta dd { margin: 0; overflow-wrap: anywhere; }

.codes { display: flex; gap: .75rem; }

.codes button {
  flex: 1;
  font: 600 1.75rem/1 var(--mono);
  padding: 1.15rem 0;
  letter-spacing: .05em;
}

.codes button:hover { border-color: var(--accent); color: var(--accent); }

.deny {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
  background: none;
  border: 0;
  color: var(--faint);
  text-decoration: underline;
  font-size: .875rem;
  padding: .5rem;
}

.deny:hover { background: none; color: var(--danger); border: 0; }

/* ----------------------------------------------------------------- uppy */

/* Let the dashboard sit flush with the page rather than floating in a box. */
.uppy-Dashboard-inner { border-radius: var(--radius) !important; }
#uppy { margin: 1.25rem 0 1.5rem; }
.uppy-Dashboard-browse { color: var(--accent) !important; }

@media (max-width: 34rem) {
  body { padding: 1.5rem 1rem 3rem; }
  .topbar { gap: .5rem; }
  .code { font-size: 2.25rem; }
  td.ua { max-width: 9rem; }
}
