:root {
  --bg: #0b1524;
  --bg-2: #0e1b2c;
  --panel: #13233a;
  --panel-2: #17294300;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eaf1fb;
  --muted: #8aa0bd;
  --accent: #ffb703;
  --accent-2: #2f80ed;
  --green: #34c759;
  --danger: #ff5a5f;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 50% -10%, #16294a 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo { color: var(--accent); }
.card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-radius: 7px;
  cursor: pointer;
}
.tab.active { background: var(--accent-2); color: #fff; }
h2 { font-size: 18px; margin: 4px 0 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--text);
  font-size: 15px;
}
input:focus { outline: none; border-color: var(--accent-2); }
button.primary {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #201500;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  margin-top: 4px;
}
button.primary:hover { filter: brightness(1.05); }
button.primary:disabled { opacity: 0.6; cursor: default; }
.switch { font-size: 13px; color: var(--muted); text-align: center; margin: 14px 0 0; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 2px 0 8px; }
.tagline { color: var(--muted); font-size: 13px; margin-top: 18px; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand-sm { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.co { display: flex; flex-direction: column; line-height: 1.15; }
.co .code { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.spacer { flex: 1; }
.who { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
button.link {
  background: none;
  border: 0;
  color: var(--accent-2);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
}
button.link.danger { color: var(--danger); }
.nav {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.navbtn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.navbtn.active { background: var(--panel); color: var(--text); }
main { max-width: 900px; margin: 0 auto; padding: 22px 18px 60px; }
h1 { font-size: 22px; margin: 4px 0 18px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.stat .num { font-size: 30px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

.row-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-form input { width: auto; flex: 1 1 140px; margin-top: 0; }
.row-form button.primary { width: auto; flex: 0 0 auto; margin-top: 0; padding: 11px 18px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 8px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }

.driver main { max-width: 560px; }

/* ---------- phase 2 ---------- */
.right { text-align: right; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.head-row h3 { display: flex; align-items: center; gap: 10px; margin: 0; }
select {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--bg-2);
  color: var(--text);
  font-size: 15px;
}
select:focus { outline: none; border-color: var(--accent-2); }
.row-form select { width: auto; flex: 1 1 150px; margin-top: 0; }
.row-form input[type="date"] { width: auto; flex: 0 0 auto; margin-top: 0; }
.head-row input[type="date"] { width: auto; margin-top: 0; }
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(47, 128, 237, 0.16);
  color: #7bb0f5;
  text-transform: capitalize;
}
.badge.done { background: rgba(52, 199, 89, 0.16); color: var(--green); }
.job-card .job-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.complete-btn { padding-left: 0; margin-top: 8px; }
.complete-form { margin-top: 12px; }
.complete-form.hidden { display: none; }
input[type="file"] { padding: 8px; background: var(--bg-2); }

/* ---------- maps / gps ---------- */
.map-el { width: 100%; height: 460px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.loc { font-size: 13px; color: var(--muted); margin: 4px 0 14px; }

.route-stop { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.route-stop:last-child { border-bottom: 0; }
.route-stop .seq {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #201500; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.route-stop .rs-main { flex: 1; min-width: 0; }
.nav-link {
  flex: 0 0 auto; background: var(--accent-2); color: #fff;
  padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.nav-link:hover { text-decoration: none; filter: brightness(1.05); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 10, 20, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  width: 100%; max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 20px 22px 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-x {
  background: none; border: 0; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-x:hover { color: var(--text); }
.kv {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line);
}
.kv:last-of-type { border-bottom: 0; }
.kv span { color: var(--muted); font-size: 13px; }
.kv code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 15px; font-weight: 600; color: var(--text);
}
.modal-card input[readonly] { font-size: 13px; color: var(--muted); }
