/* Shipments (#/shipments), ships map (#/ships) and the client's tracking page (#/track/<token>). Tokens only. */

/* ---------- list ---------- */
.sx-list { display: grid; gap: var(--s3); }
.sx-card {
  display: grid; grid-template-columns: 132px minmax(0, 1fr) auto; gap: var(--s4); align-items: start;
  padding: var(--s3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.sx-photo { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 8px; background: var(--surface-3); color: var(--muted); overflow: hidden; }
.sx-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sx-photo svg { width: 22px; height: 22px; }
.sx-body { display: grid; gap: 6px; min-width: 0; }
.sx-title { font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.sx-title:hover { text-decoration: underline; text-underline-offset: 2px; }
.sx-sub, .sx-ship, .sx-eta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--muted); font-size: var(--fs-sm); }
.sx-sub svg, .sx-ship svg, .sx-eta svg { width: 14px; height: 14px; flex: none; }
.sx-sub .sep { color: var(--border-strong, var(--border)); }
.sx-ship b { color: var(--text); font-weight: 600; }
.sx-actions { display: grid; gap: var(--s2); justify-items: stretch; }
.sx-actions .btn { justify-content: flex-start; }
.sx-done { margin-top: var(--s5); }
.sx-done > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); font-weight: 500; margin-bottom: var(--s3); }
.sx-live-note { margin: 0 0 var(--s3); }

/* ---------- steps ---------- */
.sx-steps { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; margin: 4px 0; padding: 0; list-style: none; counter-reset: none; }
.sx-step { position: relative; display: grid; justify-items: center; text-align: center; min-width: 0; }
.sx-step::before { content: ''; position: absolute; top: 8px; left: calc(-50% + 9px); right: calc(50% + 9px); height: 2px; background: var(--border); }
.sx-step:first-child::before { display: none; }
.sx-step.done::before, .sx-step.cur::before { background: var(--teal); }
.sx-step button { display: grid; justify-items: center; gap: 0; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.sx-step button:hover .sx-step-t { color: var(--text); }
.sx-dot { position: relative; z-index: 1; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); color: #fff; }
.sx-dot svg { width: 11px; height: 11px; stroke-width: 3; }
.sx-step.done .sx-dot { background: var(--teal); border-color: var(--teal); }
.sx-step.cur .sx-dot { border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.sx-step-t { margin-top: 4px; font-size: 11px; line-height: 1.25; color: var(--muted); overflow-wrap: anywhere; }
.sx-step.cur .sx-step-t { color: var(--teal-text); font-weight: 600; }
.sx-step-d { font-size: 10.5px; color: var(--muted); }

/* ---------- one shipment ---------- */
.sx-detail { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: var(--s5); align-items: start; margin-top: var(--s3); }
.sx-side { display: grid; gap: var(--s4); min-width: 0; }
.sx-side .panel-body { display: grid; gap: var(--s3); padding: var(--s4) var(--s5); }
.sx-map-panel { overflow: hidden; position: sticky; top: calc(var(--top-h) + var(--s4)); }
.sx-map { position: relative; height: min(62vh, 560px); background: var(--surface-2); }
.sx-map .maplibregl-canvas:focus-visible, .trk-map .maplibregl-canvas:focus-visible, .shipmap-map .maplibregl-canvas:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.sx-map-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--s2); padding: var(--s6); color: var(--muted); text-align: center; font-size: var(--fs-sm); }
.sx-map-empty svg { width: 24px; height: 24px; }
.sx-map-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: var(--s3) var(--s4); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--muted); }
.sx-map-foot svg { width: 15px; height: 15px; }
.sx-map-foot b { color: var(--text); }
.sx-kv { padding: var(--s4) var(--s5); }
.sx-linkbox input { width: 100%; font-size: var(--fs-sm); }

/* ---------- form ---------- */
.sx-form fieldset { display: grid; gap: var(--s3); margin: 0; padding: var(--s3) 0 0; border: 0; border-top: 1px solid var(--border); }
.sx-form legend { padding: 0 0 var(--s2); font-weight: 600; font-size: var(--fs-sm); color: var(--text); }
.sx-form [hidden], .shipmap [hidden] { display: none !important; }
.sx-shippick { position: relative; }
.sx-shippick input[name='shipQuery'] { width: 100%; }
.sx-shiplist { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md, 8px); box-shadow: var(--shadow-pop); }
.sx-shiplist button { display: grid; gap: 2px; width: 100%; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.sx-shiplist button:hover, .sx-shiplist button:focus-visible { background: var(--surface-2); }
.sx-shiplist button span { color: var(--muted); font-size: var(--fs-xs); }
.sx-shiplist .pk-empty { padding: 10px 12px; color: var(--muted); font-size: var(--fs-sm); }
.sheet-actions { padding-top: var(--s2); }

/* ---------- maps (MapLibre): controls, credit and labels in LotWise's style ---------- */
:root .maplibregl-map { font: inherit; background: var(--surface-2); }
:root .maplibregl-ctrl-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md, 8px); box-shadow: var(--shadow-sm, 0 1px 2px rgba(16, 24, 40, 0.06)) !important; overflow: hidden; }
:root .maplibregl-ctrl-group button { width: 32px; height: 32px; background-color: transparent; }
:root .maplibregl-ctrl-group button + button { border-top: 1px solid var(--border); }
:root .maplibregl-ctrl-group button:hover { background-color: var(--surface-2) !important; }
[data-theme='dark']:root .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(0.85); }
/* The credit OpenStreetMap asks for: a small ⓘ that opens it (it shows at first and folds once the map moves). */
:root .maplibregl-ctrl-attrib.maplibregl-compact { min-height: 22px; margin: 0 8px 8px 0 !important; padding: 2px 26px 2px 8px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface) !important; color: var(--muted); font-size: 10.5px; line-height: 16px; box-shadow: none; }
:root .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) { padding: 0; width: 22px; }
:root .maplibregl-ctrl-attrib a { color: var(--muted); text-decoration: none; }
:root .maplibregl-ctrl-attrib a:hover { color: var(--teal-text); text-decoration: underline; }
:root .maplibregl-ctrl-attrib-button { width: 20px !important; height: 20px !important; top: 0 !important; right: 0 !important; background-color: transparent !important; border-radius: 50%; opacity: 0.55; }
[data-theme='dark']:root .maplibregl-ctrl-attrib-button { filter: invert(0.85); }
:root .maplibregl-ctrl-logo { display: none !important; }
:root .lw-popup .maplibregl-popup-content { padding: 5px 9px; border-radius: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-pop); font-size: var(--fs-xs); font-weight: 500; }
:root .lw-popup .maplibregl-popup-tip { display: none; }

/* ---------- ships map ---------- */
body[data-route='ships'] .page { padding-bottom: 0; }
.shipmap { position: relative; height: calc(100vh - var(--top-h) - 150px); min-height: 420px; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
/* MapLibre makes map containers position: relative; this map fills its frame. */
:root .shipmap-map { position: absolute; inset: 0; }
.shipmap-panel { position: absolute; z-index: 500; top: var(--s3); left: 56px; width: min(340px, calc(100% - 70px)); display: grid; gap: var(--s2); }
.shipmap-search { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.shipmap-search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.shipmap-search input { flex: 1; height: 40px; border: 0; background: none; outline: none; box-shadow: none; font-size: 16px; }
.shipmap-results, .shipmap-info { max-height: 52vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.shipmap-results button { display: grid; gap: 2px; width: 100%; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.shipmap-results button:hover { background: var(--surface-2); }
.shipmap-results button span { color: var(--muted); font-size: var(--fs-xs); }
.shipmap-results p { margin: 0; padding: 10px 12px; }
.shipmap-info { padding: var(--s3) var(--s4); }
.shipmap-info .kv { grid-template-columns: minmax(90px, auto) 1fr; }
.shipmap-info-head { display: flex; align-items: flex-start; gap: var(--s2); margin-bottom: var(--s3); }
.shipmap-info-head > div { display: grid; flex: 1; }
.shipmap-mine { display: grid; gap: 4px; margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.shipmap-status { position: absolute; z-index: 500; right: var(--s3); top: var(--s3); display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; font-size: var(--fs-xs); color: var(--text-2); }
.shipmap-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.shipmap-status .dot.ok { background: var(--success); }
.shipmap-status .dot.warn { background: #e8862a; }
.shipmap-legend { position: absolute; z-index: 500; left: var(--s3); bottom: 22px; display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); font-size: var(--fs-xs); color: var(--text-2); }
.shipmap-legend span { display: inline-flex; align-items: center; gap: 5px; }
.shipmap-legend i { width: 9px; height: 9px; border-radius: 50%; }
.shipmap-legend i.mine { background: var(--teal); border-radius: 2px; transform: rotate(45deg); }

/* ---------- client tracking page ---------- */
#trackRoot { min-height: 100vh; background: var(--bg, var(--surface-2)); }
.trk-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); max-width: 880px; margin: 0 auto; padding: var(--s4); }
.trk-brand { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-md); }
.trk-main { display: grid; gap: var(--s4); max-width: 880px; margin: 0 auto; padding: 0 var(--s4) var(--s10); }
.trk-car { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: var(--s5); align-items: center; }
.trk-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-lg); background: var(--surface-3); }
.trk-car h1 { font-size: 24px; line-height: 1.25; margin: 2px 0 6px; }
.trk-kicker { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.trk-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s2) 0 0; font-size: var(--fs-sm); color: var(--text-2); }
.trk-steps { padding: var(--s4) var(--s3); }
.trk-mapbox { overflow: hidden; }
.trk-map { position: relative; height: min(56vh, 460px); background: var(--surface-2); }
.trk-kv { padding: var(--s4) var(--s5); }
.trk-call { justify-self: start; }
.trk-updated { text-align: center; }

@media (max-width: 1099px) {
  .sx-detail { grid-template-columns: minmax(0, 1fr); }
  .sx-map-panel { position: static; }
}
@media (max-width: 720px) {
  .sx-card { grid-template-columns: 96px minmax(0, 1fr); }
  .sx-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; }
  .sx-step-t { font-size: 10px; }
  .sx-step-d { display: none; }
  .shipmap { height: calc(100vh - var(--top-h) - 170px); border-radius: 0; margin: 0 calc(-1 * var(--s4)); border-left: 0; border-right: 0; }
  .shipmap-panel { left: var(--s3); right: var(--s3); width: auto; top: 52px; }
  .trk-car { grid-template-columns: minmax(0, 1fr); }
  .trk-car h1 { font-size: 20px; }
  .sx-form .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* Overview map above the shipments list, and the estimated-position tooltip */
.sx-overview { overflow: hidden; margin-bottom: var(--s4); }
.sx-map.sx-map-sm { height: min(42vh, 360px); }

/* Container / booking lookup in the form, and the shipping line's events */
.sx-find-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 190px) auto; gap: var(--s2); }
.sx-find-row input[name='trackNumber'] { font-size: 16px; letter-spacing: 0.04em; text-transform: uppercase; }
.sx-found { display: grid; gap: var(--s2); padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); font-size: var(--fs-sm); }
.sx-found.is-loading { display: flex; align-items: center; gap: var(--s2); color: var(--muted); }
.sx-found.ok { border-color: var(--teal); background: var(--teal-soft); }
.sx-found.bad { border-color: var(--danger, #d92d20); color: var(--danger, #d92d20); }
.sx-found-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.sx-found-head svg { width: 16px; height: 16px; color: var(--teal-text); }
.sx-found .kv { grid-template-columns: minmax(90px, auto) 1fr; }
.sx-auto > summary { cursor: pointer; font-weight: 600; font-size: var(--fs-sm); padding: var(--s2) 0; }
.sx-events { display: grid; gap: var(--s2); margin: 0; padding: 0; list-style: none; }
.sx-events li { display: grid; gap: 1px; padding-left: var(--s3); border-left: 2px solid var(--teal); font-size: var(--fs-sm); }
.sx-events li.est { border-left-style: dashed; border-left-color: var(--border-strong, var(--border)); }
.sx-events li span { color: var(--text-2); font-size: var(--fs-xs); }
@media (max-width: 720px) { .sx-find-row { grid-template-columns: minmax(0, 1fr) auto; } .sx-find-row select { grid-column: 1 / -1; grid-row: 2; } }
