/* ============================================================
   HARDIAN — Design System
   Gaya: Apple-modern, clean, minimal. Font: Plus Jakarta Sans
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Palette */
  --bg:            #f5f5f7;
  --surface:       #ffffff;
  --surface-2:     #fbfbfd;
  --ink:           #1d1d1f;
  --ink-2:         #6e6e73;
  --ink-3:         #86868b;
  --line:          #e6e6eb;
  --line-2:        #d2d2d7;
  --accent:        #0071e3;
  --accent-hover:  #0077ed;
  --accent-press:  #006edb;
  --accent-soft:   #e8f1fd;
  --success:       #1db954;
  --success-soft:  #e6f8ed;
  --warning:       #ff9f0a;
  --warning-soft:  #fff4e0;
  --danger:        #ff3b30;
  --danger-soft:   #ffeceb;

  /* Progress colors */
  --p0:   #ff453a;
  --p50:  #ff9f0a;
  --p100: #34c759;

  /* Shape */
  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;
  --r-xl: 28px;

  /* Shadow */
  --sh-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --sh:    0 4px 16px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --sh-lg: 0 12px 40px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.05);

  --maxw: 480px;
  --ff: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ff);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 16px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ---------- Layout ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}
.wrap { padding: 16px; flex: 1; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.pad { padding: 20px; }
.stack > * + * { margin-top: 14px; }
.center { display: flex; align-items: center; justify-content: center; }
.muted { color: var(--ink-2); }
.tiny  { font-size: 13px; }
.mono  { font-variant-numeric: tabular-nums; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.topbar .brand .logo { width: 30px; height: 30px; }
.topbar .spacer { flex: 1; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; line-height: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer;
  background: var(--accent); color: #fff;
  padding: 14px 22px; border-radius: 980px;
  font-weight: 600; font-size: 16px; letter-spacing: -.01em;
  transition: transform .12s ease, background .15s ease, opacity .15s;
  width: 100%;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.97); background: var(--accent-press); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost:active { background: #f0f0f3; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #ff5147; }
.btn-success { background: var(--success); }
.btn-sm { padding: 9px 16px; font-size: 14px; width: auto; }
.btn-auto { width: auto; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.btn .spin { width: 18px; height: 18px; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--line);
  overflow: hidden;
}
.card .card-pad { padding: 20px; }
.card-title { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; color: var(--ink); }
.field label .req { color: var(--danger); }
.field .hint { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%; background: var(--surface-2);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 13px 14px; font-size: 16px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); background: #fff;
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.input[readonly] { background: #f0f0f3; color: var(--ink-2); cursor: not-allowed; }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
.locked-field {
  display: flex; align-items: center; gap: 8px;
  background: #f0f0f3; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 15px; color: var(--ink-2);
}
.locked-field svg { flex: 0 0 auto; color: var(--ink-3); }
.locked-field .val { color: var(--ink); font-weight: 600; }

/* Segmented progress chooser */
.seg { display: flex; gap: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1; text-align: center; cursor: pointer;
  border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  padding: 14px 6px; font-weight: 700; font-size: 15px; background: var(--surface-2);
  transition: all .15s; margin: 0; color: var(--ink-2);
}
.seg label small { display: block; font-weight: 500; font-size: 11px; margin-top: 2px; }
.seg input:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* Kalau opsi kebanyakan & kepotong, JS nambah class ini -> jadi bisa digeser (scroll) */
.seg.is-scroll {
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-bottom: 4px; margin-bottom: -4px;
}
.seg.is-scroll label {
  flex: 0 0 auto; scroll-snap-align: start;
  min-width: 84px; white-space: nowrap;
}

/* ---------- Badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 980px;
  letter-spacing: 0; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-0   { background: #ffe9e8; color: #d70015; }
.badge-0   .dot { background: var(--p0); }
.badge-50  { background: #fff2dd; color: #b76a00; }
.badge-50  .dot { background: var(--p50); }
.badge-100 { background: #e3f8e8; color: #1a7f37; }
.badge-100 .dot { background: var(--p100); }

/* ---------- Status indicators ---------- */
.status-list { display: flex; flex-direction: column; gap: 8px; }
.status-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); font-size: 14.5px; font-weight: 600;
}
.status-item .ic { width: 24px; height: 24px; flex: 0 0 auto; }
.status-item.ok   .ic { color: var(--success); }
.status-item.wait .ic { color: var(--ink-3); }
.status-item.err  .ic { color: var(--danger); }
.status-item.warn .ic { color: var(--warning); }
.status-item .lbl { flex: 1; }
.status-item.wait { color: var(--ink-2); }
.status-item.err  { background: var(--danger-soft); border-color: #ffd3d0; color: #c0271f; }
.status-item.warn { background: var(--warning-soft); border-color: #ffe2b3; color: #92590a; }

/* ---------- Camera ---------- */
.camera-screen {
  position: fixed; inset: 0; background: #000; z-index: 100;
  display: flex; flex-direction: column;
  max-width: var(--maxw); margin: 0 auto;
}
.camera-stage { position: relative; flex: 1; overflow: hidden; background: #000; }
.camera-stage video, .camera-stage canvas, .camera-stage img.shot {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.camera-stage video { transform: translateZ(0); }
.cam-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; padding: 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
}
.cam-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.45); backdrop-filter: blur(8px);
  color: #fff; font-size: 12px; font-weight: 600; padding: 7px 11px; border-radius: 980px;
}
.cam-pill svg { width: 14px; height: 14px; }
.cam-pill.ok  { color: #7dffa0; }
.cam-pill.bad { color: #ff8a82; }
.cam-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 5;
  padding: 24px 24px calc(28px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0,0,0,.6), transparent);
  display: flex; align-items: center; justify-content: center; gap: 28px;
}
.shutter {
  width: 76px; height: 76px; border-radius: 50%;
  background: #fff; border: 5px solid rgba(255,255,255,.55);
  cursor: pointer; transition: transform .1s;
  box-shadow: 0 0 0 3px rgba(0,0,0,.2);
}
.shutter:active { transform: scale(.9); }
.shutter:disabled { opacity: .4; }
.cam-side-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.18); backdrop-filter: blur(8px);
  border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cam-side-btn:active { background: rgba(255,255,255,.32); }
.cam-overlay-msg {
  position: absolute; inset: 0; z-index: 8;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px; gap: 16px; color: #fff;
  background: rgba(0,0,0,.85);
}
.cam-overlay-msg svg { width: 56px; height: 56px; color: rgba(255,255,255,.8); }
.cam-overlay-msg h2 { font-size: 20px; font-weight: 700; }
.cam-overlay-msg p { color: rgba(255,255,255,.7); max-width: 320px; line-height: 1.6; }

/* watermark preview badge on photo */
.shot-wrap { position: relative; }

/* ---------- Preview page ---------- */
.preview-photo {
  width: 100%; border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--sh); background: #000; aspect-ratio: 3/4; max-height: 52vh;
}
.preview-photo img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Toast ---------- */
.toast-host { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 200; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; background: var(--ink); color: #fff;
  padding: 13px 18px; border-radius: 980px; font-size: 14px; font-weight: 600;
  box-shadow: var(--sh-lg); display: inline-flex; align-items: center; gap: 9px;
  max-width: var(--maxw); animation: toastIn .3s ease;
}
.toast.err { background: var(--danger); }
.toast.ok  { background: var(--success); }
.toast svg { width: 18px; height: 18px; }
@keyframes toastIn { from { opacity:0; transform: translateY(16px); } to { opacity:1; transform:none; } }

/* ---------- Modal ---------- */
.modal-host { position: fixed; inset: 0; z-index: 150; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,.4); backdrop-filter: blur(4px); }
.modal-host.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 380px;
  box-shadow: var(--sh-lg); overflow: hidden; animation: toastIn .25s ease;
}
.modal .m-body { padding: 24px; text-align: center; }
.modal .m-icon { width: 56px; height: 56px; margin: 0 auto 14px; }
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.modal p { color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }
.modal .m-actions { display: flex; gap: 10px; padding: 0 20px 20px; }
.modal .m-actions .btn { flex: 1; }

/* ---------- Success screen ---------- */
.success-screen { text-align: center; padding: 48px 24px; }
.success-ic { width: 88px; height: 88px; margin: 0 auto 20px; color: var(--success); animation: pop .4s cubic-bezier(.2,.8,.3,1.2); }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { width: 72px; height: 72px; margin: 0 auto 18px; }
.login-head { text-align: center; margin-bottom: 28px; }
.login-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.login-head p { color: var(--ink-2); margin-top: 4px; font-size: 14.5px; }

/* ---------- History / list ---------- */
.doc-item { display: flex; gap: 12px; padding: 14px; align-items: center; }
.doc-item + .doc-item { border-top: 1px solid var(--line); }
.doc-thumb { width: 64px; height: 64px; border-radius: var(--r-sm); object-fit: cover; flex: 0 0 auto; background: #eee; }
.doc-meta { flex: 1; min-width: 0; }
.doc-meta h4 { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta .sub { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta .time { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 56px 24px; color: var(--ink-3); }
.empty svg { width: 56px; height: 56px; margin: 0 auto 14px; opacity: .5; }
.empty p { font-size: 14.5px; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 40;
  width: 100%; max-width: var(--maxw);
  display: flex; background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px; color: var(--ink-3); font-size: 11px; font-weight: 600;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a svg { width: 24px; height: 24px; }

/* ---------- Loader ---------- */
.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 0; gap: 14px; color: var(--ink-3); }
.page-loader .spin { width: 32px; height: 32px; color: var(--accent); }

/* ---------- Section title ---------- */
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 0 4px 10px; }

/* ---------- Detail rows ---------- */
.kv { display: flex; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; gap: 12px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-2); flex: 0 0 130px; font-weight: 600; }
.kv .v { flex: 1; font-weight: 500; word-break: break-word; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.full { width: 100%; }
.hidden { display: none !important; }
.text-c { text-align: center; }
.grow { flex: 1; }
.wrap-flex { flex-wrap: wrap; }

/* ---- Public report viewer ---- */
.report-body { background: var(--bg); }
.report-app { padding: 16px 16px 0; }
.report-head { display: flex; align-items: center; gap: 12px; padding: 8px 4px 18px; }
.report-logo { width: 44px; height: 44px; border-radius: 11px; }
.report-brand { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.report-subtitle { font-size: 13px; color: var(--ink-2); }
.report-meta { margin-bottom: 16px; }
.report-card { margin-bottom: 16px; }
.report-photo { width: 100%; border-radius: 14px; margin: 6px 0 14px; display: block; background: #eee; }
.report-card-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 10px; }

/* ============================================================
   REVISI: Toggle Rasio Foto
   ============================================================ */
.ratio-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  z-index: 20;
}
.ratio-btn {
  background: rgba(0,0,0,0.45);
  color: rgba(255,255,255,0.75);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  backdrop-filter: blur(6px);
}
.ratio-btn.active {
  background: #0a84ff;
  color: #fff;
  border-color: #0a84ff;
}

/* Stage aspect ratio */
.camera-stage {
  aspect-ratio: 4/3;
  transition: aspect-ratio .3s;
  overflow: hidden;
  position: relative;
  background: #000;
  width: 100%;
}
.camera-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   REVISI: Lokasi Tol — input KM
   ============================================================ */
#locDalamField input[type="number"] {
  -moz-appearance: textfield;
}
#locDalamField input[type="number"]::-webkit-outer-spin-button,
#locDalamField input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}