:root {
  --paper: #e8ecef;
  --surface: #f7f9fa;
  --ink: #17222c;
  --muted: #566572;
  --line: #bfc9d1;
  --accent: #1e5b74;
  --accent-ink: #ffffff;
  --danger: #a1342c;
  --ok: #2d6a4f;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f161c;
    --surface: #16202a;
    --ink: #e2e8ed;
    --muted: #8d9ca8;
    --line: #2f3d48;
    --accent: #7dbad3;
    --accent-ink: #0f161c;
    --danger: #e58a80;
    --ok: #7cc4a0;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.gate { width: 100%; max-width: 24rem; }

.brand { margin: 0 0 1.75rem; font-weight: 600; font-size: .95rem; color: var(--muted); }

.progress { display: grid; grid-template-columns: 1fr 1fr; gap: .375rem; margin-bottom: 1.5rem; }
.progress[hidden] { display: none; }
.progress span { height: 3px; border-radius: 2px; background: var(--line); transition: background .25s; }
.progress span.on { background: var(--accent); }

.dest { margin: 0 0 1.75rem; display: grid; gap: .125rem; }
.dest[hidden] { display: none; }
.dest-label { font-size: .875rem; color: var(--muted); }
.dest-host {
  font-size: clamp(1.5rem, 6vw, 1.875rem);
  font-weight: 650;
  letter-spacing: -.015em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

h1 { font-size: 1.25rem; font-weight: 650; margin: 0 0 .5rem; letter-spacing: -.005em; }
.lead { margin: 0 0 1.25rem; color: var(--muted); }
.hint { margin: -.25rem 0 1rem; font-size: .875rem; color: var(--muted); }
.aside { margin: 1.25rem 0 0; font-size: .9375rem; }

label { display: block; font-size: .9375rem; font-weight: 550; margin: 0 0 .375rem; }
.field {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .7rem .8rem;
  margin-bottom: 1.125rem;
}

/* PIN: zes vakjes boven één echt invoerveld */
.pin { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; margin-bottom: 1.125rem; }
.pin input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; margin: 0;
  font-size: 16px; /* voorkomt zoom op iOS */
  caret-color: transparent;
}
.pin i {
  display: grid; place-items: center;
  aspect-ratio: 1 / 1.15;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-style: normal;
  transition: border-color .15s;
}
.pin i.filled::after { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--ink); }
.pin:focus-within i.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pin.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

button {
  font: inherit; width: 100%; cursor: pointer;
  border-radius: 6px; padding: .8rem 1rem;
  border: 1px solid var(--accent);
}
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
button.choice { display: grid; gap: .125rem; text-align: left; padding: .9rem 1rem; margin-bottom: .625rem; }
button.choice span { font-size: .875rem; font-weight: 400; opacity: .85; }
button:disabled { opacity: .55; cursor: progress; }

a { color: var(--accent); text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.status { min-height: 1.5rem; margin: 1rem 0 0; font-size: .9375rem; }
.status.error { color: var(--danger); }
.status.ok { color: var(--ok); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.links a + a { margin-left: 1.25rem; }

/* ---------- beheer ---------- */
body.admin { display: block; place-items: initial; padding: 2rem 1.25rem 3rem; }
.wrap { max-width: 64rem; margin: 0 auto; }
.admin-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1.5rem; margin-bottom: 2rem; }
.admin-head h1 { font-size: 1.5rem; margin: 0; }
.admin-head p { margin: 0; color: var(--muted); font-size: .9375rem; }
.admin-head a { margin-left: .75rem; }

.panel { border-top: 1px solid var(--line); padding-top: 1.25rem; margin-bottom: 2.25rem; }
.panel h2 { font-size: 1.0625rem; font-weight: 650; margin: 0 0 1rem; }

.create { display: grid; grid-template-columns: 1fr 1fr 8rem auto; gap: .75rem; align-items: end; }
.create .field, .create select { margin-bottom: 0; }
.create button { width: auto; padding: .7rem 1.1rem; }
select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: .7rem .6rem; width: 100%;
}
@media (max-width: 44rem) { .create { grid-template-columns: 1fr; } .create button { width: 100%; } }

.reveal {
  border: 2px solid var(--accent); border-radius: 8px; padding: 1.25rem 1.25rem 1rem;
  margin-bottom: 2.25rem; background: var(--surface);
}
.reveal[hidden] { display: none; }
.reveal p { margin: 0 0 .75rem; }
.reveal .code {
  font-size: clamp(2.25rem, 9vw, 3.25rem); font-weight: 650; letter-spacing: .12em;
  font-variant-numeric: tabular-nums; line-height: 1; margin: .25rem 0 1rem; color: var(--accent);
}
.reveal .row { display: flex; gap: .75rem; flex-wrap: wrap; }
.reveal .row button { width: auto; }

.users { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.users th { text-align: left; font-weight: 550; color: var(--muted); font-size: .875rem; padding: 0 .75rem .5rem 0; border-bottom: 1px solid var(--line); }
.users td { padding: .85rem .75rem .85rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.users .who strong { display: block; font-weight: 600; }
.users .who span { color: var(--muted); }
.users .sub { display: block; color: var(--muted); font-size: .8125rem; margin-top: .125rem; }
.tag { display: inline-block; font-size: .8125rem; font-weight: 550; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.tag.active { color: var(--ok); border-color: currentColor; }
.tag.onboarding { color: var(--accent); border-color: currentColor; }
.tag.expired, .tag.disabled, .tag.locked { color: var(--danger); border-color: currentColor; }
.tag.admin { color: var(--muted); margin-left: .375rem; }
.actions { display: flex; flex-wrap: wrap; gap: .375rem .875rem; }
.actions button {
  width: auto; padding: 0; border: 0; background: none; color: var(--accent);
  font-size: .875rem; text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.actions button.danger { color: var(--danger); }
.empty { color: var(--muted); }
@media (max-width: 44rem) {
  .users thead { display: none; }
  .users tr { display: block; border-bottom: 1px solid var(--line); padding: .75rem 0; }
  .users td { display: block; border: 0; padding: .2rem 0; }
}

/* ---------- apps en groepen (beheer) ---------- */
.panel-lead { margin: -.5rem 0 1rem; color: var(--muted); font-size: .9375rem; max-width: 60ch; }
.create.app { grid-template-columns: 1fr 1fr 2fr 11rem auto; }
@media (max-width: 60rem) { .create.app { grid-template-columns: 1fr; } .create.app button { width: 100%; } }
.reveal .code.long {
  font-size: 1.05rem; letter-spacing: 0; line-height: 1.4; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.users .groups { display: flex; flex-wrap: wrap; gap: .25rem; }
.tag.group { color: var(--ink); }
.users .url { overflow-wrap: anywhere; font-size: .875rem; }

/* ---------- portal ---------- */
.wrap.narrow { max-width: 48rem; }
.status.top { margin: 0 0 1.25rem; }
.status.top[hidden] { display: none; }
.applist { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.applist a {
  display: block; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-weight: 600; text-decoration: none; color: var(--ink);
}
.applist a:hover { border-color: var(--accent); }
.applist .empty { color: var(--muted); grid-column: 1 / -1; }
.create.pk { grid-template-columns: 1fr 10rem 9rem auto; margin-top: 1rem; }
.create.pin3 { grid-template-columns: 1fr 1fr 1fr auto; }
@media (max-width: 44rem) { .create.pk, .create.pin3 { grid-template-columns: 1fr; } }

/* ---------- beheer: detailregels ---------- */
.users tr.detail td { background: var(--surface); padding: .75rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin: 0 0 .75rem; }
.checks label { font-weight: 500; display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
.detail .row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.detail .row button { width: auto; padding: .5rem .9rem; }
.detail .row .field, .detail .row select { width: auto; min-width: 14rem; margin: 0; }
.create.user { grid-template-columns: 1fr 1fr 1fr 8rem auto; }
.create .check { display: flex; align-items: center; gap: .4rem; padding-bottom: .7rem; }
.create .check label { margin: 0; font-weight: 500; }
@media (max-width: 60rem) { .create.user { grid-template-columns: 1fr; } }
.create.app { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 60rem) { .create.app { grid-template-columns: 1fr; } }
.panel-lead code { font-size: .875em; }
