/* ============================================================
   app.css — LATRA web (app surveyor + app pembimbing)
   Tema terang untuk pemakaian lapangan.
   Palet: oranye keselamatan (aksen) + teal (sekunder) di atas
   latar hangat terang. 60-30-10.
   ============================================================ */
:root {
  --bg: #F6F4F1;
  --surface: #FFFFFF;
  --accent: #E8590C;
  --accent-dark: #D0490A;
  --teal: #0B7285;
  --text: #262220;
  --muted: #7A726B;
  --line: #E4DED7;
  --ok: #2B8A3E;
  --danger: #C92A2A;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(38, 34, 32, .08);
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 84px;
}

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
}
.brand { font-size: 18px; font-weight: 800; letter-spacing: .02em; }
.brand span { color: var(--accent); }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; }
.topbar .spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.ok { color: var(--ok); border-color: rgba(43,138,62,.35); }
.badge.ok .dot { background: var(--ok); }
.badge.warn { color: var(--accent-dark); border-color: rgba(232,89,12,.35); }
.badge.warn .dot { background: var(--accent); }

/* ---------- tab ---------- */
.tabs {
  display: flex; gap: 6px; padding: 10px 14px 0;
}
.tab {
  flex: 1; text-align: center;
  padding: 9px 10px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--muted);
  cursor: pointer; user-select: none;
}
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }

/* ---------- kartu ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin: 10px 14px;
}
.card-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-bottom: 8px;
}

/* ---------- form ---------- */
.field { margin-bottom: 8px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin-bottom: 3px;
}
.field input, .field select {
  width: 100%; padding: 10px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--text);
}
.field input:focus, .field select:focus {
  outline: 2px solid rgba(232,89,12,.35); border-color: var(--accent);
}
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; }

/* ---------- ubin kendaraan ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 14px 10px; font-size: 14px; font-weight: 600;
  text-align: center; cursor: pointer; user-select: none;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.tile:active { transform: scale(.96); }
.tile.selected {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.tile .code {
  display: block; font-size: 10px; font-weight: 700;
  letter-spacing: .08em; opacity: .75; margin-top: 2px;
}

/* ---------- stopwatch & kecepatan ---------- */
.measure { text-align: center; padding: 14px 12px 10px; }
.speed-num {
  font-size: 52px; font-weight: 900; line-height: 1;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.speed-unit { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.watch {
  font-size: 38px; font-weight: 900; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
  margin-top: 8px;
}
.watch-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .08em; }
.watch.running { color: var(--teal); }
.flash { animation: flash .35s ease; }
@keyframes flash {
  0% { background: rgba(232,89,12,.18); }
  100% { background: transparent; }
}

.chips { display: flex; gap: 6px; margin-top: 12px; }
.chip {
  flex: 1; text-align: center;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 4px;
}
.chip .v { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.chip .l { font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 700;
  padding: 11px 16px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; user-select: none;
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.97); filter: brightness(.95); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.dark { background: var(--text); border-color: var(--text); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.small { padding: 7px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ---------- bar bawah tetap ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px;
}
.bottombar .btn { flex: 1; padding: 15px 10px; font-size: 16px; }

/* ---------- tabel ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.new { animation: rowin .5s ease; }
@keyframes rowin {
  0% { background: rgba(232,89,12,.18); }
  100% { background: transparent; }
}

/* ---------- kartu ringkasan ---------- */
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  flex: 1 1 30%; min-width: 96px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 10px;
}
.stat .v { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-top: 2px; }

/* ---------- riwayat / daftar ---------- */
.list-item {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 10px 12px; margin-bottom: 8px;
}
.list-item .head { display: flex; align-items: center; gap: 8px; }
.list-item .title { font-size: 14px; font-weight: 700; }
.list-item .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.list-item .actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- kode sesi besar (pembimbing) ---------- */
.codebox {
  text-align: center; padding: 16px 12px;
  border: 2px dashed var(--accent); border-radius: var(--radius);
  background: rgba(232,89,12,.06);
}
.codebox .code {
  font-size: 40px; font-weight: 900; letter-spacing: .12em;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.codebox .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- notifikasi kecil ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--text); color: #fff;
  font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 6px;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
  z-index: 50;
}
.toast.show { opacity: 1; }

.empty {
  text-align: center; color: var(--muted);
  font-size: 13px; padding: 18px 10px;
}

.footnote { font-size: 11px; color: var(--muted); margin: 8px 14px 20px; line-height: 1.5; }

/* ---------- desktop (dashboard pembimbing) ---------- */
@media (min-width: 760px) {
  .wrap { max-width: 880px; margin: 0 auto; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
