:root {
  --bg: #14161a; --panel: #1d2026; --panel2: #232831; --line: #2c3139; --text: #e8eaed; --muted: #9aa3ad;
  --accent: #4cc38a; --accent-ink: #07140d; --bad: #e5604d; --warn: #e0a93b; --info: #5aa9e6;
  --radius: 12px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7; --panel: #ffffff; --panel2: #f0f2f5; --line: #d9dde3; --text: #1b1f24; --muted: #5b6570;
    --accent: #1f8f5f; --accent-ink: #ffffff; --bad: #c0392b; --warn: #a06a00; --info: #1f6fb2;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 8px; } h3 { font-size: 15px; margin: 0 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.head-row { margin-bottom: 14px; } .mt { margin-top: 14px; }
a { color: var(--accent); }

/* ---- kerangka ---- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; color: var(--text); }
.brand img { width: 28px; height: 28px; } .brand span { white-space: nowrap; }
.spacer { flex: 1; }
.who { text-align: right; line-height: 1.2; }
.who b { display: block; font-size: 14px; } .who span { font-size: 12px; color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.narrow { max-width: 440px; margin: 0 auto; padding: 32px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.foot { margin-top: 28px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---- form dan tombol ---- */
label { display: block; margin: 0 0 14px; font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input[type=search], input[type=date], input[type=file], select {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; min-height: 48px;
}
input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.code-input { text-align: center; font-size: 28px; letter-spacing: 0.35em; font-variant-numeric: tabular-nums; }
button, .btn { font: inherit; padding: 11px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); min-height: 48px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 40px; padding: 7px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 160px; }

.alert { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); border-left-width: 4px; background: var(--panel2); font-size: 14px; margin: 0 0 14px; }
.alert.err { border-left-color: var(--bad); } .alert.warn { border-left-color: var(--warn); } .alert.ok { border-left-color: var(--accent); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--accent); border-color: var(--accent); } .badge.warn { color: var(--warn); border-color: var(--warn); } .badge.bad { color: var(--bad); border-color: var(--bad); }

/* ---- dashboard ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 16px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 150px; padding: 18px; text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); text-decoration: none; }
.tile:hover:not([aria-disabled="true"]) { border-color: var(--accent); }
.tile .ico { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--panel2); color: var(--accent); }
.tile .ico svg { width: 26px; height: 26px; }
.tile h2 { margin: 0; } .tile p { margin: 0; font-size: 14px; color: var(--muted); }
.tile[aria-disabled="true"] { opacity: .6; cursor: default; }
.tile[aria-disabled="true"] .ico { color: var(--muted); }
.tile .badge { position: absolute; top: 14px; right: 14px; }
.tile-empty { border-style: dashed; justify-content: center; align-items: center; text-align: center; color: var(--muted); }

/* ---- admin ---- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.tabs button { min-height: 44px; }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.item .meta { min-width: 200px; flex: 1; }
.item .meta b { display: block; } .item .meta span { font-size: 13px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.tablewrap { overflow-x: auto; }

/* ---- dialog dan toast ---- */
dialog { max-width: min(480px, calc(100vw - 24px)); width: 100%; padding: 20px; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.toasts { position: fixed; left: 12px; right: 12px; bottom: 16px; z-index: 50; display: grid; gap: 8px; pointer-events: none; justify-items: center; }
.toast { pointer-events: auto; max-width: 480px; width: 100%; padding: 12px 14px; background: #0c0e11; color: #e8eaed; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; font-size: 14px; }
.toast.err { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 10px; margin: 10px auto; width: fit-content; }
.qr svg { display: block; width: 220px; height: 220px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.checks label { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; color: var(--text); }
.checks input { width: 22px; height: 22px; }

@media (max-width: 560px) {
  .wrap { padding: 14px 12px 32px; } .who span { display: none; }
  .tiles { grid-template-columns: 1fr; } .tile { min-height: 0; flex-direction: row; align-items: center; }
  .tile .badge { position: static; margin-left: auto; align-self: flex-start; }
  .item { flex-direction: column; align-items: stretch; } .item .row > * { flex: 1; }
}
@media (max-width: 400px) { .who { display: none; } .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- validator ---- */
.cam { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; max-height: 46vh; width: 100%; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .alert { position: absolute; left: 8px; right: 8px; top: 8px; margin: 0; }
.flash { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px; font-weight: 600; text-align: center; color: #fff; background: rgba(0, 0, 0, .75); }
.flash.ok { background: rgba(31, 143, 95, .92); } .flash.bad { background: rgba(192, 57, 43, .94); } .flash.warn { background: rgba(160, 106, 0, .94); }
.line { padding: 10px 12px; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; }
.line.done { border-left-color: var(--accent); }
.line p { margin: 2px 0; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.comps { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; }
.comps li { display: flex; justify-content: space-between; padding: 2px 0; color: var(--muted); } .comps li.done { color: var(--accent); }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.done-card { text-align: center; }
@media (min-width: 900px) { .cam { max-width: 640px; } }

details summary { cursor: pointer; color: var(--muted); }
label .row { margin-top: 4px; }
