:root {
  --panel: #121419;
  --panel-2: #191c22;
  --line: rgba(255, 255, 255, .09);
  --ink: #f3f1ec;
  --muted: #a3a8b1;
  --orange: #ff5a1f;
  --orange-d: #e2490f;
  --amber: #f5b100;
  --green: #48e07f;
  --bar: 60px;
  --font: "Overpass", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Overpass Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: #0b0d11; color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45; overflow: hidden; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }

/* top bar */
.pbar {
  position: fixed; inset: 0 0 auto 0; height: calc(var(--bar) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; z-index: 1000;
  display: flex; align-items: center; gap: 12px; background: rgba(17, 19, 24, .94); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex: none; }
.mark { width: 32px; height: 32px; }
.wm { display: flex; flex-direction: column; line-height: 1; }
.wm b { font-weight: 900; letter-spacing: .12em; font-size: 14.5px; }
.wm small { font-size: 9px; letter-spacing: .24em; color: var(--muted); margin-top: 4px; font-weight: 700; }
.live-pill { display: flex; align-items: center; gap: 7px; margin-left: auto; font-family: var(--mono); font-size: 12px; color: #cfd2d8; background: #0a0b0e; border: 1px solid var(--line); padding: 6px 11px; border-radius: 999px; white-space: nowrap; }
.live-pill b { color: var(--green); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: ping 1.8s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(72, 224, 127, .6); } 70%, 100% { box-shadow: 0 0 0 8px rgba(72, 224, 127, 0); } }
.who { display: flex; align-items: center; gap: 12px; }
.who-n { display: none; flex-direction: column; line-height: 1.15; text-align: right; }
.who-n b { font-size: 14px; }
.who-n small { font-size: 12px; color: var(--muted); }
@media (min-width: 760px) { .who-n { display: flex; } }
.btn-s { white-space: nowrap; height: 36px; padding: 0 14px; border-radius: 999px; background: transparent; border: 1px solid rgba(255, 255, 255, .22); cursor: pointer; font-weight: 700; font-size: 13.5px; }
@media (max-width: 420px) { .live-pill { padding: 6px 9px; font-size: 11px; } .wm small { letter-spacing: .14em; } }

/* map */
.mapwrap { position: fixed; inset: calc(var(--bar) + env(safe-area-inset-top)) 0 0 0; }
.map { position: absolute; inset: 0; background: #0b0d11; }
.is-auth .map { filter: saturate(.9); }
.leaflet-container { font-family: var(--font); background: #0b0d11; }
.leaflet-control-attribution { background: rgba(10, 11, 14, .7) !important; color: #8a9099 !important; font-size: 10.5px; }
.leaflet-control-attribution a { color: #b8bec7 !important; }
.leaflet-bar a { background: #191c22 !important; color: #fff !important; border-color: #2a2e36 !important; }
.leaflet-control-zoom { border: 1px solid #2a2e36 !important; }

.trk { transition: transform 1s linear; }
.fast .trk { transition: transform .25s linear; }
.no-anim .trk, .leaflet-zoom-anim .trk { transition: none !important; }
.trk-i { width: 30px; height: 30px; display: grid; place-items: center; }
.trk-i svg { width: 30px; height: 30px; transition: transform .6s; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .6)); }
.trk-i.mine svg .b { fill: var(--orange); }
.trk-i.sel svg { width: 38px; height: 38px; }
.trk-i.sel::before { content: ""; position: absolute; width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--orange); animation: ring 1.8s infinite; }
@keyframes ring { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
.fleet-dot { width: 10px; height: 10px; border-radius: 50%; background: #8d96a3; border: 2px solid #0b0d11; }
.trk-tip { background: #fff; color: #16181c; font-weight: 800; border: 0; border-radius: 6px; box-shadow: 0 6px 16px rgba(0, 0, 0, .4); padding: 3px 8px; font-size: 12px; }
.trk-tip::before { display: none; }

.mapctl { position: absolute; z-index: 600; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.seg { display: flex; background: rgba(17, 19, 24, .92); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 999px; font-weight: 800; font-size: 12.5px; cursor: pointer; color: #cfd2d8; }
.seg button.on { background: var(--orange); color: #fff; }
.tog { display: flex; align-items: center; gap: 7px; background: rgba(17, 19, 24, .92); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 12.5px; font-weight: 800; cursor: pointer; }
.tog input { accent-color: var(--orange); width: 16px; height: 16px; margin: 0; }

/* shared */
.kick { margin: 0 0 8px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--amber); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 20px; border-radius: 999px; font-weight: 800; font-size: 15.5px; text-decoration: none; cursor: pointer; border: 0; }
.btn.wide { width: 100%; }
.btn-o { background: var(--orange); color: #fff; }
.btn-o:hover { background: var(--orange-d); }
.btn-g { background: transparent; color: var(--ink); border: 1.5px solid rgba(255, 255, 255, .3); }
.err { margin: 0; color: #ff8a65; font-size: 14px; }

/* auth */
.auth { position: fixed; z-index: 700; inset: calc(var(--bar) + env(safe-area-inset-top)) 0 0 0; overflow-y: auto; padding: 18px 14px 28px; background: linear-gradient(90deg, rgba(11, 13, 17, .92) 0, rgba(11, 13, 17, .55) 560px, rgba(11, 13, 17, .1) 900px); }
@media (max-width: 759px) { .auth { background: rgba(11, 13, 17, .6); } }
@media (min-width: 760px) { .auth { padding: 40px 48px; } }
.auth-card { max-width: 440px; background: rgba(18, 20, 25, .96); border: 1px solid var(--line); border-radius: 22px; padding: 24px 20px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7); }
@media (min-width: 760px) { .auth-card { padding: 32px 30px; } }
.auth h1 { margin: 0; font-size: clamp(30px, 7vw, 42px); line-height: 1.02; font-weight: 900; letter-spacing: -.02em; }
.auth h1 span { color: var(--orange); }
.auth-sub { color: var(--muted); margin: 10px 0 18px; }
.tabs, .ltabs { display: grid; grid-template-columns: 1fr 1fr; background: #0d0f13; border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs button, .ltabs button { border: 0; background: transparent; border-radius: 9px; padding: 9px; font-weight: 800; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"], .ltabs button[aria-selected="true"] { background: #23272f; color: #fff; }
.af { display: grid; gap: 12px; }
.af label { display: grid; gap: 5px; font-size: 13px; font-weight: 700; color: #c9ccd2; }
.af small { font-weight: 500; color: var(--muted); }
.af input:not([type=checkbox]) { width: 100%; min-width: 0; height: 48px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .16); background: #0f1115; padding: 0 13px; font-size: 16px; font-weight: 600; color-scheme: dark; }
.af input:focus { border-color: var(--orange); outline: none; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.af .check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--orange); flex: none; margin: 0; }
.demo-note { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }
.demo-note b { color: var(--ink); }

/* side list */
.side {
  position: fixed; z-index: 650; left: 0; right: 0; bottom: 0; height: 46vh; height: 46svh; display: flex; flex-direction: column;
  background: rgba(18, 20, 25, .97); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; box-shadow: 0 -20px 40px rgba(0, 0, 0, .45);
}
@media (min-width: 900px) {
  .side { left: 14px; top: calc(var(--bar) + 14px); bottom: 14px; right: auto; width: 380px; height: auto; border: 1px solid var(--line); border-radius: 20px; }
}
.side-h { padding: 16px 16px 4px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.kpis div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; }
.kpis b { display: block; font-size: 22px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.kpis span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.2; }
.search { width: 100%; height: 42px; border-radius: 11px; border: 1px solid rgba(255, 255, 255, .14); background: #0f1115; padding: 0 12px; font-size: 16px; margin-bottom: 10px; color-scheme: dark; }
.ltabs { margin-bottom: 6px; }
.ships { scrollbar-width: thin; scrollbar-color: #3a3f47 transparent; list-style: none; margin: 0; padding: 4px 10px 16px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.ship { width: 100%; text-align: left; display: grid; gap: 5px; padding: 12px; margin-top: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.ship:hover { border-color: rgba(255, 255, 255, .25); }
.ship[aria-current="true"] { border-color: var(--orange); background: rgba(255, 90, 31, .08); }
.ship-t { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ship-id { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ship-lane { font-weight: 800; font-size: 15.5px; }
.ship-sub { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.ship-sub b { color: var(--ink); font-weight: 700; }
.bar { height: 5px; background: #2a2e36; border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--amber)); width: 0; }
.chip { font-family: var(--mono); font-size: 10.5px; font-weight: 700; padding: 4px 8px; border-radius: 999px; white-space: nowrap; background: #23272f; color: #cfd2d8; }
.chip.c-move { background: rgba(245, 177, 0, .15); color: var(--amber); }
.chip.c-stop { background: rgba(80, 150, 255, .15); color: #7fb2ff; }
.chip.c-done { background: rgba(72, 224, 127, .13); color: var(--green); }
.empty { color: var(--muted); font-size: 14px; padding: 18px 6px; }

/* phone: the sheet scrolls as one piece, peeks at the first load, and pulls up to full height */
.grab { display: none; }
@media (max-width: 899px) {
  .side { height: 50vh; height: 50svh; overflow-y: auto; overscroll-behavior: contain; transition: height .3s cubic-bezier(.2, .8, .2, 1); scrollbar-width: none; }
  .side.full { height: calc(100vh - var(--bar) - 10px); height: calc(100svh - var(--bar) - env(safe-area-inset-top) - 10px); }
  .side::-webkit-scrollbar { display: none; }
  .grab { position: sticky; top: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; flex: none; border: 0; padding: 8px 0 6px; background: #121419; box-shadow: 0 8px 10px -6px #121419; border-radius: 20px 20px 0 0; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 700; touch-action: none; }
  .grab i { width: 42px; height: 5px; border-radius: 5px; background: #4a505a; }
  .side-h { padding: 0 14px 0; }
  .side .kick { margin-bottom: 8px; }
  .kpis { gap: 6px; margin-bottom: 10px; }
  .kpis div { padding: 7px 9px; border-radius: 10px; }
  .kpis b { font-size: 18px; }
  .kpis span { font-size: 11px; margin-top: 3px; white-space: nowrap; }
  .find { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .find .search { margin: 0; height: 44px; font-size: 16px; }
  .find .ltabs { margin: 0; padding: 3px; }
  .find .ltabs button { padding: 6px 4px; font-size: 13.5px; }
  .ships { overflow: visible; flex: none; padding: 0 10px calc(20px + env(safe-area-inset-bottom)); }
  .ship { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* detail */
.detail {
  position: fixed; z-index: 680; left: 0; right: 0; bottom: 0; max-height: 72vh; max-height: 72svh; overflow-y: auto;
  background: rgba(18, 20, 25, .98); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 40px rgba(0, 0, 0, .5); overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #3a3f47 transparent;
}
@media (min-width: 900px) {
  .detail { left: auto; right: 14px; top: calc(var(--bar) + 66px); bottom: auto; width: 380px; max-height: calc(100vh - var(--bar) - 84px); border: 1px solid var(--line); border-radius: 20px; }
}
.x { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #23272f; font-size: 22px; line-height: 1; cursor: pointer; }
.d-id { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 0; }
.d-lane { margin: 2px 40px 0 0; font-size: 22px; font-weight: 900; line-height: 1.15; }
.d-where { margin: 6px 0 0; color: #c9ccd2; font-size: 14.5px; }
.d-live { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.d-live div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; }
.d-live b { display: block; font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.05; }
.d-live span { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.d-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 13.5px; }
.d-meta dt { color: var(--muted); font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.d-meta dd { margin: 0 0 4px; font-weight: 700; }
.steps { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 9px; }
.steps li { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: baseline; font-size: 14px; color: var(--muted); }
.steps li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #4a505a; align-self: center; }
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--orange); border-color: var(--orange); }
.steps li.now::before { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 4px rgba(245, 177, 0, .2); }
.steps time { font-family: var(--mono); font-size: 11.5px; }
.d-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.d-acts .btn { min-height: 44px; font-size: 14px; padding: 0 10px; }
.d-acts .btn[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); }
.toast { position: fixed; z-index: 1200; left: 50%; bottom: 24px; transform: translateX(-50%); background: #fff; color: #16181c; font-weight: 800; padding: 10px 16px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  .trk, .trk-i svg { transition: none !important; }
  .dot, .trk-i.sel::before { animation: none; }
}
@media (max-width: 899px) { .leaflet-control-zoom { display: none; } }
