/* ============================================================
   app.css — TraffCo Web (survey simpang & ruas jalan)
   Palet "road worker": beton hangat, putih, oranye safety.
   ============================================================ */

/* ===== 1. TOKENS ===== */
:root{
  --bg:#F2F0EC;
  --surface:#FFFFFF;
  --border:#E0DDD7;
  --divider:#E8E5DF;
  --primary:#E8850C;
  --primary-dark:#C56A00;
  --primary-soft:rgba(232,133,12,.12);
  --text:#1A1A1A;
  --muted:#6E6E6E;
  --hint:#A0A0A0;
  --green:#1B5E20;
  --amber:#E65100;
  --red:#B71C1C;
  --blue:#1565C0;
  --shadow-sm:0 1px 2px rgba(26,26,26,.05), 0 1px 3px rgba(26,26,26,.06);
  --shadow-md:0 6px 20px rgba(26,26,26,.13);
  --radius:10px;
  --radius-lg:14px;
  --font:'Inter','Segoe UI',system-ui,-apple-system,Roboto,sans-serif;
  --mono:'Cascadia Mono','Consolas','SF Mono',ui-monospace,monospace;
}

*{ box-sizing:border-box; margin:0; padding:0; }
html{ -webkit-text-size-adjust:100%; }
body{
  font-family:var(--font);
  background:var(--bg);
  color:var(--text);
  min-height:100vh;
  -webkit-tap-highlight-color:transparent;
}
button{ font:inherit; color:inherit; background:none; border:none; cursor:pointer; }
input{ font:inherit; }
.hidden{ display:none !important; }
.ic{ width:20px; height:20px; flex:0 0 auto; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.ic-sm{ width:14px; height:14px; }
.ic-lg{ width:28px; height:28px; }

/* ===== 2. LAYOUT ===== */
.app{ max-width:760px; margin:0 auto; min-height:100dvh; }
.view{ display:none; flex-direction:column; min-height:100dvh; }
.view.active{ display:flex; }

/* ===== 3. LANDING ===== */
#viewLanding{
  max-width:560px; margin:0 auto; width:100%;
  padding:34px 20px calc(20px + env(safe-area-inset-bottom, 0px));
}
.landing-head{ text-align:center; margin-bottom:26px; }
.landing-logo{
  width:78px; height:78px; border-radius:20px;
  object-fit:cover; box-shadow:var(--shadow-sm);
}
.landing-head h1{ font-size:27px; font-weight:800; margin-top:10px; letter-spacing:-.02em; }
.landing-head p{ font-size:13px; color:var(--muted); margin-top:3px; }

.mode-card, .nav-card{
  display:flex; align-items:center; gap:13px;
  width:100%;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px;
  text-align:left;
  box-shadow:var(--shadow-sm);
  transition:transform .06s ease, border-color .15s ease;
}
.mode-card{ border-color:rgba(232,133,12,.28); margin-bottom:11px; }
.mode-card:active, .nav-card:active{ transform:scale(.99); }
.mode-card:hover, .nav-card:hover{ border-color:rgba(232,133,12,.5); }
.mode-icon, .nav-icon{
  display:flex; align-items:center; justify-content:center;
  width:48px; height:48px; border-radius:10px;
  background:var(--primary-soft); color:var(--primary);
  flex:0 0 auto;
}
.mode-icon.jalan{ background:rgba(197,106,0,.12); color:var(--primary-dark); }
.nav-icon{ background:var(--bg); color:var(--muted); }
.mode-text{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.mode-text strong{ font-size:15.5px; font-weight:750; }
.mode-text small{ font-size:11.5px; color:var(--muted); line-height:1.4; }
.chev{ width:16px; height:16px; color:var(--hint); transform:rotate(180deg); }

.nav-list{ display:flex; flex-direction:column; gap:8px; margin-top:20px; }
.nav-card{ padding:12px 14px; }
.nav-card .nav-icon{ width:42px; height:42px; }

.landing-foot{
  display:flex; align-items:center; justify-content:space-between;
  margin-top:22px;
  font-size:11px; color:var(--hint);
}
.conn{
  display:inline-flex; align-items:center; gap:5px;
  padding:4px 9px; border-radius:999px;
  background:var(--surface); border:1px solid var(--border);
  font-size:10.5px; font-weight:700; color:var(--muted);
}
.conn-dot{ width:7px; height:7px; border-radius:50%; background:#C0392B; }
.conn.online .conn-dot{ background:#2E7D32; }
.conn.syncing .conn-dot{ background:var(--primary); animation:pulse 1.1s infinite; }
.conn.offline .conn-dot{ background:#C0392B; }
@keyframes pulse{ 0%,100%{ opacity:1; } 50%{ opacity:.35; } }

/* ===== 4. HEADER SURVEY ===== */
.survey-head{
  position:sticky; top:0; z-index:30;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  padding-top:env(safe-area-inset-top, 0px);
  box-shadow:0 1px 3px rgba(26,26,26,.05);
}
.head-row{
  display:flex; align-items:center; gap:6px;
  padding:8px 8px 4px;
}
.icon-btn{
  display:inline-flex; align-items:center; justify-content:center;
  width:38px; height:38px; border-radius:9px;
  color:var(--muted);
  flex:0 0 auto;
  transition:background .15s ease, color .15s ease;
}
.icon-btn:hover{ background:var(--bg); color:var(--text); }
.icon-btn.danger:hover{ background:rgba(183,28,28,.08); color:var(--red); }
.head-title{ flex:1; min-width:0; display:flex; flex-direction:column; }
.head-title strong{ font-size:16px; font-weight:750; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.head-title small{ font-size:11px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.total-badge{
  min-width:44px; text-align:center;
  padding:5px 10px; border-radius:7px;
  background:var(--primary-soft); color:var(--primary-dark);
  font-size:17px; font-weight:800;
  font-variant-numeric:tabular-nums;
}
.head-sub{
  display:flex; align-items:center; gap:6px;
  padding:0 14px 7px;
  color:var(--muted);
  font-size:11px;
}
.timer{ font-family:var(--mono); font-size:14px; font-weight:700; color:var(--text); font-variant-numeric:tabular-nums; }
.paused-tag{
  background:rgba(230,81,0,.12); color:var(--amber);
  font-size:9.5px; font-weight:800; letter-spacing:.05em;
  padding:2px 6px; border-radius:4px;
}
.spacer{ flex:1; }
.sync-mini{ font-size:10px; color:var(--hint); font-weight:650; }

/* ===== 5. BODY ===== */
.survey-body{
  flex:1;
  padding:10px 12px 14px;
  display:flex; flex-direction:column; gap:9px;
}
.identity-row{ display:grid; grid-template-columns:1fr 1fr; gap:9px; }
.field{ display:flex; flex-direction:column; gap:3px; min-width:0; }
.field > span{ font-size:10.5px; font-weight:700; color:var(--muted); letter-spacing:.03em; }
.field input{
  height:42px; width:100%;
  padding:0 11px;
  border:1.5px solid var(--border);
  border-radius:8px;
  background:var(--surface);
  color:var(--text);
  font-size:14px;
}
.field input::placeholder{ color:var(--hint); }
.field input:focus{ outline:none; border-color:var(--primary); }
.field input:disabled{ background:var(--bg); color:var(--muted); }
.field-hint{ font-size:11px; color:var(--muted); line-height:1.5; margin-top:3px; }
.hint{ font-size:11px; color:var(--hint); text-align:center; line-height:1.5; }

/* ===== 6. SIMPANG ===== */
.simpang-list{ display:flex; flex-direction:column; gap:8px; }
.sim-row{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:12px;
  padding:9px 10px;
  display:flex; flex-direction:column; gap:7px;
  box-shadow:var(--shadow-sm);
}
.sim-info{ display:flex; align-items:center; gap:8px; min-width:0; }
.v-badge{
  font-size:11px; font-weight:800; color:var(--primary-dark);
  background:var(--primary-soft);
  padding:3px 8px; border-radius:6px;
  flex:0 0 auto;
}
.v-label{ font-size:11.5px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sim-dirs{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:6px; }
.dir-btn{
  height:50px;
  display:flex; align-items:center; justify-content:center; gap:7px;
  border-radius:9px;
  font-size:19px; font-weight:800;
  font-variant-numeric:tabular-nums;
  border:1px solid transparent;
  transition:transform .06s ease, filter .12s ease;
  user-select:none; -webkit-user-select:none;
  touch-action:manipulation;
}
.dir-btn .arrow{ font-size:14px; font-weight:700; opacity:.75; }
.dir-btn.left{ background:#E8F0FA; color:var(--blue); border-color:#CFDFF2; }
.dir-btn.straight{ background:#EAF3EA; color:var(--green); border-color:#D3E6D3; }
.dir-btn.right{ background:#FDF1E3; color:var(--primary-dark); border-color:#F6E0C3; }
.dir-btn:active{ transform:scale(.97); filter:brightness(.97); }
.dir-btn.off{ opacity:.42; pointer-events:none; }
.dir-btn.flash{ filter:brightness(.92); }

/* ===== 7. JALAN ===== */
.lane-mode{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.chip{
  height:36px; border-radius:8px;
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--muted);
  font-size:12.5px; font-weight:700;
  transition:background .15s ease, color .15s ease, border-color .15s ease;
}
.chip.active{ background:var(--primary-soft); border-color:rgba(232,133,12,.45); color:var(--primary-dark); }
.chip:disabled{ opacity:.5; pointer-events:none; }

.single-grid{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.dual-wrap{ display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.lane-col{ display:flex; flex-direction:column; gap:7px; min-width:0; }
.lane-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:4px 8px; border-radius:6px;
  background:var(--primary-soft); color:var(--primary-dark);
  font-size:10.5px; font-weight:800;
}
.lane-head b{ font-variant-numeric:tabular-nums; }

.vc-card{
  position:relative;
  min-height:104px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:11px;
  padding:10px;
  display:flex; flex-direction:column; gap:4px;
  text-align:left;
  box-shadow:var(--shadow-sm);
  user-select:none; -webkit-user-select:none;
  touch-action:manipulation;
  transition:transform .06s ease, border-color .12s ease, background .12s ease;
}
.vc-card:not(.edit):active{ transform:scale(.98); }
.vc-card.flash{ background:#FFF7ED; border-color:rgba(232,133,12,.5); }
.vc-card.off{ opacity:.45; pointer-events:none; }
.vc-card .vc-key{
  align-self:flex-start;
  font-size:10.5px; font-weight:800; color:var(--primary-dark);
  background:var(--primary-soft);
  padding:2px 7px; border-radius:5px;
}
.vc-card .vc-name{ font-size:11px; color:var(--muted); line-height:1.3; }
.vc-card .vc-count{
  margin-top:auto;
  font-size:32px; font-weight:900; line-height:1;
  color:var(--text);
  font-variant-numeric:tabular-nums;
}
.vc-card .vc-count.zero{ color:var(--hint); }
.vc-tools{
  position:absolute; top:5px; right:5px;
  display:none; gap:2px;
}
.vc-card.edit .vc-tools{ display:flex; }
.tool-btn{
  width:26px; height:26px;
  display:flex; align-items:center; justify-content:center;
  border-radius:6px;
  background:var(--bg); color:var(--muted);
}
.tool-btn .ic{ width:14px; height:14px; }
.tool-btn.del{ color:var(--red); background:rgba(183,28,28,.08); }
.tool-btn:active{ filter:brightness(.95); }
.vc-card.edit{ border-style:dashed; border-color:rgba(232,133,12,.5); cursor:grab; touch-action:none; }
.vc-card.dragging{
  z-index:80;
  pointer-events:none;
  background:#FFF7ED;
  border-color:var(--primary);
  box-shadow:0 16px 36px rgba(26,26,26,.24);
  opacity:.97;
  cursor:grabbing;
  will-change:transform;
  border-style:solid;
}
.vc-placeholder{
  border:1.5px dashed rgba(232,133,12,.55);
  background:rgba(232,133,12,.07);
  border-radius:11px;
  box-sizing:border-box;
}
.vc-card.drop-target{
  border-color:var(--primary);
  background:#FFFBF4;
  box-shadow:0 0 0 2px rgba(232,133,12,.22), var(--shadow-sm);
}
body.drag-active{ cursor:grabbing; user-select:none; }
.add-vehicle{
  height:44px; border-radius:10px;
  border:1.5px dashed rgba(232,133,12,.55);
  color:var(--primary-dark);
  font-size:12.5px; font-weight:750;
  display:flex; align-items:center; justify-content:center; gap:5px;
  background:rgba(232,133,12,.04);
  width:100%;
}
.edit-banner{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:8px 10px; border-radius:8px;
  background:rgba(232,133,12,.08);
  color:var(--primary-dark);
  font-size:11.5px; font-weight:650;
}
.edit-banner button{ color:var(--primary-dark); font-weight:800; font-size:11.5px; }

/* ===== 8. ACTION BAR ===== */
.action-bar{
  position:sticky; bottom:0; z-index:30;
  display:grid; grid-template-columns:1.3fr 1fr 1fr 1fr; gap:6px;
  background:var(--surface);
  border-top:1px solid var(--border);
  padding:9px 12px calc(9px + env(safe-area-inset-bottom, 0px));
}
.abtn{
  height:47px;
  border-radius:9px;
  display:flex; align-items:center; justify-content:center; gap:5px;
  color:#fff;
  font-size:12.5px; font-weight:800;
  transition:filter .12s ease, transform .06s ease;
}
.abtn .ic{ width:17px; height:17px; }
.abtn:active{ transform:translateY(1px); }
.abtn.start{ background:var(--green); }
.abtn.pause{ background:var(--amber); }
.abtn.stop{ background:var(--red); }
.abtn.export{ background:var(--surface); color:var(--primary-dark); border:1.5px solid rgba(232,133,12,.55); }
.abtn:disabled{ opacity:.4; pointer-events:none; }

/* ===== 9. RIWAYAT ===== */
.search-wrap{
  display:flex; align-items:center; gap:8px;
  background:var(--surface);
  border:1.5px solid var(--border);
  border-radius:9px;
  padding:0 11px;
  height:42px;
  color:var(--hint);
}
.search-wrap:focus-within{ border-color:var(--primary); }
.search-wrap input{ flex:1; border:none; outline:none; background:none; font-size:13.5px; color:var(--text); }
.filter-row{ display:flex; gap:7px; }
.filter-row .chip{ flex:1; height:33px; font-size:12px; }

.history-list{ display:flex; flex-direction:column; gap:9px; }
.hist-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:11px;
  padding:12px;
  box-shadow:var(--shadow-sm);
}
.hist-top{ display:flex; align-items:center; gap:7px; }
.mode-badge{
  font-size:9.5px; font-weight:800; letter-spacing:.05em;
  padding:3px 7px; border-radius:5px;
  background:var(--primary-soft); color:var(--primary-dark);
  flex:0 0 auto;
}
.mode-badge.jalan{ background:rgba(21,101,192,.10); color:var(--blue); }
.hist-loc{ flex:1; min-width:0; font-size:14.5px; font-weight:750; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hist-total{ font-size:16px; font-weight:800; color:var(--primary-dark); font-variant-numeric:tabular-nums; }
.hist-meta{ font-size:10.5px; color:var(--muted); margin-top:3px; line-height:1.5; }
.hist-chips{ display:flex; flex-wrap:wrap; gap:4px; margin-top:8px; }
.hist-chips span{
  font-size:10px; font-weight:700;
  background:var(--bg); color:var(--muted);
  padding:3px 6px; border-radius:5px;
  font-variant-numeric:tabular-nums;
}
.hist-actions{ display:flex; gap:6px; margin-top:10px; }
.hist-actions button{
  flex:1; height:33px; border-radius:7px;
  font-size:11.5px; font-weight:750;
  border:1px solid var(--border);
  background:var(--bg); color:var(--muted);
  display:flex; align-items:center; justify-content:center; gap:4px;
}
.hist-actions .act-del{ color:var(--red); border-color:rgba(183,28,28,.2); background:rgba(183,28,28,.05); }
.empty{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:8px; padding:46px 16px;
  text-align:center; color:var(--hint); font-size:13px; line-height:1.5;
}

/* ===== 10. PANEL / SETTINGS ===== */
.panel{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:11px;
  padding:13px;
  display:flex; flex-direction:column; gap:9px;
}
.panel-title{
  display:flex; align-items:center; gap:6px;
  font-size:10.5px; font-weight:800; letter-spacing:.08em;
  color:var(--primary-dark);
}
.panel-title .ic{ width:15px; height:15px; }
.kv{ display:flex; align-items:center; justify-content:space-between; font-size:12.5px; color:var(--muted); }
.kv b{ color:var(--text); font-weight:650; }
.sync-row{ display:flex; align-items:center; justify-content:flex-start; }
.steps{ padding-left:18px; display:flex; flex-direction:column; gap:6px; font-size:12.5px; color:var(--muted); line-height:1.55; }
.steps b{ color:var(--text); }
.body-text{ font-size:12.5px; color:var(--muted); line-height:1.6; }

/* ===== 11. TOMBOL UMUM ===== */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  height:44px; padding:0 16px;
  border-radius:9px;
  font-size:13.5px; font-weight:750;
  border:1.5px solid transparent;
  transition:filter .12s ease, transform .06s ease, background .15s ease;
}
.btn:active{ transform:translateY(1px); }
.btn-block{ width:100%; }
.btn-primary{ background:var(--primary); color:#fff; }
.btn-primary:hover{ filter:brightness(1.04); }
.btn-outline{ background:var(--surface); border-color:var(--primary); color:var(--primary-dark); }
.btn-ghost{ background:transparent; color:var(--muted); }
.btn-danger{ background:var(--red); color:#fff; }
.btn:disabled{ opacity:.45; pointer-events:none; }

/* ===== 12. DIALOG & TOAST ===== */
.overlay{
  position:fixed; inset:0; z-index:100;
  display:flex; align-items:center; justify-content:center;
  padding:18px;
  background:rgba(20,18,14,.48);
  opacity:0; visibility:hidden;
  transition:opacity .16s ease, visibility .16s ease;
}
.overlay.show{ opacity:1; visibility:visible; }
.dialog{
  width:100%; max-width:400px;
  max-height:88vh; overflow:auto;
  background:var(--surface);
  border-radius:var(--radius-lg);
  padding:18px;
  box-shadow:var(--shadow-md);
  transform:translateY(6px) scale(.985);
  transition:transform .16s ease;
}
.dialog-wide{ max-width:560px; }
.overlay.show .dialog{ transform:none; }
.dialog-head{ display:flex; align-items:flex-start; justify-content:space-between; gap:8px; margin-bottom:6px; }
.dialog-title{ font-size:16px; font-weight:800; }
.dialog-text{ font-size:12.5px; color:var(--muted); line-height:1.55; white-space:pre-line; }
.dialog-actions{ display:flex; gap:8px; margin-top:16px; }
.dialog-actions .btn{ flex:1; }
.add-list{ display:flex; flex-direction:column; gap:5px; margin-top:10px; }
.add-list button{
  display:flex; align-items:center; gap:8px;
  padding:10px; border-radius:8px;
  background:var(--bg); text-align:left;
  font-size:13px; font-weight:650;
}
.add-list .code{ font-weight:800; color:var(--primary-dark); }
.toast{
  position:fixed; left:50%; bottom:76px; z-index:120;
  transform:translate(-50%, 12px);
  background:#2A2722; color:#fff;
  font-size:12.5px; font-weight:650;
  padding:10px 16px; border-radius:999px;
  opacity:0; pointer-events:none;
  transition:opacity .18s ease, transform .18s ease;
  max-width:calc(100vw - 40px); text-align:center;
}
.toast.show{ opacity:1; transform:translate(-50%, 0); }

/* detail tabel */
.detail-table{ width:100%; border-collapse:collapse; margin-top:10px; font-size:11.5px; }
.detail-table th, .detail-table td{ border:1px solid var(--divider); padding:5px 7px; text-align:right; }
.detail-table th{ background:var(--bg); font-weight:750; color:var(--muted); }
.detail-table th:first-child, .detail-table td:first-child{ text-align:left; }
.detail-table tr.total td{ font-weight:800; background:#FBF8F2; }
.detail-chips{ display:flex; flex-wrap:wrap; gap:5px; margin-top:8px; }
.detail-chips span{ font-size:11px; background:var(--bg); border-radius:6px; padding:4px 8px; font-weight:650; }

/* ===== 13. RESPONSIF ===== */
@media (max-width:420px){
  .survey-body{ padding:9px 9px 12px; }
  .identity-row{ gap:7px; }
  .field > span{ font-size:10px; }
  .field input{ height:40px; font-size:13px; }
  .sim-row{ padding:8px; }
  .dir-btn{ height:46px; font-size:17px; }
  .vc-card{ min-height:96px; }
  .vc-card .vc-count{ font-size:28px; }
  .abtn span{ display:none; }
  .abtn{ gap:0; }
  .action-bar{ grid-template-columns:1.2fr 1fr 1fr 1fr; }
  .head-title strong{ font-size:15px; }
  .landing-head h1{ font-size:24px; }
}
@media (min-width:620px){
  .survey-body{ padding:14px 16px 18px; }
  .sim-row{ padding:11px 12px; }
  .dir-btn{ height:54px; }
}
