:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 60%, #1e3a8a 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  text-align: center;
}
.login-logo { font-size: 44px; line-height: 1; }
.login-card h1 { margin: 8px 0 2px; font-size: 26px; letter-spacing: -.5px; }
.login-card p { margin: 0 0 20px; font-size: 14px; }
.login-card label { text-align: left; }
.login-hint { margin-top: 16px !important; font-size: 12px; color: var(--muted); }

/* ---------------- Layout ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #0f172a;
  color: #fff;
}
.brand { font-weight: 700; letter-spacing: -.3px; display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-chip {
  font-size: 13px; background: rgba(255, 255, 255, .12);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  max-width: 45vw; overflow: hidden; text-overflow: ellipsis;
}

.tabs {
  position: sticky; top: 52px; z-index: 19;
  display: flex; gap: 4px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.tab.active { background: #eff6ff; color: var(--primary); }

.container { max-width: 900px; margin: 0 auto; padding: 16px 12px 48px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 28px; }

/* ---------------- Card ---------------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 17px; letter-spacing: -.3px; }
.section-split { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
.section-split h3 { margin: 0 0 4px; font-size: 15px; }

/* ---------------- Form ---------------- */
label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 12px; }
input, select, textarea {
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
input[type="file"] { padding: 9px; background: #f8fafc; }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.hint { font-size: 12px; color: var(--warn); margin: -6px 0 12px; min-height: 16px; }

.btn {
  border: 0; border-radius: 10px; font: inherit; font-weight: 600;
  padding: 11px 16px; cursor: pointer; background: #e2e8f0; color: #334155;
  transition: filter .15s;
}
.btn:hover { filter: brightness(.95); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); padding: 6px 10px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; margin-top: 6px; }

.inline-form {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.inline-form input { flex: 1 1 130px; width: auto; margin-top: 0; }
.inline-form button { flex: 0 0 auto; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters input, .filters select { flex: 1 1 140px; width: auto; margin-top: 0; font-size: 14px; }

/* ---------------- Fuel bar ---------------- */
.fuel { display: flex; align-items: flex-end; gap: 4px; margin: 2px 0 14px; }
.fuel-seg {
  flex: 1; height: 42px; border: 1px solid var(--border); background: #f8fafc;
  border-radius: 6px; cursor: pointer; position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  font-size: 10px; color: var(--muted); padding-bottom: 3px;
  transition: background .12s;
}
.fuel-seg[data-i="0"] { flex: 0 0 34px; }
.fuel-seg.on { background: var(--success); border-color: var(--success); color: #fff; }
.fuel-seg.on.low { background: var(--danger); border-color: var(--danger); }
.fuel-seg.on.mid { background: var(--warn); border-color: var(--warn); }
.fuel-label { font-size: 12px; color: var(--muted); margin: -10px 0 14px; }

/* ---------------- Switch ---------------- */
.switch-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 14px; font-size: 14px; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; margin: 0; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px;
  transition: background .18s; cursor: pointer;
}
.slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .18s;
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------------- Daftar / item ---------------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  background: #fff;
}
.item:hover { border-color: #cbd5e1; }
.item-main { min-width: 0; flex: 1; }
.item-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.item-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #e2e8f0; color: #475569; white-space: nowrap;
}
.badge.green { background: #dcfce7; color: #15803d; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.gray { background: #f1f5f9; color: #64748b; }

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

/* ---------------- Statistik ---------------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat {
  background: var(--surface); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -.6px; margin-top: 2px; }

/* ---------------- Banner perjalanan aktif ---------------- */
.banner {
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.banner h3 { margin: 0 0 4px; font-size: 16px; }
.banner p { margin: 0 0 12px; font-size: 13px; opacity: .9; }
.banner .btn { background: #fff; color: var(--primary-dark); }

.trip-summary {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 13px; margin-bottom: 16px;
}
.trip-summary b { display: inline-block; }

/* ---------------- Tujuan ---------------- */
.dest-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.dest-row input { margin-top: 0; }
.dest-row .del {
  flex: 0 0 auto; border: 0; background: #fee2e2; color: #b91c1c;
  width: 38px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 16px;
}

/* ---------------- Modal & toast ---------------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .6);
  display: grid; place-items: center; padding: 16px; z-index: 50;
}
.modal-box {
  background: #fff; border-radius: 16px; padding: 22px;
  max-width: 560px; width: 100%; max-height: 88vh; overflow: auto; position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; border: 0; background: #f1f5f9;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 14px;
}
.modal-box h3 { margin: 0 0 14px; font-size: 18px; padding-right: 30px; }
.detail-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px;
}
.detail-row span:first-child { color: var(--muted); flex: 0 0 auto; }
.detail-row span:last-child { text-align: right; font-weight: 600; }
.receipt-img { width: 100%; border-radius: 10px; border: 1px solid var(--border); margin-top: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; z-index: 60; max-width: 92vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

/* ---------------- Pemilih modul ---------------- */
.pilih-head { text-align: center; margin: 24px 0 22px; }
.pilih-head h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.4px; }

.modul-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.modul-card {
  /* appearance:none penting — tanpa ini tombol tetap memakai gaya bawaan browser */
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin: 0;
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius);
  padding: 26px 22px;
  box-shadow: var(--shadow);
  position: relative;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.modul-card[data-modul="tamu"] { border-left-color: var(--success); }

.modul-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, .08), 0 16px 32px rgba(15, 23, 42, .10);
}
.modul-card:active { transform: translateY(0); }
.modul-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .3);
}

/* tanda panah supaya jelas kartunya bisa diklik */
.modul-card::after {
  content: "→";
  position: absolute;
  right: 20px;
  bottom: 22px;
  font-size: 20px;
  color: var(--muted);
  transition: transform .15s, color .15s;
}
.modul-card:hover::after { transform: translateX(4px); color: var(--primary); }

.modul-ikon {
  font-size: 32px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: #eff6ff;
}
.modul-card[data-modul="tamu"] .modul-ikon { background: #dcfce7; }

.modul-nama { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.modul-ket {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  padding-right: 28px;   /* beri ruang untuk tanda panah */
}

/* ---------------- Topbar di layar sempit ----------------
   Tombol pindah modul menambah satu elemen di topbar, jadi pada
   lebar HP labelnya disingkat supaya tidak ada yang terpotong. */
.topbar .btn { white-space: nowrap; }

@media (max-width: 520px) {
  .topbar { padding: 10px 12px; gap: 6px; }
  .brand { font-size: 15px; gap: 6px; }
  .topbar-right { gap: 4px; }
  .topbar .btn-sm { padding: 6px 8px; font-size: 13px; }
  .user-chip { max-width: 28vw; font-size: 12px; padding: 4px 8px; }
  .teks-panjang { display: none; }
}
