/* Jinhui Fleet Dashboard — dark marine-ops theme.
   Status colors from the validated dark-mode data-viz palette. */
:root {
  --bg:            #05070c;
  --surface-1:     #0d121c;
  --surface-2:     #121a28;
  --surface-3:     #182233;
  --line:          #1e2c40;
  --line-soft:     #16202f;
  --ink:           #eef3fb;
  --ink-2:         #a9b6c9;
  --ink-3:         #6c7c93;
  --accent:        #3d8bf5;   /* marine blue */
  --accent-soft:   #6da7ec;

  --s-underway:    #2fd08a;   /* teal-green */
  --s-port:        #3d8bf5;   /* blue */
  --s-stale:       #f5b73d;   /* amber */
  --s-nosig:       #e5636b;   /* red */

  --sidebar-w: 388px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; width: 100vw; }

/* ---------------- GLOBE PANE ---------------- */
#globe-pane {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background:
    radial-gradient(120% 120% at 30% 20%, #0a1526 0%, #05070c 55%, #03040a 100%);
  overflow: hidden;
}
#globe { position: absolute; inset: 0; }
#globe canvas { display: block; }

#globe-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  padding: 22px 26px;
  display: flex; flex-direction: column;
}
#brand { pointer-events: none; }
.brand-mark {
  font-size: 26px; font-weight: 800; letter-spacing: .22em;
  color: var(--ink);
  text-shadow: 0 2px 24px rgba(0,0,0,.7);
}
.brand-sub {
  margin-top: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .28em;
  color: var(--ink-3);
}

/* focus card — floats over globe when a vessel is selected */
#focus-card {
  pointer-events: auto;
  margin-top: auto;
  align-self: flex-start;
  max-width: 340px;
  background: rgba(9,14,23,.82);
  backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  transform: translateY(0);
  transition: opacity .3s, transform .3s;
}
#focus-card.hidden { opacity: 0; transform: translateY(12px); pointer-events: none; }
.fc-photo { width: 100%; height: 148px; object-fit: cover; display: block; background: var(--surface-2); }
.fc-body { padding: 14px 16px 16px; }
.fc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.fc-name { font-size: 19px; font-weight: 750; letter-spacing: .02em; }
.fc-flag { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.fc-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }
.fc-route { margin: 12px 0 4px; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.fc-route b { color: var(--ink); font-weight: 650; }
.fc-arrow { color: var(--accent-soft); }
.fc-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 12px; }
.fc-m .m-v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fc-m .m-l { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; margin-top: 1px; }

/* progress bar */
.prog { margin-top: 14px; }
.prog-track { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; position: relative; }
.prog-fill { height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--s-underway), var(--accent-soft)); }
.prog-meta { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10.5px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; }

/* globe controls */
#globe-controls { position: absolute; right: 18px; top: 18px; display: flex; gap: 8px; }
.gctl {
  pointer-events: auto;
  font: 600 12px var(--font);
  color: var(--ink-2);
  background: rgba(12,18,28,.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 11px; cursor: pointer;
  transition: all .15s;
}
.gctl:hover { color: var(--ink); border-color: var(--accent); background: rgba(18,26,40,.85); }
.gctl.active { color: var(--accent); border-color: rgba(61,139,245,.5); }

#legend {
  position: absolute; left: 22px; bottom: 18px;
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 11px; color: var(--ink-2);
  background: rgba(9,14,23,.6); backdrop-filter: blur(8px);
  border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 13px;
}
#legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }
.dot.s-underway { background: var(--s-underway); color: var(--s-underway); }
.dot.s-port     { background: var(--s-port);     color: var(--s-port); }
.dot.s-stale    { background: var(--s-stale);    color: var(--s-stale); }
.dot.s-nosig    { background: var(--s-nosig);    color: var(--s-nosig); }

#loading {
  position: absolute; inset: 0; display: flex; gap: 14px;
  align-items: center; justify-content: center;
  background: var(--bg); color: var(--ink-2); font-size: 14px; z-index: 20;
  transition: opacity .5s;
}
#loading.gone { opacity: 0; pointer-events: none; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- SIDEBAR ---------------- */
#sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  background: var(--surface-1);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}
#side-head { padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.head-row { display: flex; align-items: baseline; justify-content: space-between; }
#side-head h1 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: .04em; }
#updated { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
#updated .live { color: var(--s-underway); }

#stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 9px 6px; text-align: center; }
.stat-v { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.stat-l { font-size: 9.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-top: 5px; }
.s-underway-t { color: var(--s-underway); }
.s-port-t { color: var(--s-port); }
.s-stale-t { color: var(--s-stale); }

#tools { margin-top: 14px; }
#search {
  width: 100%; font: 500 13px var(--font); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 12px; outline: none;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--ink-3); }
#filters { display: flex; gap: 6px; margin-top: 10px; }
.chip {
  font: 600 11.5px var(--font); color: var(--ink-3);
  background: transparent; border: 1px solid var(--line);
  border-radius: 20px; padding: 5px 13px; cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--ink-2); }
.chip.active { color: var(--ink); background: var(--surface-3); border-color: var(--accent); }

/* vessel list */
#list { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 6px 8px 12px; }
#list::-webkit-scrollbar { width: 9px; }
#list::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 6px; border: 2px solid var(--surface-1); }
#list::-webkit-scrollbar-thumb:hover { background: #23324a; }

.v-row {
  position: relative;
  border-radius: 11px;
  padding: 11px 12px 11px 14px;
  margin: 3px 0;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .13s, border-color .13s;
}
.v-row:hover { background: var(--surface-2); }
.v-row.sel { background: var(--surface-2); border-color: var(--accent); }
.v-row::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px;
  border-radius: 3px; background: var(--rowc, var(--ink-3));
}
.v-main { display: flex; align-items: center; gap: 9px; }
.v-name { font-size: 14px; font-weight: 650; letter-spacing: .01em; flex: 0 0 auto; }
.v-tag { font-size: 9px; font-weight: 700; padding: 1.5px 5px; border-radius: 5px; letter-spacing: .05em;
  color: var(--ink-3); background: var(--surface-3); text-transform: uppercase; }
.v-eta { margin-left: auto; font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.v-eta.overdue { color: var(--s-stale); }
.v-route { margin-top: 5px; font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-route .arr { color: var(--accent-soft); flex: 0 0 auto; }
.v-route .p { overflow: hidden; text-overflow: ellipsis; }
.v-bar { margin-top: 8px; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.v-bar > i { display: block; height: 100%; background: var(--rowc, var(--accent)); border-radius: 3px; }

/* inline expanded detail */
.v-detail { max-height: 0; overflow: hidden; transition: max-height .28s ease; }
.v-row.sel .v-detail { max-height: 460px; }
.det-inner { padding: 12px 2px 4px; border-top: 1px solid var(--line-soft); margin-top: 11px; }
.det-photo { width: 100%; height: 118px; object-fit: cover; border-radius: 9px; background: var(--surface-3); display: block; }
.det-photo.none { display: none; }
.det-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; margin-top: 12px; }
.det-k { font-size: 9.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.det-v { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; }
.det-v.small { font-size: 12px; font-weight: 550; }
.det-leg { margin-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.leg-item { display: flex; gap: 10px; align-items: flex-start; }
.leg-ic { flex: 0 0 auto; width: 16px; text-align: center; font-size: 13px; margin-top: 1px; }
.leg-txt .t1 { font-size: 12.5px; font-weight: 600; }
.leg-txt .t2 { font-size: 10.5px; color: var(--ink-3); margin-top: 1px; font-variant-numeric: tabular-nums; }
.det-note { margin-top: 11px; font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }

#side-foot { padding: 9px 16px; border-top: 1px solid var(--line); }
#foot-note { font-size: 10px; color: var(--ink-3); line-height: 1.4; }

.empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 40px 12px; }

/* Vessel HTML marker on globe */
.ship-marker { position: relative; cursor: pointer; pointer-events: auto; transform: translate(-50%, -50%); }
.ship-tri {
  width: 0; height: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 13px solid var(--mk, #fff);
  filter: drop-shadow(0 0 4px var(--mk, #fff));
  transition: transform .2s;
}
.ship-marker .halo {
  position: absolute; left: 50%; top: 55%; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; border: 1.5px solid var(--mk, #fff); opacity: 0; transform: scale(.4);
}
.ship-marker.on .halo { animation: ping 1.6s ease-out infinite; }
@keyframes ping { 0% { opacity: .8; transform: scale(.4);} 100% { opacity: 0; transform: scale(1.5);} }
.ship-marker.on .ship-tri { transform: scale(1.55); }
.ship-label {
  position: absolute; left: 50%; top: -6px; transform: translate(-50%, -100%);
  white-space: nowrap; font: 700 10px var(--font); letter-spacing: .04em;
  color: var(--ink); background: rgba(6,10,18,.82); padding: 2px 6px; border-radius: 5px;
  border: 1px solid var(--line); opacity: 0; transition: opacity .15s; pointer-events: none;
}
.ship-marker:hover .ship-label, .ship-marker.on .ship-label { opacity: 1; }

/* ---------------- responsive ---------------- */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #globe-pane { flex: 0 0 46vh; }
  #sidebar { flex: 1 1 auto; width: 100%; border-left: none; border-top: 1px solid var(--line); }
  #brand .brand-sub { display: none; }
  #legend { font-size: 10px; gap: 10px; padding: 6px 10px; }
  #focus-card { display: none; }   /* sidebar detail carries this on mobile */
}
