:root {
  --bg: #f2f5fa;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e7ecf4;
  --primary: #2563eb;
  --primary-weak: #e8f0ff;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 6px 22px rgba(15, 23, 42, 0.06);
  --radius: 18px;
  --nav-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
.hidden { display: none !important; }

.app {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
}

/* ---------------------------------------------------------------- login */
.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 24px calc(48px + env(safe-area-inset-bottom));
  background: radial-gradient(120% 80% at 20% 0%, #1e3a8a 0%, #0b1220 55%, #070b14 100%);
  color: #e2e8f0;
}
.login .brand { font-size: 30px; font-weight: 800; letter-spacing: 2px; }
.login .brand span { color: #60a5fa; }
.login .slogan { color: #94a3b8; margin: 6px 0 30px; font-size: 13px; }
.login .field { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.14); }
.login .field input { color: #f1f5f9; }
.login .field input::placeholder { color: #64748b; }
.login .btn-primary { margin-top: 18px; height: 50px; font-size: 16px; }
.login .err { color: #fca5a5; font-size: 13px; min-height: 18px; margin-top: 10px; }
.login .foot { margin-top: 26px; color: #475569; font-size: 12px; text-align: center; }

/* ---------------------------------------------------------------- layout */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(242, 245, 250, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(231, 236, 244, 0.8);
}
.top h1 { font-size: 18px; margin: 0; font-weight: 700; flex: 1; }
.top .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); display: grid; place-items: center; color: var(--text);
}
.icon-btn svg { width: 19px; height: 19px; }

.page { padding: 14px 16px 0; display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; border: 1px solid rgba(231, 236, 244, 0.7);
}
.card.flush { padding: 0; overflow: hidden; }
.card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title h2 { font-size: 15px; margin: 0; font-weight: 650; }
.card-title .more { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 2px; }

/* ---------------------------------------------------------------- vehicle hero */
.hero { position: relative; overflow: hidden; padding: 18px 18px 16px; }
.hero::after {
  content: ""; position: absolute; inset: -40% -20% auto auto; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.14), transparent 68%);
}
.hero .name { font-size: 20px; font-weight: 750; letter-spacing: 0.5px; }
.hero .plate {
  display: inline-block; margin-left: 8px; font-size: 12px; padding: 2px 8px; border-radius: 6px;
  background: var(--primary-weak); color: var(--primary); font-weight: 600; vertical-align: 2px;
}
.hero .state { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14); }
.dot.off { background: #94a3b8; }
.hero .loc { margin-top: 14px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.hero .loc svg { width: 17px; height: 17px; color: var(--primary); flex: none; }
.hero .loc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero .split { display: flex; gap: 8px; margin-top: 14px; }
.hero .split button { flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { background: #f8fafd; border-radius: 14px; padding: 10px 8px; text-align: center; }
.stat b { display: block; font-size: 19px; font-weight: 750; letter-spacing: 0.3px; }
.stat small { color: var(--muted); font-size: 11.5px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  border: 0; border-radius: 13px; height: 42px; padding: 0 16px; font-size: 14px;
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #eef2f8; color: var(--text);
}
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-block { width: 100%; }
.btn:active { transform: scale(0.985); }
.btn[disabled] { opacity: 0.55; }

/* ---------------------------------------------------------------- list rows */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 13px 2px;
  border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left; color: var(--text); font-size: 14.5px;
}
.row:last-child { border-bottom: 0; }
.row .ico {
  width: 36px; height: 36px; border-radius: 11px; background: var(--primary-weak);
  color: var(--primary); display: grid; place-items: center; flex: none;
}
.row .ico.green { background: #e7f8f1; color: var(--green); }
.row .ico.amber { background: #fff6e5; color: #b45309; }
.row .ico.red { background: #feeceb; color: #b91c1c; }
.row .ico svg { width: 19px; height: 19px; }
.row .body { flex: 1; min-width: 0; }
.row .body b { display: block; font-weight: 600; font-size: 14.5px; }
.row .body small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.row .chev { color: #c3ccda; flex: none; }
.row .chev svg { width: 18px; height: 18px; }
.row .value { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- forms */
.field {
  display: flex; align-items: center; gap: 10px; background: #f8fafd;
  border: 1px solid var(--line); border-radius: 13px; padding: 0 13px; height: 46px;
}
.field input, .field select {
  flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--text);
  min-width: 0;
}
.field label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-actions .btn { flex: 1; }

/* ---------------------------------------------------------------- map */
.map-wrap { position: relative; }
.map { width: 100%; height: calc(100vh - var(--nav-h) - 150px); min-height: 380px; background: #dfe6ef; }
.map.full { height: calc(100vh - var(--nav-h) - env(safe-area-inset-top)); }
.map-toolbar {
  position: absolute; right: 12px; bottom: 16px; z-index: 500; display: flex; flex-direction: column; gap: 8px;
}
.map-toolbar .icon-btn { width: 42px; height: 42px; box-shadow: var(--shadow); }
.map-hint {
  position: absolute; left: 12px; bottom: 16px; z-index: 500;
  background: rgba(15, 23, 42, 0.78); color: #e2e8f0; font-size: 12px;
  padding: 7px 11px; border-radius: 10px; backdrop-filter: blur(6px);
}
.map-chip {
  position: absolute; left: 12px; top: 12px; z-index: 500; background: #fff;
  border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 13px; max-width: 72%;
}
.map-chip b { display: block; font-size: 14px; }
.map-chip small { color: var(--muted); }
.car-marker { width: 18px; height: 18px; border-radius: 50%; background: var(--primary);
  border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.22); }
.car-marker.idle { background: #64748b; box-shadow: 0 0 0 6px rgba(100, 116, 139, 0.2); }
.leaflet-container { font-family: inherit; }

/* ---------------------------------------------------------------- trips */
.trip {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--line); padding: 13px 2px;
}
.trip:last-child { border-bottom: 0; }
.trip .line1 { display: flex; align-items: baseline; gap: 8px; }
.trip .time { font-size: 14px; font-weight: 650; }
.trip .dur { color: var(--muted); font-size: 12px; margin-left: auto; }
.trip .dest { color: var(--muted); font-size: 12.5px; margin-top: 3px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.trip .meta { display: flex; gap: 14px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.trip .meta b { color: var(--text); font-weight: 650; font-size: 13px; }
.day-head { color: var(--muted); font-size: 12px; padding: 6px 2px; }

/* ---------------------------------------------------------------- report */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding: 6px 2px 0; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; height: 100%; }
.bar .fill { width: 100%; max-width: 34px; border-radius: 7px 7px 4px 4px; background: linear-gradient(180deg, #60a5fa, #2563eb); min-height: 3px; transition: height .3s; }
.bar .cap { font-size: 10.5px; color: var(--muted); }
.bar .val { font-size: 10px; color: var(--muted); }
.score-ring { display: flex; align-items: center; gap: 16px; }
.score-ring .num { font-size: 40px; font-weight: 800; letter-spacing: -1px; }
.score-ring .num small { font-size: 13px; color: var(--muted); font-weight: 500; }
.beh { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.beh div { background: #f8fafd; border-radius: 12px; padding: 9px; text-align: center; }
.beh b { display: block; font-size: 17px; }
.beh small { color: var(--muted); font-size: 11px; }

/* ---------------------------------------------------------------- nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.94); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line); display: flex;
}
.nav button {
  flex: 1; border: 0; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: #94a3b8; font-size: 10.5px;
}
.nav button svg { width: 23px; height: 23px; }
.nav button.active { color: var(--primary); }

/* ---------------------------------------------------------------- misc */
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #eef2f8; color: var(--muted); }
.badge.green { background: #e7f8f1; color: #047857; }
.badge.red { background: #feeceb; color: #b91c1c; }
.badge.blue { background: #e8f0ff; color: #1d4ed8; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 26px); transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 13px; z-index: 3000; max-width: 86vw; text-align: center;
}
.sheet-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 2000;
  display: flex; align-items: flex-end;
}
.sheet {
  width: 100%; background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 86vh; overflow: auto;
}
.sheet h3 { margin: 0 0 12px; font-size: 16px; }
.seg { display: flex; background: #eef2f8; border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; font-size: 13px; color: var(--muted); }
.seg button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.speed-legend { display: flex; gap: 10px; font-size: 11px; color: var(--muted); margin-top: 8px; align-items: center; }
.speed-legend i { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }
