/* The Tracker (index.html) and the shared Tracker (share/index.html). */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--ink); display: flex; flex-direction: column;
       -webkit-font-smoothing: antialiased; }
header { background: var(--panel); border-bottom: 1px solid var(--line);
         padding: 12px 20px; display: flex;
         align-items: center; flex-wrap: wrap; gap: 8px; }
header h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: -.01em;
            display: flex; align-items: center; gap: 8px; }
header h1 a { color: inherit; text-decoration: none;
              display: flex; align-items: center; gap: 8px; }
header h1 .logo { width: 22px; height: 22px; }
.mainnav { display: flex; gap: 16px; font-size: 13px; margin-left: 10px; margin-right: auto; }
.mainnav a { color: var(--muted); text-decoration: none; padding: 4px 2px; }
.mainnav a.active { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--ink); }
.mainnav a.gear svg { width: 14px; height: 14px; vertical-align: -2px; }
.mainnav a.gear:hover { color: var(--ink); }
.mainnav .count { background: var(--alert); color: var(--on-dark); border-radius: 999px;
                  font-size: 10px; font-weight: 600; padding: 1px 6px; margin-left: 4px; }
header .right { display: flex; align-items: center; gap: 14px; }
header .sub { font-size: 12px; color: var(--muted); }
#addDocBtn, #addBtn, #shareBtn { background: var(--accent); color: var(--on-dark); border: none; border-radius: 8px;
          padding: 7px 14px; font-size: 12.5px; font-weight: 500; cursor: pointer;
          font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
#addDocBtn:hover, #addBtn:hover, #shareBtn:hover { opacity: .85; }
/* ---- share dialog ---- */
.modal .share-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0 0 6px; }
.modal .share-note b { color: var(--ink); font-weight: 600; }
.modal #s-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; margin-top: 8px; }
.doc-note { font-size: 12px; color: var(--muted); max-width: 240px; }
/* ---- add-shipment modal ---- */
.modal-back { display: none; position: fixed; inset: 0; background: var(--scrim);
              z-index: 5000; align-items: center; justify-content: center; }
.modal-back.open { display: flex; }
.modal { background: var(--panel); border-radius: 14px; padding: 22px; width: 380px; max-width: 92vw;
         box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal h2 { margin: 0 0 14px; font-size: 15px; }
.modal label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted);
               text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 3px; }
.modal input, .modal select { width: 100%; padding: 8px 10px; border: 1px solid var(--line);
               border-radius: 8px; font-family: inherit; font-size: 13px; background: var(--panel); }
.modal .row2 { display: flex; gap: 10px; }
.modal .row2 > div { flex: 1; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal .actions button { padding: 8px 16px; border-radius: 8px; font-family: inherit;
                         font-size: 13px; font-weight: 500; cursor: pointer; border: none; }
.modal .cancel { background: var(--hover); color: var(--ink); }
.modal .submit { background: var(--accent); color: var(--on-dark); }
.modal .err { color: var(--alert); font-size: 12px; margin-top: 8px; min-height: 16px; }

.layout { flex: 1; display: flex; min-height: 0; gap: 14px; padding: 14px; }
/* ---- left: shipment list panel ---- */
.sidebar { width: 400px; min-width: 330px; overflow-y: auto; background: var(--panel);
           border: 1px solid var(--line); border-radius: 14px;
           box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.summary { padding: 14px 16px 10px; display: flex; gap: 8px; align-items: center;
           position: sticky; top: 0; background: var(--panel); z-index: 5;
           border-bottom: 1px solid var(--line); }
.summary .pills { display: flex; gap: 6px; margin-left: auto; }
/* In transit / Collected: the Documents Cards/List control, with text */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--panel); color: var(--muted); font: inherit;
              font-size: 12px; padding: 5px 10px; cursor: pointer; display: flex;
              align-items: center; gap: 5px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--hover); color: var(--ink); }
.seg .n { color: var(--muted); font-size: 11px; }
.list-empty { padding: 18px 16px; font-size: 12.5px; color: var(--muted); }
.list-empty a { color: inherit; }
.pill { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pill.total { background: var(--hover); color: var(--ink); }
.pill.alert { background: var(--alert-bg); color: var(--alert-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.vessel-group { padding: 14px 16px 4px; font-size: 10.5px; font-weight: 600;
                text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.row { margin: 2px 8px; padding: 10px 10px; border-radius: 10px; cursor: pointer; }
.row:hover { background: var(--hover); }
.row.open { background: var(--hover); }
.row-line { display: flex; align-items: center; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); }
.dot.alert { background: var(--alert); }
.row-ref { font-weight: 600; font-size: 13.5px; flex: 1; letter-spacing: -.01em; }
.row-eta { font-size: 12px; font-weight: 600; flex: none; }
.row-eta .link-quiet { font-weight: 500; }
.row-sub { display: flex; gap: 8px; margin: 3px 0 0 18px; font-size: 12px; color: var(--muted); }
.row-sub .where { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub .updated { flex: none; font-size: 11px; }

/* ---- expanded card ---- */
.detail { display: none; margin: 12px 0 4px 18px; font-size: 12.5px; }
.row.open .detail { display: block; }
.ai-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px;
            font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
            background: linear-gradient(135deg, var(--ai-from), var(--ai-to));
            -webkit-background-clip: text; background-clip: text; color: transparent;
            margin-bottom: 5px; }
.ai-badge svg { width: 13px; height: 13px; stroke: var(--ai-from); }
.read { background: var(--ai-bg); border: 1px solid var(--ai-line);
        border-radius: 10px; padding: 10px 12px; }
.read .story { font-size: 12.5px; line-height: 1.55; }
.flag { font-size: 12px; padding: 6px 9px; border-radius: 8px; margin: 6px 0 0; line-height: 1.4; }
.flag.warn { background: var(--warn-bg); color: var(--warn-ink); }
.flag.alert { background: var(--alert-bg); color: var(--alert-ink); }
.flag.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flag.none { background: var(--hover); color: var(--muted); }
.section-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase;
                 letter-spacing: .08em; color: var(--muted); margin: 14px 0 4px;
                 display: flex; justify-content: space-between; align-items: baseline; }
.section-label .log-check { font-weight: 500; text-transform: none; letter-spacing: 0;
                            color: var(--link); text-decoration: none; font-size: 11.5px; }
.section-label .log-check:hover { text-decoration: underline; }
.modal textarea { width: 100%; min-height: 100px; padding: 8px 10px; border: 1px solid var(--line);
                  border-radius: 8px; font-family: inherit; font-size: 12.5px; resize: vertical; }
.modal input[type="file"] { padding: 6px; font-size: 12px; }
.modal .preview { background: var(--ai-bg); border: 1px solid var(--ai-line); border-radius: 8px;
                  padding: 8px 10px; font-size: 12.5px; margin-top: 10px; display: none; }
table.src { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.src td { padding: 5px 8px 5px 0; vertical-align: top; }
table.src .src-name { color: var(--muted); white-space: nowrap; width: 1%; padding-right: 14px; }
table.src .src-name a { color: var(--link); text-decoration: none; font-weight: 500; }
table.src .src-name a:hover { text-decoration: underline; }
table.src .src-name .log-check { margin-left: 2px; }
table.src .src-links { margin-top: 2px; }
table.src .src-age .log-check { color: var(--link); text-decoration: none; font-weight: 500; font-size: 12px; }
table.src .src-age .log-check:hover { text-decoration: underline; }
table.src .src-age { color: var(--muted); text-align: right; white-space: nowrap;
                     width: 1%; font-size: 11.5px; }
table.src .src-age.stale { color: var(--alert); font-weight: 600; }
table.src .late { color: var(--alert); font-weight: 600; }
table.src .early { color: var(--ok); font-weight: 600; }
table.sched tr.booked td { color: var(--ink); font-weight: 600; }
.section-label .sched-src { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11px; }
details.more { margin-top: 10px; }
details.more summary { font-size: 12.5px; color: var(--muted); cursor: pointer;
                       list-style: none; display: flex; align-items: center; gap: 5px; }
details.more summary .edit-ship { margin-left: auto; color: var(--muted); font-size: 11.5px;
                                  text-decoration: none; display: inline-flex;
                                  align-items: center; gap: 4px; }
details.more summary .edit-ship svg { width: 11px; height: 11px; }
details.more summary .edit-ship:hover { color: var(--ink); text-decoration: underline; }
details.more summary .archive-ship, details.more summary .docs-ship {
                                     margin-left: 12px; color: var(--muted); font-size: 11.5px;
                                     text-decoration: none; display: inline-flex;
                                     align-items: center; gap: 4px; }
details.more summary .archive-ship svg, details.more summary .docs-ship svg { width: 11px; height: 11px; }
details.more summary .archive-ship:hover, details.more summary .docs-ship:hover {
                                     color: var(--ink); text-decoration: underline; }
details.more summary::before { content: "›"; transition: transform .15s; font-size: 14px; }
details.more[open] summary::before { transform: rotate(90deg); }
details.more .more-body { padding: 8px 0 0 14px; font-size: 12.5px; color: var(--ink); }
details.more .more-body div { padding: 2px 0; }
details.more .more-body .lbl { color: var(--muted); }
.bol { display: inline-flex; align-items: center; gap: 4px;
       user-select: text; cursor: copy; }
.bol .copy { display: none; width: 13px; height: 13px; padding: 0; border: none;
             background: none; color: var(--muted); cursor: pointer; }
.bol:hover .copy, .bol.copied .copy { display: block; }
.bol .copy svg { width: 13px; height: 13px; stroke: currentColor; display: block; }
.bol .copy .done { display: none; }
.bol.copied .copy .idle { display: none; }
.bol.copied .copy .done { display: block; color: var(--ok); }
details.more a { color: var(--link); text-decoration: none; }
details.more a:hover { text-decoration: underline; }

/* ---- right: map panel ---- */
.map-wrap { flex: 1; min-width: 0; border-radius: 14px; overflow: hidden;
            border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.05); }
#map { height: 100%; width: 100%; background: var(--canvas); }
.vessel-label { font-size: 11px; font-weight: 600; font-family: Inter, sans-serif; }
/* map markers: colour = the list dot's level; hollow = position is old */
.mk-wrap { background: none; border: none; }
.mk, .chev { --c: var(--ok); }
.mk.warn, .chev.warn, .legend i.warn { --c: var(--warn); }
.mk.alert, .chev.alert, .legend i.alert { --c: var(--alert); }
.mk { position: relative; width: 100%; height: 100%;
      display: flex; align-items: center; justify-content: center; }
.mk.dot::before { content: ""; width: 13px; height: 13px; border-radius: 50%;
                  background: var(--c); border: 2.5px solid var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.mk.dot.stale::before { background: var(--panel); border-color: var(--c); }
.mk.ship svg { width: 22px; height: 22px; fill: var(--c); stroke: var(--panel); stroke-width: 1.6;
               stroke-linejoin: round; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.35)); }
.mk.ship.stale svg { fill: var(--panel); stroke: var(--c); stroke-width: 2; }
.mk.port { border-radius: 6px; background: var(--c); color: var(--on-dark); font-size: 11px; font-weight: 700;
           border: 2px solid var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.chev { width: 100%; height: 100%; }
.chev svg { width: 12px; height: 12px; fill: none; stroke: var(--c); stroke-width: 2;
            stroke-linecap: round; stroke-linejoin: round; }
.mk.sel::after { content: ""; position: absolute; inset: -7px; border-radius: 50%;
                 border: 2px solid var(--c); pointer-events: none;
                 animation: mk-pulse 1.6s ease-out infinite; }
.mk.port.sel::after { border-radius: 10px; }
@keyframes mk-pulse { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mk.sel::after { animation: none; opacity: .8; } }
.legend { background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
          padding: 6px 10px; font-size: 11px; color: var(--muted); display: flex; gap: 10px;
          flex-wrap: wrap; font-family: Inter, sans-serif; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
/* status colours are bars, so they don't read as a marker shape */
.legend i { --c: var(--ok); width: 11px; height: 4px; border-radius: 2px; display: inline-block;
            background: var(--c); }
.legend .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }
.legend i.port { width: 9px; height: 9px; border-radius: 3px; background: var(--muted); }
.legend svg.sea { width: 14px; height: 14px; fill: var(--muted); stroke: none; }
/* stale position: a hollow ship. The map keeps the shipment's colour; the legend is grey. */
.legend svg.stale { width: 14px; height: 14px; fill: var(--panel); stroke: var(--muted); stroke-width: 2;
                    stroke-linejoin: round; }
.legend i.dest { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); border: none; }
.mk.dest::before { content: ""; width: 10px; height: 10px; border-radius: 50%;
                   background: var(--muted); border: 2.5px solid var(--panel); }
.dest-label { color: var(--muted); }
.leaflet-tooltip { border-radius: 8px; border: 1px solid var(--line);
                   box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.leaflet-popup-content-wrapper { border-radius: 10px; font-family: Inter, sans-serif; }

.list-toggle { display: none; }
@media (max-width: 760px) {
  body { height: auto; }
  .layout { flex-direction: column; padding: 8px; gap: 8px; }
  .map-wrap { order: 0; height: 44vh; flex: none; }
  .sidebar { order: 1; width: 100%; min-width: 0; flex: none; max-height: none; }
  header { padding: 10px 12px; gap: 8px; }
  header h1 { font-size: 14px; }
  header .right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  header .sub { display: none; }             /* freshness lives in the list on mobile */
  #addBtn { padding: 6px 10px; font-size: 11.5px; }
  /* collapsible list: summary bar is the tap target */
  .list-toggle { display: block; text-align: center; font-size: 11.5px; color: var(--muted);
                 padding: 6px 0 8px; cursor: pointer; user-select: none; }
  .sidebar.collapsed #list { display: none; }
  /* card content: stop bleeding */
  .detail { margin-left: 6px; }
  table.src { table-layout: fixed; }
  table.src .src-name { white-space: normal; width: 32%; padding-right: 8px; }
  table.src td { word-break: break-word; }
  table.src .src-age { font-size: 10.5px; width: 52px; }
  .row-sub .where { white-space: normal; }
}
