/* teslimat — Flow's design language (owner 09-24): Flow's palette and type,
   3px corners on every element, thin translucent borders, the house focus
   ring. Values are copied from Flow's tokens (public/vendor/flow/css/tokens.css
   and flow-core.css) because this page is a separate app; keep them in step. */
:root {
  --primary: #003c91;
  --primary-hover: #0047ab;
  --primary-lt: #e4ecfa;
  --primary-rgb: 0, 60, 145;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: rgba(4, 32, 69, .1);
  --input-line: rgba(4, 32, 69, .18);
  --page: #f9fafb;
  --surface: #ffffff;
  --success: #1f9d55;
  --success-lt: #e3f5e8;
  --success-dark: #166534;
  --danger: #dc2626;
  --danger-lt: #fde8e8;
  --danger-dark: #991b1b;
  --radius: 3px;
  --shadow: 0 1px 2px rgba(4, 32, 69, .06), 0 4px 14px rgba(4, 32, 69, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px; color: var(--ink); background: var(--page);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
#map { position: fixed; inset: 0; z-index: 0; }

/* Brand card — top left: HSR (owner) | Flow (app) + title */
.brand {
  position: fixed; z-index: 500; top: max(12px, env(safe-area-inset-top)); left: 12px;
  max-width: calc(100% - 76px);
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px 12px;
}
.brand-owner { height: 22px; width: auto; display: block; }
.brand-sep { width: 1px; align-self: stretch; background: var(--line); }
.brand-app { width: 20px; height: 20px; display: block; flex: 0 0 auto; }
.brand-title { font-weight: 700; font-size: 14px; line-height: 1.2; color: var(--primary); white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Map buttons — top right */
.map-tools {
  position: fixed; z-index: 500; top: max(12px, env(safe-area-inset-top)); right: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.map-tools button {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; color: var(--primary); padding: 0;
}
.map-tools button:hover { background: var(--primary-lt); }
.map-tools button:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .15); }
.map-tools svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.map-tools button[hidden] { display: none; }

/* Sheet — bottom on phones, left panel on wide screens */
.sheet {
  position: fixed; z-index: 600; left: 0; right: 0; bottom: 0;
  max-height: 72vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-top: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 18px rgba(4, 32, 69, .12);
  padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
  transition: transform .25s ease;
}
.sheet.collapsed { transform: translateY(calc(100% - 190px)); overflow: hidden; }
.sheet-grip {
  display: block; width: 100%; height: 20px; border: 0; background: none; cursor: pointer; position: relative;
}
.sheet-grip::after {
  content: ""; position: absolute; left: 50%; top: 8px; width: 36px; height: 4px; margin-left: -18px;
  border-radius: var(--radius); background: rgba(4, 32, 69, .18);
}
@media (min-width: 900px) {
  .sheet {
    left: 12px; right: auto; top: 72px; bottom: auto; width: 360px; max-height: calc(100vh - 84px);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding-top: 16px;
  }
  .sheet.collapsed { transform: none; overflow-y: auto; }
  .sheet-grip { display: none; }
}

/* Status badge — Flow's .badge: 3px corners, tinted background */
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  padding: 4px 8px; border-radius: var(--radius); background: var(--primary-lt); color: var(--primary);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blink 1.6s infinite; }
.status.done { background: var(--success-lt); color: var(--success-dark); }
.status.done::before { animation: none; }
@keyframes blink { 50% { opacity: .25; } }
.updated { font-size: 12px; color: var(--muted); }

.eta { margin-top: 12px; }
.eta-label { font-size: 12px; color: var(--muted); }
.eta-time { font-size: 30px; font-weight: 700; letter-spacing: -.5px; line-height: 1.15; color: var(--ink); }
.eta-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.progress { height: 6px; border-radius: var(--radius); background: var(--primary-lt); margin-top: 14px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: var(--radius); transition: width .6s ease; }
.progress-text { font-size: 12px; color: var(--muted); margin-top: 6px; }

.vehicle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
}
.vehicle .k { font-size: 12px; color: var(--muted); }
.vehicle .v { font-size: 14px; font-weight: 600; margin-top: 2px; }

.stops { list-style: none; margin: 14px 0 0; padding: 0; position: relative; }
.stops li { position: relative; display: flex; gap: 12px; padding: 0 0 14px; }
.stops li:not(:last-child)::before {
  content: ""; position: absolute; left: 11px; top: 22px; bottom: 0; width: 2px; background: rgba(var(--primary-rgb), .2);
}
.stops .dot {
  flex: 0 0 24px; height: 24px; border-radius: 50%; border: 2px solid var(--primary); background: var(--surface);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--primary); position: relative; z-index: 1;
}
.stops li.done .dot { background: var(--primary); color: #fff; }
.stops li.mine .dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 5px rgba(var(--primary-rgb), .18); }
.stops .name { font-size: 14px; font-weight: 500; line-height: 24px; }
.stops li.done .name { color: var(--muted); }
.stops .meta { font-size: 12px; color: var(--muted); }
.stops li.mine .card {
  flex: 1; margin: -4px 0 0; padding: 8px 10px; border-radius: var(--radius);
  background: var(--primary-lt); border: 1px solid rgba(var(--primary-rgb), .15);
}
.stops li.mine .name { font-weight: 700; color: var(--primary); line-height: 1.35; }
.tag { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--primary); margin-bottom: 2px; }
.stops li.solo .dot { display: none; }
.stops li.solo .card { margin: 0; }

.foot { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.45; }

/* Map markers */
.stop-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--primary); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.stop-dot.depot { background: #fff; border-color: var(--primary); }
.mine-dot { position: relative; width: 26px; height: 26px; }
.mine-dot::before {
  content: ""; position: absolute; inset: -12px; border-radius: 50%; background: rgba(var(--primary-rgb), .22);
  animation: halo 1.8s ease-out infinite;
}
.mine-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--primary);
  border: 4px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
@keyframes halo { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
.truck {
  width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 3px solid var(--primary);
  box-shadow: 0 3px 10px rgba(0,0,0,.35); display: grid; place-items: center;
}
.truck svg { width: 22px; height: 22px; }
.leaflet-tooltip.mine-label {
  background: var(--primary); color: #fff; border: 0; border-radius: var(--radius); font-weight: 600; font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); padding: 5px 8px; line-height: 1.3; text-align: center;
}
.leaflet-tooltip.mine-label small { display: block; font-size: 10px; font-weight: 500; letter-spacing: .04em; opacity: .8; }
.leaflet-tooltip.mine-label::before { border-top-color: var(--primary); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-container { font-family: inherit; }
@media (max-width: 899px) { .leaflet-bottom { bottom: 190px; } }

/* Lookup — the bare hostname (FL-471), laid out like Flow's sign-in page:
   HSR (owner) above, a card headed by the Flow mark (app). */
.lookup {
  position: fixed; inset: 0; z-index: 2000; overflow-y: auto;
  display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: rgba(249, 250, 251, .94);
}
.lookup[hidden] { display: none; }
.lookup-col { width: 100%; max-width: 400px; }
.lookup-owner { text-align: center; margin-bottom: 20px; }
.owner-logo {
  height: 76px; width: auto; padding: 8px; background: #fff;
  border: 3px solid var(--line); border-radius: 12px;   /* Flow's .login-logo frame */
}
.lookup-owner p { margin: 12px 0 0; font-size: 14px; font-weight: 700; color: var(--muted); }
.lookup-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0 4px rgba(31, 41, 55, .04);
}
.lookup-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.lookup-head img { width: 22px; height: 22px; display: block; }
.lookup-head h1 { font-size: 16px; font-weight: 700; color: var(--primary); margin: 0; }
.lookup-body { padding: 16px; display: flex; flex-direction: column; }
.lookup-intro { font-size: 13px; color: var(--muted); margin: 0 0 4px; line-height: 1.45; }
.lookup-card label { font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.lookup-card input {
  font: inherit; font-size: 16px; line-height: 20px; padding: 9px 12px; color: var(--ink);
  background: #fff; border: 1px solid var(--input-line); border-radius: var(--radius); outline: none;
}
.lookup-card input::placeholder { color: #9ca3af; }
.lookup-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .15); }
.lookup-card input.invalid { border-color: var(--danger); }
.lookup-card input.invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
.lookup-error {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--radius); font-size: 13px; line-height: 1.4;
  background: var(--danger-lt); color: var(--danger-dark);
}
.lookup-card button {
  margin-top: 18px; font: inherit; font-size: 14px; font-weight: 600; color: #fff; background: var(--primary);
  border: 1px solid var(--primary); border-radius: var(--radius); padding: 10px 14px; cursor: pointer;
}
.lookup-card button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.lookup-card button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .15); }
.lookup-card button:disabled { opacity: .6; cursor: default; }
.lookup-note { font-size: 12px; color: var(--muted); text-align: center; margin: 12px 0 0; }
body.is-lookup .brand, body.is-lookup .map-tools, body.is-lookup .sheet { display: none; }
