:root {
  --navy: #0f2559;
  --navy-700: #16327a;
  --blue: #2f5bea;
  --blue-soft: #e9efff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e3e8f2;
  --bg: #f4f6fb;
  --card: #ffffff;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 37, 89, 0.08);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px); background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; }
.brand > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lang-picker { display: inline-flex; align-items: center; gap: 6px; color: var(--navy); border: 1.5px solid #d3dae8; border-radius: 6px; padding: 4px 6px 4px 8px; background: #fff; }
/* A select is sized by its WIDEST option, so without this the box stays as wide as
   "Bahasa Indonesia" even when "ไทย" is chosen. field-sizing shrinks it to whatever
   is actually selected; app.js measures and sets a width where that isn't supported. */
.lang-picker select { font: inherit; font-size: 13px; font-weight: 600; color: var(--navy); border: 0; background: transparent; padding: 2px 2px; max-width: 150px; cursor: pointer; field-sizing: content; }
.lang-picker select:focus { outline: none; }
.lang-picker:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.15); }
/* Cap as a share of the viewport rather than a fixed 110px, which truncated the
   longer names. The brand text ellipsises, so the bar absorbs the extra width. */
@media (max-width: 480px) { .lang-picker select { max-width: 44vw; font-size: 12.5px; } .topbar-right { gap: 6px; } }
@media (max-width: 480px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand { font-size: 15px; }
}

/* ---------- Layout ---------- */
.layout {
  flex: 1; width: min(1100px, 100%); margin: 0 auto; padding: clamp(16px, 3vw, 32px);
  display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.sidebar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); position: sticky; top: 76px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sidebar-title { margin: 0; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.close-btn { display: none; background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

/* Hamburger (mobile only) */
.menu-btn { display: none; background: none; border: 0; padding: 6px; margin-right: 4px; cursor: pointer; flex-direction: column; gap: 4px; }
.menu-btn span { display: block; width: 20px; height: 2px; background: var(--navy); border-radius: 2px; transition: transform .2s, opacity .2s; }
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.drawer-overlay { position: fixed; inset: 0; background: rgba(15, 37, 89, 0.45); z-index: 20; backdrop-filter: blur(2px); }

@media (max-width: 860px) {
  .menu-btn { display: flex; }
  .close-btn { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(320px, 85vw); z-index: 30; border-radius: 0;
    transform: translateX(-100%); transition: transform .25s ease; overflow-y: auto;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }
  .sidebar.is-open { transform: translateX(0); }
  body.drawer-open { overflow: hidden; }
}
.step { display: flex; align-items: flex-start; gap: 12px; padding: 10px 10px; border-radius: 10px; color: var(--ink); font-size: 15px; cursor: default; transition: background .15s; }
.step.is-done { cursor: pointer; }
.step.is-done:hover { background: var(--bg); }
.step.is-current { background: var(--blue-soft); color: var(--navy); font-weight: 600; }
.step-dot {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #c7cfe0; background: #fff; margin-top: 1px;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
}
.step.is-current .step-dot { border-color: var(--blue); }
.step.is-done .step-dot { background: var(--green); border-color: var(--green); }
.step.is-done .step-dot::after { content: '✓'; }
.step.is-locked { color: var(--muted); }
.step.is-locked .step-dot { background: #9ca3af; border-color: #9ca3af; }
.step.is-locked .step-dot::after { content: '–'; }
.step-label small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.sidebar-note { margin-top: 18px; padding: 12px; border-radius: 10px; background: var(--bg); font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.sidebar-note strong { color: var(--navy); }

.content { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.progress { height: 4px; background: var(--line); }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--navy)); transition: width .3s ease; }
form { padding: clamp(18px, 3vw, 36px); }

/* ---------- Panels & fields ---------- */
.panel { border: 0; padding: 0; margin: 0; min-width: 0; }
.panel-head { margin-bottom: 22px; }
.panel-head h1 { margin: 0 0 6px; font-size: clamp(20px, 2.4vw, 26px); color: var(--navy); letter-spacing: -0.02em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.sub { font-size: 14px; color: var(--navy); margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: 0.06em; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.span-2 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field-label { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.field b, .field-label b { color: var(--red); font-weight: 600; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select {
  font: inherit; font-size: 15px; padding: 11px 13px; border: 1.5px solid #d3dae8; border-radius: 10px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s; width: 100%; min-width: 0;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(47, 91, 234, 0.15); }
.field.has-error input, .field.has-error select { border-color: var(--red); }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; font-style: normal; line-height: 1.5; }
.error { color: var(--red); font-size: 12.5px; min-height: 0; }
.error:empty { display: none; }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1.5px solid #d3dae8; border-radius: 10px; cursor: pointer; font-size: 14.5px; }
.radio:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); color: var(--navy); font-weight: 600; }
.radio input { accent-color: var(--blue); }
.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; font-size: 14px; line-height: 1.5; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--blue); flex: none; }

.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Uploads ---------- */
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 24px; }
@media (max-width: 640px) { .upload-grid { grid-template-columns: 1fr; } }
.uploader { display: flex; flex-direction: column; gap: 8px; }
.dropzone {
  position: relative; display: grid; place-items: center; min-height: 170px; border: 2px dashed #c7cfe0; border-radius: 12px;
  background: #fafbfe; cursor: pointer; overflow: hidden; transition: border-color .15s, background .15s;
}
.dropzone { cursor: default; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dz-empty { text-align: center; padding: 16px; color: var(--muted); font-size: 13px; display: grid; gap: 10px; justify-items: center; }
.dz-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.dz-actions .btn { padding: 10px 16px; font-size: 14px; }

/* Submitting overlay */
.submit-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(244, 246, 251, .96); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 24px; }
.submit-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 420px; }
.submit-box h2 { margin: 8px 0 0; font-size: clamp(18px, 3vw, 22px); color: var(--navy); }
.submit-box p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.big-spinner { width: 56px; height: 56px; border: 4px solid var(--blue-soft); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.lock-line { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--green); }

/* Camera modal */
.cam-modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .85); display: grid; place-items: center; padding: 16px; }
.cam-box { width: min(720px, 100%); background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cam-box video { width: 100%; max-height: 60vh; background: #0f172a; border-radius: 10px; object-fit: contain; }
.dz-preview { width: 100%; max-height: 260px; object-fit: contain; display: block; background: #0f172a; }
/* PDFs have no thumbnail, so a document slot shows a named file tile instead. */
.dz-doc { display: flex; align-items: center; gap: 10px; padding: 22px 16px; background: #f4f6fb; }
.dz-doc-badge { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: #fff; background: var(--navy); border-radius: 5px; padding: 4px 7px; }
.dz-doc-name { font-size: 13.5px; color: var(--navy); word-break: break-all; }
.uploader.has-file .dz-empty { display: none; }
.uploader.has-error .dropzone { border-color: var(--red); }
.link-btn { background: none; border: 0; color: var(--blue); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; align-self: flex-start; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Video ---------- */
.video-block { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }
.affidavit {
  margin: 0; padding: 16px 18px; border-left: 4px solid var(--blue); background: var(--blue-soft); border-radius: 0 10px 10px 0;
  font-size: 15px; line-height: 1.7; color: var(--navy);
}
.affidavit mark { background: #fff; padding: 1px 6px; border-radius: 6px; font-weight: 600; color: var(--navy); }
.recorder { display: flex; flex-direction: column; gap: 10px; }
.recorder video { width: 100%; max-height: 360px; background: #0f172a; border-radius: 12px; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.rec-timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--red); }
.rec-timer::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
#videoUpload { font: inherit; font-size: 13px; }

/* ---------- Signature ---------- */
.sig-wrap { position: relative; }
#sigPad { width: 100%; height: auto; aspect-ratio: 10 / 3; border: 1.5px solid #d3dae8; border-radius: 10px; background: #fff; touch-action: none; display: block; }
.sig-wrap .link-btn { position: absolute; right: 12px; top: 10px; }
.review { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 20px; margin-bottom: 22px; padding: 16px; background: var(--bg); border-radius: 12px; font-size: 13.5px; }
.review div { display: flex; flex-direction: column; gap: 2px; }
.review small { color: var(--muted); }
.review strong { font-weight: 600; color: var(--ink); word-break: break-word; }

/* ---------- Buttons ---------- */
.actions { display: flex; align-items: center; gap: 12px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.btn {
  font: inherit; font-weight: 600; font-size: 14.5px; padding: 12px 22px; border-radius: 10px; border: 1.5px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 6px 16px rgba(15, 37, 89, 0.25); }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }
.btn-secondary { background: #fff; color: var(--navy); border-color: #d3dae8; }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--red); color: #fff; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; flex: none; }
.btn-secondary .spinner { border-color: rgba(15, 37, 89, .2); border-top-color: var(--navy); }
.btn[aria-busy="true"] { opacity: .85; cursor: progress; justify-content: center; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-alert { margin-top: 18px; padding: 12px 14px; border-radius: 10px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; font-size: 14px; }
.form-alert.is-info { background: var(--blue-soft); border-color: #c7d5ff; color: var(--navy); }

/* ---------- Success ---------- */
.success { padding: clamp(32px, 6vw, 64px) clamp(18px, 4vw, 48px); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.success-icon { width: 64px; height: 64px; border-radius: 50%; background: #ecfdf3; color: var(--green); display: grid; place-items: center; font-size: 30px; font-weight: 700; border: 2px solid #bbf7d0; }
.success h1 { margin: 6px 0 0; color: var(--navy); }
.success p { margin: 0; color: var(--muted); max-width: 46ch; line-height: 1.6; }
.ref { margin-top: 10px; padding: 14px 24px; background: var(--blue-soft); border-radius: 12px; display: flex; flex-direction: column; gap: 2px; }
.ref small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.ref strong { font-size: 24px; color: var(--navy); letter-spacing: .05em; }

.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 18px; }
.footer p { margin: 0; }
/* Plain green text + lock, no chrome — inline-flex so the icon and label sit on
   one baseline while text-align on .footer keeps the pair centred. */
.secure-badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--green);
  background: none; border: 0; padding: 0;
}
.footer .secure-badge { margin-bottom: 6px; }
