:root {
  --bg: #ffffff; --fg: #1d2127; --muted: #66707c; --line: #e3e6ea;
  --cargo: #2563eb; --tanker: #dc2626; --unknown: #9333ea; --other: #16a34a;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color: var(--fg); }
#map { position: absolute; inset: 0; }

.bar {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  padding: 8px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 1px 4px rgb(0 0 0 / .08); max-width: max-content;
}
.bar form { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.bar label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
#count { color: var(--muted); font-variant-numeric: tabular-nums; }
.pill { padding: 1px 8px; border-radius: 99px; background: #f1f3f5; color: var(--muted); font-size: 12px; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.cargo { background: var(--cargo); } .dot.tanker { background: var(--tanker); }
.dot.unknown { background: var(--unknown); } .dot.other { background: var(--other); }
.dot.sat { background: #f59e0b; box-shadow: 0 0 0 1.5px #7c2d12 inset; }
#satMode { font: inherit; font-size: 13px; padding: 1px 4px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
#sat { display: flex; flex-wrap: wrap; gap: 4px 12px; padding-left: 12px; border-left: 1px solid var(--line); }
#sat[hidden] { display: none; }
#satRange { color: var(--muted); font-size: 12px; }

.banner {
  position: absolute; top: 64px; left: 10px; z-index: 2; max-width: 520px;
  padding: 8px 12px; border-radius: 8px; background: #fef3c7; color: #78350f; border: 1px solid #fde68a;
}

#panel {
  position: absolute; top: 10px; right: 10px; bottom: 10px; z-index: 3; width: min(440px, calc(100vw - 20px));
  overflow-y: auto; padding: 16px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 2px 10px rgb(0 0 0 / .12);
}
#close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
#panel h2 { margin: 0 24px 2px 0; font-size: 18px; }
#panel .sub { color: var(--muted); margin-bottom: 12px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 14px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.links a { margin-right: 10px; }
#bol { border-top: 1px solid var(--line); padding-top: 12px; }
#bol h3 { margin: 0 0 6px; font-size: 15px; }
#bol .note { color: var(--muted); font-size: 12px; margin: 6px 0; }
#bol .sample { background: #fef3c7; color: #78350f; padding: 6px 8px; border-radius: 6px; font-size: 12px; margin: 6px 0; }
#bol .error { color: #991b1b; }
button.primary {
  padding: 6px 12px; border: 1px solid var(--cargo); border-radius: 6px;
  background: var(--cargo); color: white; cursor: pointer; font: inherit;
}
button.primary:disabled { opacity: .6; cursor: progress; }
.record { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin: 8px 0; }
.record .what { font-weight: 600; }
.record .meta { color: var(--muted); font-size: 12px; }
#bol h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
#bol .total { margin: 8px 0 4px; font-weight: 600; }
.trow { margin: 5px 0; }
.tlabel { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.tlabel span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tval { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.tbar { height: 6px; background: #eef1f4; border-radius: 3px; margin-top: 2px; }
.tbar > span { display: block; height: 100%; background: var(--cargo); border-radius: 3px; }

/* Explore panel (left) */
.pillbtn { font: inherit; font-size: 13px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); background: #f8fafc; cursor: pointer; }
.pillbtn[aria-expanded="true"] { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
#explore {
  position: absolute; top: 96px; left: 10px; bottom: 10px; z-index: 2; width: 280px;
  overflow-y: auto; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 1px 4px rgb(0 0 0 / .08); max-height: max-content;
}
#explore[hidden] { display: none; }
#explore h3 { margin: 12px 0 4px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
#explore h3:first-child { margin-top: 2px; }
.ehint { color: var(--muted); font-size: 12px; margin: 0 0 4px; }
.eitem {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; font: inherit;
  padding: 5px 6px; margin: 0 -6px; border: 0; border-radius: 6px; background: none; cursor: pointer; color: var(--fg);
}
.eitem:hover, .eitem:focus-visible { background: #f1f5f9; outline: none; }
.eitem .etext { flex: 1; min-width: 0; }
.eitem .ename { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eitem .edetail { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eitem .ecount { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.banner { left: 300px; }
@media (max-width: 800px) { #explore { width: auto; right: 10px; top: 130px; bottom: auto; max-height: 45vh; } .banner { left: 10px; } }

#bol h5 { margin: 10px 0 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
#bol h3 { margin-top: 0; }
.src { color: var(--muted); font-size: 12px; margin: 6px 0 14px; }
.chg { font-size: 12px; font-weight: 600; white-space: nowrap; }
.chg.up { color: #15803d; } .chg.down { color: #b91c1c; }
.spark { margin: 6px 0; }
.spark svg { width: 100%; height: 64px; display: block; }
.spark .line { fill: none; stroke: var(--cargo); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark .area { fill: #dbeafe; stroke: none; }
.spark figcaption { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
#panel .total { font-weight: 600; margin: 6px 0; }

/* Ops: KPIs, tabs, alerts, idle table */
.dot.wait { background: transparent; box-shadow: 0 0 0 2px #ea580c inset; }
#explore { width: 330px; }
.banner { left: 350px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.kpi { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.kpi b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 11px; }
.kpi.hot b { color: #c2410c; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 -12px 8px; padding: 0 8px; }
.tabs button { font: inherit; font-size: 13px; border: 0; background: none; padding: 6px 8px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: #ea580c; font-weight: 600; }
.alert { display: block; width: 100%; text-align: left; font: inherit; border: 0; background: none; cursor: pointer; color: var(--fg);
  padding: 6px 8px 6px 10px; margin: 0 0 4px; border-radius: 6px; border-left: 3px solid #94a3b8; }
.alert:hover, .alert:focus-visible { background: #f1f5f9; outline: none; }
.alert.high { border-left-color: #dc2626; } .alert.medium { border-left-color: #f59e0b; } .alert.info { border-left-color: #3b82f6; }
.alert .atitle { display: block; font-weight: 600; font-size: 13px; }
.alert .adetail { display: block; color: var(--muted); font-size: 12px; }
.alert .akind { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.qtable { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.qtable th { text-align: right; color: var(--muted); font-weight: 600; padding: 4px; border-bottom: 1px solid var(--line); }
.qtable th:first-child, .qtable td:first-child { text-align: left; }
.qtable td { text-align: right; padding: 5px 4px; border-bottom: 1px solid #f1f5f9; }
.qtable tr[data-lat] { cursor: pointer; } .qtable tr[data-lat]:hover td { background: #f8fafc; }
.linkbtn { font: inherit; font-size: 12px; color: #2563eb; background: none; border: 0; padding: 8px 0 0; cursor: pointer; text-decoration: underline; }
.opsbanner { border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; font-size: 13px; }
.opsbanner.wait { background: #fff7ed; border: 1px solid #fed7aa; color: #7c2d12; }
.opsbanner.late { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; }
.opsbanner.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #14532d; }
.mtable { width: 100%; border-collapse: collapse; font-size: 12px; }
.mtable td { padding: 3px 4px; border-bottom: 1px solid #f1f5f9; } .mtable td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 800px) { #explore { width: auto; } }
