:root {
  --white: #ffffff;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e8eaed;
  --border-strong: #d1d5db;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --purple-50: #eef6ec;
  --purple-100: #d7ead1;
  --purple-500: #5a9a4a;
  --purple-600: #3a7a30;
  --purple-700: #2a5c23;
  --teal-50: #edfaf4;
  --teal-100: #d1f5e5;
  --teal-500: #1D9E75;
  --teal-700: #085041;
  --amber-50: #fef9ec;
  --amber-100: #fdedc2;
  --amber-500: #d48a0c;
  --amber-700: #633806;
  --red-50: #fef2f2;
  --red-500: #ef4444;
  --red-700: #b91c1c;
  --blue-50: #eff6ff;
  --blue-500: #3b82f6;
  --blue-700: #1d4ed8;
  --green-50: #f0fdf4;
  --green-500: #22c55e;
  --green-700: #15803d;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text-primary); min-height: 100vh; font-size: 14px; line-height: 1.6; }

/* TOPBAR */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm); }
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-logo { width: 32px; height: 32px; background: var(--purple-600); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.topbar-logo svg { width: 18px; height: 18px; fill: white; }
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.topbar-sub { font-size: 12px; color: var(--text-secondary); }

/* PROGRESS STEPS */
.progress-wrap { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 24px; overflow-x: auto; }
.progress-steps { display: flex; align-items: center; gap: 0; min-width: max-content; }
.step { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); transition: background .15s; }
.step:hover { background: var(--bg); }
.step-dot { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; transition: all .2s; }
.step-dot.done { background: var(--teal-500); color: white; }
.step-dot.active { background: var(--purple-600); color: white; box-shadow: 0 0 0 3px var(--purple-100); }
.step-dot.idle { background: var(--bg); color: var(--text-muted); border: 1.5px solid var(--border-strong); }
.step-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.step.active .step-label { color: var(--purple-700); }
.step.done .step-label { color: var(--teal-700); }
.step-line { width: 28px; height: 1.5px; background: var(--border-strong); flex-shrink: 0; margin: 0 2px; }
.step-line.done { background: var(--teal-500); }

/* LAYOUT & CARDS */
.page { display: block; padding: 28px 24px; max-width: 1100px; margin: 0 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); }
.card-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 12px; }

/* PAGE HEADER */
.page-header { margin-bottom: 22px; }
.page-eyebrow { font-size: 12px; font-weight: 600; color: var(--purple-600); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.page-desc { font-size: 14px; color: var(--text-secondary); max-width: 600px; }
.section-gap { margin-top: 18px; }

/* NAV BUTTONS */
.nav-row { display: flex; gap: 10px; margin-top: 24px; align-items: center; }
.btn { padding: 9px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 7px; transition: all .15s; border: none; }
.btn-primary { background: var(--purple-600); color: white; }
.btn-primary:hover { background: var(--purple-700); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-success { background: var(--teal-500); color: white; }
.btn-success:hover { background: var(--teal-700); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

/* NOTICE */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin-top: 12px; }
.notice svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; margin-top: 1px; }
.notice-text { font-size: 13px; line-height: 1.5; }
.notice.info { background: var(--purple-50); color: var(--purple-700); border: 1px solid var(--purple-100); }
.notice.warning { background: var(--amber-50); color: var(--amber-700); border: 1px solid var(--amber-100); }
.notice.success { background: var(--teal-50); color: var(--teal-700); border: 1px solid var(--teal-100); }

/* TAGS & SELECT */
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 99px; }
.select-wrap { position: relative; }
.select-wrap select { width: 100%; padding: 9px 32px 9px 12px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-primary); font-size: 13px; appearance: none; cursor: pointer; }
.select-wrap::after { content: '▾'; position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

/* ANIMATIONS */
@keyframes spin { to { transform:rotate(360deg); } }
@keyframes slideIn { from { opacity:0;transform:translateY(8px); } to { opacity:1;transform:translateY(0); } }

/* RESPONSIVE */
@media(max-width:768px){
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .page { padding: 18px 14px; }
  .fmap-wrap { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 14px; }
  .progress-wrap { padding: 10px 14px; }
}

/* =========================================
   AREA UNGGAH (UPLOAD ZONE)
   ========================================= */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--purple-500);
  background: var(--purple-50);
}

.upload-zone.has-file {
  border-style: solid;
  border-color: var(--teal-500);
  background: var(--teal-50);
}

.upload-icon {
  width: 48px;
  height: 48px;
  background: var(--purple-100);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.upload-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--purple-600);
  fill: none;
  stroke-width: 1.8;
}

.upload-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.upload-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-link {
  color: var(--purple-600);
  text-decoration: underline;
  cursor: pointer;
}

/* =========================================
   PRATINJAU GAMBAR (IMAGE PREVIEW)
   ========================================= */
.img-preview {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--teal-50);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.img-preview svg {
  width: 64px;
  height: 64px;
  opacity: 0.25;
}

.preview-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--teal-500);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

/* =========================================
   KOTAK STATISTIK (STAT BOXES)
   ========================================= */
.stat-box {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* =========================================
   PROGRESS BAR PRA-PROSES
   ========================================= */
.pb-wrap {
  margin-top: 8px;
}

.pb-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.pb-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.pb-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}
/* ============================================================
   camera modal — akses webcam langsung untuk "Ambil Foto Langsung"
   ============================================================ */
.camera-modal {
  position: fixed; inset: 0; background: rgba(17,24,39,.72);
  z-index: 999; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.camera-modal-box {
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 480px;
  overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.camera-modal-header {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
  font-weight: 600; font-size: 14px; color: var(--text-primary); border-bottom: 1px solid var(--border);
}
.camera-close-btn {
  background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer;
  color: var(--text-secondary); padding: 2px 6px;
}
.camera-close-btn:hover { color: var(--text-primary); }
.camera-video-wrap {
  position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; overflow: hidden;
}
.camera-video-wrap video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scaleX(-1); /* efek cermin untuk kamera depan, terasa lebih natural */
}
.camera-video-wrap.rear video { transform: none; } /* kamera belakang: tidak perlu dicerminkan */
.camera-error {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; text-align: center; padding: 24px; background: rgba(0,0,0,.5);
}
.camera-modal-actions {
  display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border);
}
.camera-modal-actions .btn-primary { flex: 1; justify-content: center; }

/* ============================================================
   BERANDA — halaman utama
   ============================================================ */
:root{
    --leaf-50:#eef6ec; --leaf-100:#d7ead1; --leaf-400:#5a9a4a; --leaf-600:#3a7a30; --leaf-800:#1f4a1a;
    --soil-500:#a8763f; --soil-700:#6b4a26;
  }
  *{ box-sizing:border-box; }
  body{ background:linear-gradient(180deg,#fbfbf7 0%, var(--bg) 340px); }
  .font-display{ font-family:'Fraunces', serif; }

  /* ---------- topbar ---------- */
  .topbar{ backdrop-filter:blur(6px); background:rgba(255,255,255,.85); }

  /* ---------- hero ---------- */
  .hero-wrap{ max-width:1140px; margin:0 auto; padding:64px 24px 20px; }
  .hero-grid{ display:grid; grid-template-columns:1.1fr 1fr; gap:48px; align-items:center; }
  .eyebrow{
    display:inline-flex; align-items:center; gap:8px; font-size:12px; font-weight:600;
    letter-spacing:.06em; color:var(--leaf-600); background:var(--leaf-50);
    border:1px solid var(--leaf-100); padding:6px 14px; border-radius:999px; margin-bottom:20px;
    opacity:0; animation:riseIn .6s .05s ease forwards;
  }
  .eyebrow-dot{ width:6px;height:6px;border-radius:50%;background:var(--leaf-600); animation:pulseDot 2s ease infinite; }
  @keyframes pulseDot{ 0%,100%{opacity:1} 50%{opacity:.3} }

  .hero-title{
    font-family:'Fraunces', serif; font-weight:600; font-size:clamp(30px,4vw,44px);
    line-height:1.15; color:var(--text-primary); margin-bottom:18px; letter-spacing:-.01em;
    opacity:0; animation:riseIn .6s .15s ease forwards;
  }
  .hero-title em{ font-style:italic; color:var(--leaf-600); }
  .hero-desc{
    font-size:15.5px; color:var(--text-secondary); line-height:1.75; max-width:480px; margin-bottom:32px;
    opacity:0; animation:riseIn .6s .25s ease forwards;
  }
  @keyframes riseIn{ from{opacity:0; transform:translateY(14px);} to{opacity:1; transform:translateY(0);} }

  .hero-actions{ display:flex; gap:12px; flex-wrap:wrap; opacity:0; animation:riseIn .6s .35s ease forwards; }
  .btn-hero{
    padding:12px 22px; border-radius:var(--radius); font-size:14px; font-weight:600;
    display:inline-flex; align-items:center; gap:8px; text-decoration:none; transition:transform .15s, box-shadow .15s;
  }
  .btn-hero.primary{ background:var(--leaf-600); color:#fff; box-shadow:0 4px 14px rgba(58,122,48,.28); }
  .btn-hero.primary:hover{ transform:translateY(-2px); box-shadow:0 8px 20px rgba(58,122,48,.35); }
  .btn-hero.ghost{ background:#fff; color:var(--text-primary); border:1px solid var(--border-strong); }
  .btn-hero.ghost:hover{ transform:translateY(-2px); border-color:var(--leaf-400); }
  .btn-hero svg{ width:15px;height:15px; stroke:currentColor; fill:none; stroke-width:2; }

  /* ---------- signature: scanning leaf ---------- */
  .scan-card{
    background:#fff; border:1px solid var(--border); border-radius:20px; padding:28px;
    box-shadow:0 20px 50px -20px rgba(31,74,26,.25); position:relative;
    opacity:0; animation:riseIn .7s .2s ease forwards;
  }
  .scan-caption{ font-size:11px; font-weight:600; letter-spacing:.05em; color:var(--text-muted); text-transform:uppercase; margin-bottom:10px; }
  .scan-stage{ position:relative; width:100%; aspect-ratio:1/1; border-radius:14px; overflow:hidden; background:var(--leaf-50); }
  #kernelBox{
    position:absolute; width:22.2%; height:22.2%; border:2px solid var(--purple-600);
    background:rgba(84,74,183,.12); border-radius:4px; pointer-events:none;
    box-shadow:0 0 0 3px rgba(84,74,183,.1);
    animation:scanMove 6s linear infinite;
  }
  @keyframes scanMove{
    0%   { top:4%;  left:4%;  }
    12%  { top:4%;  left:37%; }
    24%  { top:4%;  left:70%; }
    36%  { top:37%; left:70%; }
    48%  { top:37%; left:37%; }
    60%  { top:37%; left:4%;  }
    72%  { top:70%; left:4%;  }
    84%  { top:70%; left:37%; }
    96%  { top:70%; left:70%; }
    100% { top:70%; left:70%; }
  }
  .scan-readout{
    display:flex; justify-content:space-between; align-items:center; margin-top:16px;
    padding-top:14px; border-top:1px dashed var(--border);
  }
  .scan-readout-label{ font-size:12px; color:var(--text-secondary); }
  .scan-readout-value{ font-size:13px; font-weight:700; color:var(--purple-700); font-variant-numeric:tabular-nums; }

  @media (prefers-reduced-motion: reduce){
    .eyebrow,.hero-title,.hero-desc,.hero-actions,.scan-card{ animation:none; opacity:1; }
    #kernelBox{ animation:none; top:37%; left:37%; }
  }

  /* ---------- mode cards ---------- */
  .mode-section{ max-width:1140px; margin:56px auto 0; padding:0 24px; }
  .mode-heading{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:20px; }
  .mode-heading h2{ font-family:'Fraunces', serif; font-weight:600; font-size:20px; }
  .mode-heading span{ font-size:13px; color:var(--text-muted); }
  .mode-grid2{ display:grid; grid-template-columns:1fr 1fr; gap:20px; }
  .mode-card{
    position:relative; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg);
    padding:26px; text-decoration:none; color:inherit; overflow:hidden;
    transition:transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  }
  .mode-card:hover{ transform:translateY(-4px); box-shadow:0 16px 32px -16px rgba(0,0,0,.18); border-color:var(--border-strong); }
  .mode-card::after{
    content:''; position:absolute; inset:0; opacity:0; transition:opacity .25s;
    background:radial-gradient(160px circle at var(--mx,50%) var(--my,50%), rgba(0,0,0,.035), transparent 70%);
  }
  .mode-card:hover::after{ opacity:1; }
  .mode-icon{ width:42px; height:42px; border-radius:11px; display:flex; align-items:center; justify-content:center; margin-bottom:16px; }
  .mode-icon svg{ width:20px;height:20px; stroke:currentColor; fill:none; stroke-width:2; }
  .mode-icon.simple{ background:var(--teal-50); color:var(--teal-700); }
  .mode-icon.detail{ background:var(--purple-50); color:var(--purple-700); }
  .mode-title{ font-size:16.5px; font-weight:700; margin-bottom:6px; }
  .mode-desc{ font-size:13.5px; color:var(--text-secondary); line-height:1.65; margin-bottom:18px; }
  .mode-cta{ font-size:13px; font-weight:600; display:inline-flex; align-items:center; gap:5px; }
  .mode-cta.simple{ color:var(--teal-700); }
  .mode-cta.detail{ color:var(--purple-700); }
  .mode-card:hover .mode-cta svg{ transform:translateX(3px); }
  .mode-cta svg{ width:14px;height:14px; transition:transform .2s; stroke:currentColor; fill:none; stroke-width:2.4; }

  /* ---------- stats ---------- */
  .stats-row{ max-width:1140px; margin:48px auto 64px; padding:0 24px; display:grid; grid-template-columns:repeat(4,1fr); gap:1px; background:var(--border); border:1px solid var(--border); border-radius:var(--radius-lg); overflow:hidden; }
  .stat-item{ background:#fff; padding:22px 16px; text-align:center; }
  .stat-num{ font-family:'Fraunces', serif; font-size:26px; font-weight:600; color:var(--leaf-600); font-variant-numeric:tabular-nums; }
  .stat-label{ font-size:12px; color:var(--text-secondary); margin-top:4px; }

  @media (max-width:820px){
    .hero-grid{ grid-template-columns:1fr; }
    .mode-grid2{ grid-template-columns:1fr; }
    .stats-row{ grid-template-columns:repeat(2,1fr); }
  }
