/* rurl dashboard -- one stylesheet, light and dark, no build step. */

:root {
  color-scheme: light dark;

  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --border: #e2e2e6;
  --border-strong: #cfcfd6;

  --text: #16161a;
  --text-muted: #6c6c78;
  --text-faint: #96969f;

  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef2ff;
  --accent-text: #ffffff;

  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-soft: #fef2f2;

  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #a16207;
  --warn-soft: #fefce8;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgb(16 16 26 / 6%), 0 8px 24px -12px rgb(16 16 26 / 18%);
  --shadow-lg: 0 12px 48px -12px rgb(16 16 26 / 32%);

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

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d10;
    --surface: #16161a;
    --surface-2: #1d1d22;
    --border: #27272e;
    --border-strong: #3a3a44;

    --text: #ececf1;
    --text-muted: #9c9caa;
    --text-faint: #6e6e7c;

    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1e1b3f;
    --accent-text: #0d0d10;

    --danger: #f87171;
    --danger-hover: #fca5a5;
    --danger-soft: #2a1416;

    --ok: #4ade80;
    --ok-soft: #0f2417;
    --warn: #fbbf24;
    --warn-soft: #2a2110;

    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
    --shadow-lg: 0 12px 48px -12px rgb(0 0 0 / 80%);
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.is-modal-open { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 620; letter-spacing: -0.011em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0; }

a { color: var(--accent); text-decoration-color: color-mix(in oklab, var(--accent) 35%, transparent); }
a:hover { color: var(--accent-hover); }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); font-size: 0.9em; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; align-items: center; gap: 0.5rem; }
.row--wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

/* --------------------------------------------------------------- layout -- */

.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.5rem;
  height: 56px;
  background: color-mix(in oklab, var(--surface) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  font-size: 1.0625rem;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.8125rem;
  font-weight: 700;
}

.brand--lg { font-size: 1.375rem; gap: 0.625rem; }
.brand--lg .brand__mark { width: 34px; height: 34px; border-radius: 9px; font-size: 1.0625rem; }

.nav { display: flex; gap: 0.25rem; }
.nav a {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.is-active { background: var(--accent-soft); color: var(--accent); }

@media (prefers-color-scheme: dark) {
  .nav a.is-active { color: var(--accent-hover); }
}

.topbar__account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.main { flex: 1; width: 100%; max-width: 940px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.page__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page__head p { margin-top: 0.25rem; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card__body { padding: 1.25rem; }
.card__foot {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.button:hover:not(:disabled) { background: var(--accent-hover); }
.button:disabled { opacity: 0.55; cursor: not-allowed; }

.button--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.button--ghost:hover:not(:disabled) { background: var(--surface-2); }

.button--danger { background: var(--danger); color: #fff; }
.button--danger:hover:not(:disabled) { background: var(--danger-hover); }

@media (prefers-color-scheme: dark) {
  .button--danger { color: #16161a; }
}

.button--small { padding: 0.3rem 0.6rem; font-size: 0.8125rem; }
.button--block { width: 100%; }
.button.is-copied { color: var(--ok); border-color: var(--ok); }

.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }

.linklike {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --------------------------------------------------------------- fields -- */

.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field label { font-size: 0.875rem; font-weight: 550; }

.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.5rem 0.6875rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 18%, transparent);
}
.field input[type="url"], .field input[name="alias"] { font-family: var(--mono); font-size: 0.875rem; }

.field__hint { font-size: 0.8125rem; color: var(--text-muted); }
.field__error { font-size: 0.8125rem; color: var(--danger); font-weight: 500; }
.field--invalid input { border-color: var(--danger); }

.form-error {
  padding: 0.625rem 0.75rem;
  border: 1px solid color-mix(in oklab, var(--danger) 40%, transparent);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.875rem;
}

.checkbox { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.checkbox input { width: auto; }

/* A short list of radios reads as one control, so it sits tighter than the
   1rem the surrounding .stack uses between separate fields. */
.choices { display: flex; flex-direction: column; gap: 0.5rem; }

/* `display: flex` above is an author rule, so it beats the user agent's
   `[hidden] { display: none }` and a hidden field would still show. */
.field[hidden], .checkbox[hidden] { display: none; }

/* --------------------------------------------------------------- tables -- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
thead th {
  padding: 0.625rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
tbody td { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* Sized so the five columns fit the card at full width -- otherwise the list
   picks up a horizontal scrollbar on a desktop, where there is room to spare.
   Narrower viewports still scroll inside .table-wrap, which is intended. */
.dest-link {
  display: inline-block;
  max-width: 320px;
  vertical-align: bottom;
}

.code-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 550;
}

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

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.badge--active { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in oklab, var(--ok) 30%, transparent); }
.badge--expired { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in oklab, var(--warn) 30%, transparent); }
.badge--disabled, .badge--revoked { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklab, var(--danger) 30%, transparent); }

/* ---------------------------------------------------------------- stats -- */

.stat {
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.stat__value { font-size: 2rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__label { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem; align-items: start; }
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }

.definition { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 0.625rem 1rem; font-size: 0.9375rem; }
.definition dt { color: var(--text-muted); }
.definition dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* A QR has to survive being photographed off a screen, which is a much lower
   effective resolution than it looks. At 168px a version-3 code is under 4
   device pixels per module and phones simply fail to lock onto it -- the
   quiet zone and padding are white on purpose for the same reason. */
.qr {
  display: block;
  width: 240px;
  max-width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: #000;
}
.qr svg { display: block; width: 100%; height: auto; }

/* Clickable version: opens the same code large enough to scan comfortably. */
button.qr {
  cursor: zoom-in;
  appearance: none;
  font: inherit;
}
button.qr:hover { border-color: var(--accent); }

.qr--lg {
  width: min(78vw, 420px);
  margin: 0 auto;
  padding: 18px;
}

.qr-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  text-align: center;
}

/* --------------------------------------------------------- empty/loading -- */

.empty { padding: 3rem 1.5rem; text-align: center; }
.empty h3 { margin-bottom: 0.375rem; }
.empty p { margin-bottom: 1rem; }

.loading { display: flex; align-items: center; justify-content: center; gap: 0.625rem; padding: 3rem; }
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

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

.login-screen { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login { width: 100%; max-width: 380px; }
.login__brand { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.login__note {
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* --------------------------------------------------------------- modals -- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgb(10 10 14 / 55%);
  backdrop-filter: blur(3px);
  animation: fade 0.14s ease-out;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 3rem);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.modal--wide { max-width: 560px; }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal__body { padding: 1.25rem; overflow-y: auto; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border);
}

.warn-box {
  padding: 0.75rem 0.875rem;
  border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.875rem;
}
.danger-box {
  padding: 0.75rem 0.875rem;
  border: 1px solid color-mix(in oklab, var(--danger) 40%, transparent);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.875rem;
}

.secret {
  display: block;
  padding: 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.8125rem;
  word-break: break-all;
  user-select: all;
}

.review { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 0.5rem 1rem; font-size: 0.9375rem; }
.review dt { color: var(--text-muted); }
.review dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* --------------------------------------------------------------- toasts -- */

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(400px, calc(100vw - 2rem));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0.75rem 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: slide-in 0.16s ease-out;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } }
.toast--danger { border-left-color: var(--danger); }
.toast--success { border-left-color: var(--ok); }
.toast__body { flex: 1; min-width: 0; }
.toast__message { font-size: 0.875rem; }
.toast__detail { margin-top: 0.25rem; font-size: 0.75rem; color: var(--text-faint); font-family: var(--mono); }
.toast__close {
  border: none;
  background: none;
  color: var(--text-faint);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.125rem;
}
.toast__close:hover { color: var(--text); }

/* ----------------------------------------------------------- pagination -- */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.pager__label { font-size: 0.875rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ responsive -- */

@media (max-width: 620px) {
  /* Everything has to fit one 56px row: tighten the nav rather than let a
     two-word item wrap and push itself out of the bar. */
  .topbar { padding: 0 0.75rem; gap: 0.5rem; }
  .topbar__account { gap: 0.5rem; }
  .topbar__account .email { display: none; }
  .nav { gap: 0.125rem; }
  .nav a { padding: 0.375rem 0.5rem; font-size: 0.875rem; }
  .main { padding: 1.5rem 1rem 3rem; }
  .page__head { flex-direction: column; align-items: stretch; }
  thead th, tbody td { padding-left: 0.875rem; padding-right: 0.875rem; }
  .definition { grid-template-columns: 1fr; gap: 0.25rem; }
  .definition dt { margin-top: 0.5rem; font-size: 0.8125rem; }
}

/* Below this the wordmark is what has to give; the mark still identifies it. */
@media (max-width: 430px) {
  .brand > span:not(.brand__mark) { display: none; }
}
