:root {
  --navy: #0a1834; --navy-2: #1b2a48; --green: #10a977; --green-d: #0b8a61; --green-soft: #e6f6f0; --slate: #404e62;
  --bg: #f3f5f8; --side: #fbfcfd; --card: #fff;
  --text: #16213a; --muted: #66728a; --line: #e2e7ee; --ok: #10a977; --warn: #d98e04; --bad: #d64545; --info: #2f6fd6;
  --radius: 10px; --shadow: 0 1px 2px rgba(10, 24, 52, .05), 0 1px 3px rgba(10, 24, 52, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--green-d); text-decoration: none; }
a:hover { color: var(--navy); }
h1 { font-size: 22px; margin: 0 0 18px; color: var(--navy); letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 24px 0 10px; color: var(--navy); }
h3 { font-size: 15px; margin: 16px 0 10px; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.shell { display: flex; min-height: 100vh; }
.side { width: 244px; background: var(--side); border-right: 1px solid var(--line); flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: var(--navy); font-weight: 800; font-size: 18px; letter-spacing: .01em; }
.brand:hover { color: var(--navy); }
.brand-mark { width: 40px; height: auto; display: block; }
.brand small { display: block; font-weight: 600; font-size: 11px; color: var(--green); text-transform: uppercase; letter-spacing: .06em; }
.side nav { padding: 6px 12px 18px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; color: var(--slate); border-radius: 8px; font-weight: 500; }
.side nav a i { color: #8b96aa; font-size: 15px; transition: color .15s; }
.side nav a:hover { background: #eef2f6; color: var(--navy); }
.side nav a:hover i { color: var(--navy); }
.side nav a.active { background: var(--green-soft); color: var(--green-d); font-weight: 600; }
.side nav a.active i { color: var(--green); }
.nav-group { margin-top: 8px; }
.nav-group summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px 6px; cursor: pointer; user-select: none;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #8b96aa; border-radius: 6px; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { color: var(--navy); }
.nav-group summary > span:first-child { flex: 1; }
.nav-group .chev { font-size: 10px; transition: transform .2s; }
.nav-group:not([open]) .chev { transform: rotate(-90deg); }
.nav-group[open] .nav-count.sum { display: none; }
.nav-group a { margin-bottom: 2px; }
.side nav a span:first-of-type { flex: 1; }
.nav-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--green); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; letter-spacing: 0; text-transform: none; }
.nav-count.bad { background: var(--bad); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 500; }
.who { display: flex; align-items: center; gap: 10px; }
.who strong { color: var(--navy); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.top-actions form { margin: 0; }
.bell { position: relative; font-size: 18px; color: var(--slate); width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; }
.bell:hover { background: #eef2f6; color: var(--navy); }
.bell .dot { position: absolute; top: 2px; right: 0; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; border-radius: 10px; padding: 0 5px; line-height: 16px; }
.content { padding: 28px; max-width: 1320px; width: 100%; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--slate); font-weight: 500; }
.back:hover { color: var(--green-d); }
.head .back { margin-bottom: 6px; font-size: 13px; }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 4px; }
.entity-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-size: 18px; }

.top-search { flex: 1; max-width: 460px; margin: 0 24px; position: relative; }
.top-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #8b96aa; font-size: 13px; }
.top-search input { padding: 8px 12px 8px 36px; border-radius: 20px; background: var(--bg); border-color: transparent; }
.top-search input:focus { background: #fff; }
.searchbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; padding: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.searchbar select { width: auto; min-width: 150px; }
.search-input { position: relative; flex: 1; min-width: 240px; }
.search-input i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #8b96aa; font-size: 13px; }
.search-input input { padding-left: 34px; }
.result-count { margin-left: auto; }

.pill-tabs { flex-wrap: wrap; }
.head > div:first-child { flex: 1; min-width: 260px; }
.tabs.pill-tabs a { flex: 0 1 auto; padding: 7px 14px; border-radius: 20px; background: var(--card); display: inline-flex; align-items: center; gap: 7px; }
.pill-tabs a i { color: #8b96aa; }
.pill-tabs a.on i { color: var(--green); }
table.activity td { vertical-align: middle; }
.act-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--green-soft); color: var(--green); font-size: 12px; margin-right: 6px; }
.act-icon.bad { background: #fbe5e5; color: var(--bad); }
.act-extra { margin: 2px 0 0 38px; }
tr.row-bad td { background: #fffafa; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 18px; }
.searchbar label.inline { font-weight: 500; color: var(--muted); gap: 6px; }

.row-actions { width: 1%; white-space: nowrap; text-align: right; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--slate); border: 1px solid var(--line); background: #fff; transition: all .15s; }
.icon-btn:hover { color: #fff; background: var(--green); border-color: var(--green); }
td.row-actions { vertical-align: middle; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } .side { display: none; } .top-search { display: none; } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 16px 72px; position: relative; box-shadow: var(--shadow); min-height: 78px; }
.stat .si { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: var(--green-soft); color: var(--green); }
.stat .si.navy { background: #e8ecf3; color: var(--navy); }
.stat .n { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat .n a { color: inherit; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat.alert .n { color: var(--bad); }
.stat.alert .si { background: #fbe5e5; color: var(--bad); }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head h1 { margin: 0; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #f8fafb; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafcfb; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: #fff; margin-bottom: 18px; box-shadow: var(--shadow); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.badge.ok { background: #e3f5ee; color: var(--green-d); }
.badge.warn { background: #fdf1dc; color: #9a6400; }
.badge.bad { background: #fbe5e5; color: #a82e2e; }
.badge.info { background: #e4edfb; color: #22529f; }
.badge.muted { background: #eef0f4; color: var(--muted); }

form.stack { display: grid; gap: 12px; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
label .hint { font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cdd3de; border-radius: 6px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(16, 169, 119, .18); border-color: var(--green); }
input[type=checkbox] { width: auto; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--green); background: var(--green); color: #fff; padding: 8px 16px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--green-d); border-color: var(--green-d); color: #fff; }
.btn.secondary { background: #fff; color: var(--navy); border-color: #cdd3de; }
.btn.secondary:hover { background: #f2f4f7; color: var(--navy); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 11px; font-size: 12px; }
.btn.link { background: none; border: none; color: var(--info); padding: 0; font-weight: 400; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline input, .inline select { width: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
details.box { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: #fafbfc; }
details.box summary { cursor: pointer; font-weight: 600; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.flash.success { background: #e3f5ee; border-color: #b6e3d1; color: #125c43; }
.flash.error { background: #fbe5e5; border-color: #f2c0c0; color: #8a2323; }
.flash.info { background: #e4edfb; border-color: #c2d5f5; color: #1d4583; }
.notice { padding: 12px 14px; border-left: 4px solid var(--warn); background: #fff8ea; border-radius: 4px; margin-bottom: 16px; }
.notice.bad { border-color: var(--bad); background: #fdf0f0; }
.notice.ok { border-color: var(--ok); background: #eef9f4; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0 6px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }

.steps { display: flex; gap: 0; margin: 0 0 18px; padding: 0; list-style: none; overflow-x: auto; }
.steps li { flex: 1; text-align: center; font-size: 12px; padding: 8px 4px; border-bottom: 3px solid var(--line); color: var(--muted); white-space: nowrap; }
.steps li.done { border-color: var(--green); color: var(--green-d); }
.steps li.current { border-color: var(--navy); color: var(--navy); font-weight: 700; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs a img { width: 120px; height: 90px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); }
.map.tall { height: calc(100vh - 160px); min-height: 420px; }

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
  background: radial-gradient(1200px 600px at 85% -10%, rgba(16, 169, 119, .35), transparent 60%), linear-gradient(160deg, var(--navy), #13294d); }
.auth-card { background: #fff; border-radius: 16px; padding: 32px; width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand img { width: 220px; max-width: 80%; height: auto; }
.auth-card .btn { width: 100%; padding: 10px 16px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs a { flex: 1; text-align: center; padding: 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); }
.tabs a.on { background: var(--navy); color: #fff; border-color: var(--navy); }

h1 > i, h2 > i, h3 > i { color: var(--green); margin-right: 6px; }

.picker { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fbfcfd; min-width: 0; }
.picker.picker-missing { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(214, 69, 69, .12); }
.picker-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.picker-head h3 { margin: 0 0 10px; flex: 0 0 auto; }
.picker-dot.green { color: var(--green); }
.picker-dot.navy { color: var(--navy); }
.picker-status { flex: 1 1 160px; min-width: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 10px; }
.picker-status.bad { color: var(--bad); font-weight: 600; }
.picker-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.picker-tools select { width: auto; flex: 0 1 170px; }
.picker-search { min-width: 200px; z-index: 1100; }
.picker-results { position: absolute; z-index: 1100; top: calc(100% + 4px); left: 0; min-width: min(380px, 85vw); right: 0; margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(10, 24, 52, .12); max-height: 280px; overflow-y: auto; }
.picker-results li.muted { padding: 10px 12px; }
.picker-results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; color: var(--text); }
.picker-results button:hover { background: var(--green-soft); }
.picker-results button span { display: block; font-size: 12px; color: var(--muted); }
.picker-map { height: 300px; border-radius: 8px; border: 1px solid var(--line); cursor: crosshair; }
.picker-hint { margin: 6px 0 10px; }
.picker-pin { font-size: 34px; line-height: 1; text-shadow: 0 2px 3px rgba(0, 0, 0, .3); }
.picker-pin i { display: block; }

.fleet { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: stretch; }
.fleet .map.tall { height: calc(100vh - 190px); min-height: 460px; }
.fleet-list { padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 190px); min-height: 460px; }
.fleet-list .search-input { flex: 0 0 auto; }
.fleet-list ul { flex: 1 1 auto; min-height: 0; list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; gap: 6px; align-content: start; }
.fleet-list button { display: grid; gap: 3px; width: 100%; text-align: left; font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.fleet-list button:hover { border-color: var(--green); background: #fbfefd; }
.fleet-list button.no-gps { cursor: default; opacity: .75; }
.fleet-empty { padding: 14px 6px; text-align: center; }
.fl-top { display: flex; align-items: center; gap: 7px; }
.fl-top strong { color: var(--navy); letter-spacing: .02em; }
.fl-state { margin-left: auto; font-size: 11px; font-weight: 600; }
.fl-state.moving { color: var(--green-d); } .fl-state.stopped { color: #9a6400; } .fl-state.alert { color: var(--bad); } .fl-state.stale { color: var(--muted); }
.fl-line { font-size: 12px; color: var(--slate); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-line i { color: #8b96aa; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.moving { background: var(--green); } .dot.stopped { background: var(--warn); } .dot.alert { background: var(--bad); } .dot.stale { background: #a3acbb; }
.fleet-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; align-items: center; }
.fleet-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fleet-marker { display: inline-flex; align-items: center; white-space: nowrap; filter: drop-shadow(0 1px 3px rgba(10, 24, 52, .35)); }
.fm-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; border: 2px solid #fff; position: relative; z-index: 1; }

.fleet-marker.moving .fm-dot { background: var(--green); } .fleet-marker.stopped .fm-dot { background: var(--warn); }
.fleet-marker.alert .fm-dot { background: var(--bad); } .fleet-marker.stale .fm-dot { background: #a3acbb; }

.fleet-pop { line-height: 1.7; } .fleet-pop i { width: 14px; color: #8b96aa; }
@media (max-width: 900px) { .fleet { grid-template-columns: 1fr; } .fleet-list { max-height: 260px; min-height: 0; } }

.plate { display: inline-block; background: #ffd21f; color: #111; border: 1.5px solid #111; border-radius: 3px; padding: 0 6px;
  font: 800 11px/17px "DejaVu Sans Mono", "Consolas", monospace; letter-spacing: .06em; white-space: nowrap; }
.fleet-marker .plate { margin-left: -6px; padding-left: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.fleet-marker.alert .plate { border-color: var(--bad); box-shadow: 0 0 0 2px rgba(214, 69, 69, .5); }
.fleet-marker.stale .plate { background: #ece6c4; color: #666; border-color: #888; }
.fleet-list button.on { border-color: var(--green); background: var(--green-soft); }
.trail-bar { background: #fff; padding: 6px 8px 6px 12px; border-radius: 8px; box-shadow: 0 2px 8px rgba(10, 24, 52, .2);
  display: flex; align-items: center; gap: 8px; font: 600 13px system-ui, sans-serif; color: var(--navy); }
.trail-bar[hidden] { display: none; }
.trail-bar button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 9px; cursor: pointer; font: inherit; font-weight: 500; color: var(--slate); }
.trail-bar button:hover { border-color: var(--green); color: var(--green-d); }

.quote { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border: 1px solid var(--line, #e3e8ef); border-radius: 12px; background: var(--green-soft); }
.quote-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--green); font-size: 18px; flex: none; }
.quote-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--slate); font-weight: 600; }
.quote-amount { font-size: 22px; font-weight: 700; color: var(--navy); margin: 2px 0; }
.quote.loading .quote-amount { font-size: 15px; font-weight: 500; color: var(--slate); }
.quote.bad { background: #fdf0f0; }
.quote.bad .quote-amount, .quote-amount.bad { font-size: 15px; color: var(--bad); }
