:root {
  --indigo: #5b5bf0;
  --indigo-dark: #4646d2;
  --ink: #17182f;
  --muted: #686b82;
  --line: #e5e6f0;
  --bg: #f5f6fb;
  --ok: #238b68;
  --danger: #c83d58;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(91,91,240,.12), transparent 35rem),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, a, input, select { font: inherit; }
button, .button { touch-action: manipulation; }
.shell { width: min(1040px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 30px; }
.brand { display: flex; align-items: center; gap: 12px; }
.mark { width: 72px; height: 46px; flex: none; display: grid; place-items: center; }
.mark img { width: 100%; height: 100%; object-fit: contain; }
.brand strong { display: block; font-size: 20px; letter-spacing: -.02em; }
.brand span { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.link-button, .logout { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 10px; padding: 10px 14px; text-decoration: none; cursor: pointer; }
.logout { margin: 0; }
.install-button { border: 1px solid #d9dafe; background: #f3f3ff; color: var(--indigo); border-radius: 11px; padding: 11px 14px; font-weight: 750; cursor: pointer; touch-action: manipulation; }
.install-button:hover { background: #e8e8ff; }
.install-button span { display: inline-block; margin-right: 5px; font-size: 18px; line-height: 0; transform: translateY(1px); }
.auth-card > .install-button { width: 100%; margin-top: 10px; }
.top-install { white-space: nowrap; }
.pwa-standalone [data-install-app] { display: none !important; }
.pwa-dialog { width: min(430px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 22px; color: var(--ink); box-shadow: 0 22px 70px rgba(23,24,47,.22); }
.pwa-dialog::backdrop { background: rgba(23,24,47,.42); backdrop-filter: blur(3px); }
.pwa-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.pwa-dialog h2 { margin: 0; font-size: 22px; }
.pwa-dialog p { color: var(--muted); }
.pwa-dialog-note { padding: 11px 12px; border-radius: 10px; background: #f3f3ff; font-size: 13px; }
.pwa-dialog-close { border: 0; background: #f0f0f7; color: var(--ink); width: 36px; height: 36px; border-radius: 50%; font-size: 24px; cursor: pointer; }
.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; align-items: stretch; }
.card { background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: 0 12px 40px rgba(25,27,73,.06); }
.card h1, .card h2 { margin: 0; letter-spacing: -.025em; }
.card h1 { font-size: clamp(25px, 4vw, 38px); line-height: 1.12; }
.card h2 { font-size: 17px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.section-note { margin: 7px 0 15px; color: var(--muted); font-size: 12.5px; }
.status-pill { display: inline-flex; align-items: center; min-height: 32px; padding: 6px 11px; border-radius: 999px; background: #ececf6; color: var(--muted); font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.status-pill.ok { background: #e2f6ee; color: var(--ok); }
.status-pill.danger { background: #fff0f3; color: var(--danger); }
.fleet { margin-bottom: 18px; }
.fleet h1 { font-size: 24px; }
.quest-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quest-slot { min-height: 164px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fafaff; display: flex; flex-direction: column; gap: 8px; }
.quest-slot.empty { justify-content: center; text-align: center; color: var(--muted); border-style: dashed; }
.quest-slot-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.quest-slot-head strong { font-size: 14px; }
.quest-token { color: var(--indigo); font-size: 12px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.quest-meta { display: grid; gap: 4px; color: var(--muted); font-size: 11.5px; }
.quest-meta b { color: var(--ink); }
.quest-actions { display: flex; gap: 6px; margin-top: auto; }
.quest-actions a, .quest-actions button { flex: 1; min-height: 36px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--indigo); font: inherit; font-size: 11px; font-weight: 750; text-align: center; text-decoration: none; cursor: pointer; }
.quest-actions .finish-session { color: var(--danger); }
.lead { color: var(--muted); margin: 10px 0 24px; max-width: 44rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 12.5px; font-weight: 700; }
input, select { width: 100%; border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 11px; padding: 12px 13px; outline: none; }
input:focus, select:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(91,91,240,.12); }
.primary { width: 100%; border: 0; border-radius: 12px; background: var(--indigo); color: white; font-weight: 750; padding: 14px 18px; margin-top: 18px; cursor: pointer; }
.primary:hover { background: var(--indigo-dark); }
.primary:disabled { opacity: .55; cursor: wait; }
.steps { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 16px; }
.steps li { display: grid; grid-template-columns: 31px 1fr; gap: 10px; color: var(--muted); }
.steps b { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; background: #eeeefe; color: var(--indigo); }
.steps strong { color: var(--ink); display: block; }
.recent { margin-top: 18px; }
.recent-list { margin-top: 12px; display: grid; gap: 8px; }
.recent-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--muted); }
.recent-item strong { color: var(--ink); text-transform: uppercase; letter-spacing: .08em; }
.recent-item a { color: var(--indigo); font-weight: 700; text-decoration: none; }
.empty { color: var(--muted); font-size: 13px; padding: 14px 0; }
.history-list { margin-top: 12px; display: grid; gap: 7px; }
.history-row { display: grid; grid-template-columns: 1.2fr .75fr .75fr .65fr .7fr auto; align-items: center; gap: 10px; min-height: 54px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 11px; }
.history-row > span { min-width: 0; color: var(--muted); font-size: 11.5px; }
.history-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 12.5px; }
.history-status { padding: 4px 7px; border-radius: 999px; background: #ececf6; font-size: 10px; font-weight: 800; text-align: center; text-transform: capitalize; }
.history-status.selesai { background: #e2f6ee; color: var(--ok); }
.history-status.aktif { background: #eeeeff; color: var(--indigo); }
.history-status.dihentikan { background: #fff0f3; color: var(--err); text-transform: none; }

/* Keterangan di bawah sebuah field. Jangan diberi margin atas negatif: label di
   sini flex-column dengan gap sendiri, jadi menariknya ke atas membuatnya
   menabrak select di atasnya. */
.field-note { margin: 8px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.field-note + label { margin-top: 13px; }
.activation-card { margin-top: 18px; scroll-margin-top: 12px; }
.activation-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 16px; }
.activation-grid h3 { margin: 0; font-size: 14px; }
.device-form { display: grid; grid-template-columns: 130px 1fr 1fr auto; gap: 7px; }
.device-form .primary { width: auto; margin: 0; padding: 10px 14px; }
.detected-devices { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.detected-device { border: 1px dashed #cfd1e7; border-radius: 9px; background: #fff; color: var(--indigo); padding: 7px 9px; font: inherit; font-size: 10.5px; cursor: pointer; }
.device-list { display: grid; gap: 7px; margin-top: 11px; }
.device-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fafaff; }
.device-row span { min-width: 0; }
.device-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.device-row small { display: block; color: var(--muted); font-size: 10px; }
.device-row button { min-width: 76px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--indigo); font: inherit; font-size: 10.5px; font-weight: 750; cursor: pointer; }
.device-row button.danger { color: var(--danger); }
.admin-shell { width: min(1180px, calc(100% - 32px)); }
.admin-hero { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 28px; margin-bottom: 18px; }
.admin-hero h1 { font-size: 30px; }
.admin-hero .lead { margin-bottom: 0; }
.admin-stats { display: grid; grid-template-columns: repeat(3, minmax(105px, 1fr)); gap: 8px; }
.admin-stats div { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fafaff; }
.admin-stats strong { display: block; color: var(--indigo); font-size: 24px; }
.admin-stats span { display: block; color: var(--muted); font-size: 10.5px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.admin-list { max-height: 55vh; overflow-y: auto; overscroll-behavior: none; }
.admin-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.error { display: none; color: var(--danger); background: #fff0f3; border: 1px solid #f4c7d0; border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: 13px; }
.error.show { display: block; }

.eyebrow { display: block; margin-bottom: 5px; color: var(--indigo); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.wizard-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 22px; }
.wizard-progress span { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.wizard-progress b { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: #ececf6; color: var(--muted); }
.wizard-progress span.active { color: var(--indigo); }
.wizard-progress span.active b { background: var(--indigo); color: #fff; }
.wizard-step[hidden] { display: none; }
.wizard-step h2 { margin-bottom: 17px; font-size: 19px; }
/* Jarak antar-field. Bukan hanya label + label: begitu sepasang field dibungkus
   .form-grid (nama + usia), label sesudahnya kehilangan jaraknya dan menempel
   ke grid. */
.wizard-step > label + label,
.wizard-step > .form-grid + label,
.wizard-step > label + .form-grid { margin-top: 13px; }
.wizard-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.wizard-actions .primary { width: auto; min-width: 190px; margin-top: 0; }
.wizard-actions .link-button { border: 0; }
.session-review { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.session-review div { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #fafaff; }
.session-review span { display: block; color: var(--muted); font-size: 11px; }
.session-review strong { display: block; margin-top: 3px; font-size: 14px; }

.auth-page { position: fixed; inset: 0; width: 100%; height: 100dvh; min-height: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); overflow: hidden; overscroll-behavior: none; }
.auth-card { width: min(430px, 100%); max-height: calc(100dvh - 32px); overflow: hidden; }
.auth-card .brand { margin-bottom: 30px; }
.auth-card h1 { font-size: 28px; }
.auth-card form { margin-top: 22px; display: grid; gap: 14px; }
.auth-note { margin-top: 18px; color: var(--muted); font-size: 12.5px; }
.auth-page .auth-card .brand { margin-bottom: 18px; }
.auth-page .auth-card h1 { font-size: 25px; }
.auth-page .auth-card .lead { margin: 7px 0 14px; }
.auth-page .auth-card form { margin-top: 0; gap: 10px; }
.auth-page .auth-card .primary { margin-top: 4px; padding: 12px 16px; }
.auth-page .auth-card .headset-link { margin-top: 9px; padding: 10px 12px; }
.auth-page .auth-card > .install-button { margin-top: 8px; padding: 10px 12px; }
.auth-page .auth-note { margin: 9px 0 0; font-size: 11px; line-height: 1.4; }
.headset-link { display: block; margin-top: 12px; padding: 12px 14px; border: 1px solid #d9dafe; border-radius: 11px; background: #f3f3ff; color: var(--indigo); font-weight: 750; text-align: center; text-decoration: none; }
.headset-link:hover { background: #eaeaFF; }
.token-input { text-transform: uppercase; letter-spacing: .22em; text-align: center; font-size: 24px; font-weight: 800; }
.join-card { width: min(500px, 100%); text-align: center; }
.join-card .brand { justify-content: center; }
.join-card label { text-align: left; margin-top: 24px; }
.join-install { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.join-install .install-button { width: 100%; min-height: 46px; }
.join-install p { margin: 7px 8px 0; color: var(--muted); font-size: 11.5px; line-height: 1.4; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; align-items: stretch; }
  .link-button, .logout { min-height: 44px; }
  input, select { font-size: 16px; }
  .wizard-progress span { font-size: 0; }
  .wizard-progress b { font-size: 12px; }
  .session-review { grid-template-columns: 1fr; }
  .quest-grid, .activation-grid { grid-template-columns: 1fr; }
  .admin-hero, .admin-grid { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
  .device-form { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr 1fr; }
  .history-row > :last-child { justify-self: end; }
}
