/* CarbonLayer dashboard — design tokens shared with the carbonlayer-app
 * (Tailwind palette). Light theme, emerald primary, gray neutrals, white
 * cards. Same font stack as the rest of the product.
 */

:root {
  /* ---- Tailwind palette tokens (verbatim) ---------------------------- */
  --emerald-50:  #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --green-600:   #16a34a;
  --green-700:   #15803d;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-300:    #d1d5db;
  --gray-400:    #9ca3af;
  --gray-500:    #6b7280;
  --gray-700:    #374151;
  --gray-800:    #1f2937;
  --gray-900:    #111827;
  --blue-50:     #eff6ff;
  --blue-500:    #3b82f6;
  --blue-600:    #2563eb;
  --blue-700:    #1d4ed8;
  --red-500:     #ef4444;
  --red-600:     #dc2626;
  --orange-500:  #f97316;
  --orange-600:  #ea580c;
  --purple-500:  #a855f7;
  --purple-600:  #9333ea;
  --yellow-400:  #facc15;
  --yellow-500:  #eab308;
  --amber-500:   #f59e0b;

  /* ---- Semantic aliases (used everywhere in the rest of the file) ---- */
  --bg:            var(--gray-100);              /* page background */
  --bg-elevated:   #ffffff;                       /* card surface */
  --bg-card:       rgba(255, 255, 255, 0.96);     /* widget over the map */
  --bg-subtle:     var(--gray-50);
  --fg:            var(--gray-900);
  --fg-muted:      var(--gray-500);
  --fg-subtle:     var(--gray-400);
  --border:        var(--gray-200);
  --border-strong: var(--gray-300);
  --accent:        var(--emerald-600);            /* fresh / good / on */
  --accent-soft:   var(--emerald-50);
  --warn:          var(--orange-600);             /* carry-forward / warn */
  --warn-soft:     #fff7ed;                       /* orange-50 */
  --critical:      var(--red-600);
  --critical-soft: #fef2f2;                       /* red-50 */
  --link:          var(--emerald-600);
  --shadow:        0 4px 6px rgba(17, 24, 39, 0.05), 0 10px 15px rgba(17, 24, 39, 0.08);

  /* Map fallback background — matches the light page bg. (The actual map
   * canvas paints over this once OpenFreeMap Positron tiles load.) */
  --map-bg:        var(--gray-100);
  /* Globe still renders against a dark starfield (Earth-in-space is a
   * natural exception to the light theme; opt-in via the globe toggle). */
  --globe-bg:      radial-gradient(ellipse at center, #1a2540 0%, #000 75%);

  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
}
button { font-family: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

#skip-link {
  position: absolute; top: -40px; left: 8px; z-index: 1000;
  background: var(--accent); color: #fff; padding: 6px 10px; border-radius: 4px;
}
#skip-link:focus { top: 8px; }

.tn { font-variant-numeric: tabular-nums; }

/* HEADER */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; height: 100px; z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
/* Brand mark — emerald gradient square with white lightning-bolt icon
   (matches carbonlayer-app's Header.tsx Zap-icon-in-gradient pattern). */
.brand-mark {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--emerald-500) 0%, var(--green-600) 100%);
  border-radius: 8px;
  color: #fff;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
  transition: box-shadow 0.15s ease;
}
.brand-mark:hover { box-shadow: 0 4px 6px rgba(5, 150, 105, 0.25); }
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong {
  font-size: 18px; font-weight: 700; letter-spacing: -0.015em;
  color: var(--gray-900);
}
.brand-sub { color: var(--fg-muted); font-size: 12px; font-weight: 500; }

/* "Powered By Deloitte" pairing — separator + small label + logo. */
.brand-partner {
  display: flex; align-items: center; gap: 8px;
  margin-left: 16px; padding-left: 16px;
  border-left: 1px solid var(--border);
}
.brand-partner-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--fg-subtle); font-weight: 600;
}
.brand-partner img { height: 84px; width: auto; display: block; }

.demo-badge {
  margin-left: 12px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid #fed7aa;
  font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 9999px;
}

/* Hide the partner block on narrow viewports to keep the header from wrapping. */
@media (max-width: 1024px) {
  .brand-partner { display: none; }
}
.nav { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  color: var(--fg-muted);
}
.nav-link:hover { background: var(--gray-100); color: var(--fg); text-decoration: none; }
.nav-link--active { background: var(--emerald-50); color: var(--emerald-700); }

.lang-select {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 6px; font-size: 12px; margin-left: 6px;
  font-family: var(--font-sans);
  cursor: pointer;
}
.lang-select:focus { outline: 2px solid var(--link); outline-offset: 1px; }

/* MAIN LAYOUT */
.app-main {
  position: absolute; top: 100px; bottom: 56px; left: 0; right: 0;
  display: grid; grid-template-columns: 280px 1fr; gap: 0;
}

/* SIDEBAR */
.sidebar {
  overflow-y: auto;
  padding: 12px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--fg-muted); margin: 0 0 8px 0; font-weight: 600;
}

/* CELL SELECTOR */
.cell-selector label {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px;
  font-size: 12px; color: var(--fg-muted);
}
.cell-selector select {
  background: var(--bg-elevated); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 10px; font-family: var(--font-mono); font-size: 13px;
}
.cell-selector select:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.cell-status {
  margin: 8px 0 0 0; font-size: 11px; color: var(--fg-muted);
}
.cell-status .dot { vertical-align: middle; }

/* LAYER LIST */
.layer-toggles ul { list-style: none; padding: 0; margin: 0; }
.layer-toggles input[type="checkbox"] { accent-color: var(--accent); }
.layer-count {
  margin-left: auto; color: var(--fg-subtle); font-size: 11px;
  font-variant-numeric: tabular-nums; min-width: 40px; text-align: right;
}

.layer-li { padding: 0; margin: 0; border-bottom: 1px solid transparent; }
.layer-row {
  display: flex; align-items: center; gap: 6px; padding: 4px 2px;
  font-size: 13px; user-select: none;
}
.layer-disclosure {
  background: transparent; border: 0; color: var(--fg-muted);
  font-size: 11px; cursor: pointer; padding: 0 2px;
  width: 14px; line-height: 1;
}
.layer-disclosure:hover { color: var(--fg); }
.layer-row label { flex: 1; cursor: pointer; }

.layer-items {
  margin: 2px 0 6px 22px !important;
  padding: 4px 6px !important;
  background: rgba(0,0,0,0.25);
  border-left: 1px solid var(--border);
  max-height: 200px; overflow-y: auto;
}
.layer-items[hidden] { display: none !important; }
.layer-item {
  display: flex !important; align-items: center; gap: 6px;
  padding: 2px 0 !important; font-size: 12px; color: var(--fg-muted);
  cursor: pointer !important;
}
.layer-item label {
  flex: 1; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-sans);
}
.layer-item input[type="checkbox"] { transform: scale(0.85); }
.layer-item--empty { color: var(--fg-subtle); font-style: italic; padding: 4px 0; }
.layer-item-actions {
  display: flex !important; gap: 4px; padding: 2px 0 6px 0 !important;
  border-bottom: 1px dashed var(--border); margin-bottom: 4px;
}
.layer-item-actions button {
  background: var(--bg); color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 1px 8px; font-size: 11px; cursor: pointer;
}
.layer-item-actions button:hover { background: var(--bg-elevated); color: var(--fg); }

/* FRESHNESS */
.freshness-list { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.freshness-list li { padding: 2px 0; color: var(--fg-muted); }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px;
}
.dot--ok { background: var(--accent); }
.dot--warn { background: var(--warn); }
.dot--critical { background: var(--critical); }

/* MAP */
.map-area { position: relative; background: var(--map-bg); }
#map { position: absolute; inset: 0; }
#globe {
  position: absolute; inset: 0;
  background: var(--globe-bg);
}
#globe[hidden] { display: none; }
#map[hidden]   { display: none; }

/* MAP CONTROLS (basemap + globe toggle) */
.map-controls {
  position: absolute; top: 16px; left: 16px; z-index: 25;
  display: flex; gap: 6px; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px;
  box-shadow: var(--shadow);
}
.map-controls select {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 8px; font-family: var(--font-mono); font-size: 12px;
  min-width: 160px;
}
.map-controls select:focus,
.map-controls button:focus { outline: 2px solid var(--link); outline-offset: 1px; }
#globe-toggle, #globe-rotate-toggle {
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 5px 10px; font-size: 12px; cursor: pointer;
  white-space: nowrap;
}
#globe-toggle:hover, #globe-rotate-toggle:hover { background: var(--bg-elevated); }
#globe-toggle[aria-pressed="true"],
#globe-rotate-toggle[aria-pressed="true"] {
  background: var(--accent-soft); color: var(--accent); border-color: var(--accent);
}
#globe-rotate-toggle[hidden] { display: none; }
#globe-style-select[hidden] { display: none; }

/* MAPLIBRE OVERRIDES */
.maplibregl-popup-content {
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 8px 10px;
}
.maplibregl-popup-tip { border-top-color: var(--bg-card); }
.maplibregl-ctrl-attrib {
  background: rgba(14, 17, 22, 0.85) !important;
  color: var(--fg-muted);
}
.maplibregl-ctrl-attrib a { color: var(--link); }

/* PIN CLASSES — colours from the Tailwind palette to match the rest of the
   product. Outlined in white with a soft shadow so they pop on any basemap. */
.pin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.25), 0 2px 4px rgba(17, 24, 39, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.pin:hover { transform: scale(1.2); }
.pin--port        { background: var(--blue-500); }
.pin--refinery    { background: var(--purple-500); }
.pin--vessel      { background: var(--emerald-500);  width: 10px; height: 10px; }
.pin--iscc        { background: var(--green-600);    width: 10px; height: 10px; }
.pin--ets         { background: var(--amber-500); }
.pin--regulatory  { background: var(--orange-500); }
.pin--capacity    { background: var(--purple-500); }
.pin--feedstock   { background: var(--yellow-400);   width: 10px; height: 10px; }
.pin--news        { background: var(--blue-500);     width: 10px; height: 10px; }
.pin--geopolitical{ background: var(--red-500); }
.pin--detection   { background: #ec4899;             width: 10px; height: 10px; } /* pink-500 */
.pin--weather     { background: var(--blue-500); }

.pin--critical {
  animation: pulse 1.6s ease-in-out infinite;
  border-color: var(--critical);
}
.pin--pending { border-style: dashed; }
.pin--faded { opacity: 0.45; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.6), 0 1px 4px rgba(0,0,0,0.6); }
  50%       { box-shadow: 0 0 0 8px rgba(248, 81, 73, 0), 0 1px 4px rgba(0,0,0,0.6); }
}

/* WIDGET CANVAS + ADD BUTTON */
#widget-host {
  position: absolute; inset: 0; pointer-events: none; z-index: 30;
}
.widget-add {
  position: absolute; top: 16px; right: 16px; z-index: 35;
  display: flex; gap: 6px; align-items: flex-start;
}
.widget-add button {
  background: var(--bg-card); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 6px 10px; font-size: 12px; cursor: pointer;
  box-shadow: var(--shadow);
}
.widget-add button:hover { background: var(--bg-elevated); }
.widget-add-menu {
  position: absolute; top: 36px; right: 0; z-index: 36;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
  min-width: 260px; max-width: 320px;
  max-height: 70vh; overflow-y: auto;
}
.widget-add-menu[hidden] { display: none; }
.widget-add-menu__section { display: flex; flex-direction: column; gap: 2px; }
.widget-add-menu__section + .widget-add-menu__section { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.widget-add-menu__heading {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--fg-subtle); padding: 4px 10px 2px 10px;
}
.widget-add-menu button {
  background: transparent; color: var(--fg);
  border: 0; border-radius: 4px;
  text-align: left; padding: 6px 10px; font-size: 12px; cursor: pointer;
  box-shadow: none;
  display: flex; flex-direction: column; gap: 2px;
}
.widget-add-menu button:hover { background: var(--bg-elevated); }
.widget-add-menu button .menu-title { font-weight: 600; }
.widget-add-menu button .menu-desc  { color: var(--fg-muted); font-size: 11px; }

/* WIDGET (the floating, draggable, resizable card) */
.widget {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  display: flex; flex-direction: column;
  min-width: 240px; min-height: 140px;
  overflow: hidden;
  z-index: 31;
  transition: box-shadow 0.15s ease;
}
.widget:hover { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); }
.widget--focused { z-index: 33; border-color: var(--link); }
.widget--dragging { opacity: 0.92; cursor: grabbing !important; }

.widget__header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
}
.widget__header:active { cursor: grabbing; }
.widget__title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--fg); font-weight: 600;
  flex: 1;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.widget__handle-grip {
  color: var(--fg-subtle); font-size: 14px; line-height: 1;
}
.widget__close {
  background: transparent; border: 0; color: var(--fg-muted);
  width: 22px; height: 22px; border-radius: 4px;
  font-size: 16px; line-height: 1; cursor: pointer; padding: 0;
}
.widget__close:hover { background: var(--bg); color: var(--fg); }

.widget__body {
  flex: 1; overflow: auto;
  padding: 10px 12px;
  font-size: 12px;
}
.widget__resize {
  position: absolute; right: 0; bottom: 0;
  width: 14px; height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--border-strong) 50%, var(--border-strong) 60%, transparent 60%, transparent 80%, var(--border-strong) 80%);
}
.widget__resize:hover { filter: brightness(1.5); }

/* WIDGET BODY: shared content styles */
.widget .headline { padding: 4px 0 10px 0; border-bottom: 1px solid var(--border); margin-bottom: 8px; }

/* Forward-price colour-coded direction: green when up vs prior day, red down. */
.headline__value--up   { color: var(--accent);   transition: color 0.4s ease; }
.headline__value--down { color: var(--critical); transition: color 0.4s ease; }
.headline__value--flat { color: var(--fg);       transition: color 0.4s ease; }
.headline__delta {
  display: inline-flex; align-items: baseline; gap: 2px;
  margin-left: 8px; font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.headline__delta--up   { color: var(--accent); }
.headline__delta--down { color: var(--critical); }
.headline__delta--flat { color: var(--fg-subtle); }
.headline__arrow { font-size: 12px; line-height: 1; }

/* Brief flash overlay when the headline changes — pulses then fades. */
.flash-up   { animation: flash-green 0.9s ease-out; }
.flash-down { animation: flash-red   0.9s ease-out; }
@keyframes flash-green {
  0%   { background: rgba(46, 164, 79, 0.30); }
  100% { background: transparent; }
}
@keyframes flash-red {
  0%   { background: rgba(248, 81, 73, 0.30); }
  100% { background: transparent; }
}
.headline__primary {
  display: flex; align-items: baseline; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.headline__value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.headline__unit { color: var(--fg-muted); font-size: 13px; }
.headline__secondary {
  margin-top: 4px; font-size: 12px; color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.horizons {
  width: 100%; border-collapse: collapse;
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.horizons th {
  text-align: right; padding: 4px 6px; color: var(--fg-muted);
  font-weight: 500; font-size: 11px; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.horizons th:first-child, .horizons td:first-child { text-align: left; }
.horizons td { padding: 6px 6px; text-align: right; }
.horizons tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.horizon-band { color: var(--fg-subtle); font-size: 11px; }

.components { margin-top: 10px; font-size: 12px; }
.components summary {
  cursor: pointer; padding: 6px 0; color: var(--fg-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
}
.components table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.components td { padding: 4px 0; border-bottom: 1px solid var(--border); }
.components td:last-child { text-align: right; }
.components .row--sum td { font-weight: 600; border-bottom: 0; }
.components .row--note td { color: var(--fg-subtle); font-size: 11px; border-bottom: 0; }

.widget-footer {
  margin-top: 10px; font-size: 11px; color: var(--fg-muted);
  display: flex; gap: 6px; align-items: center;
}
.separator { color: var(--fg-subtle); }

/* WIDGET CONTENT SHARED STYLES */
.events-feed { list-style: none; padding: 0; margin: 0; }
.events-feed li {
  padding: 6px 4px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer;
}
.events-feed li:hover { background: var(--bg-elevated); }
.events-feed .ef-when { color: var(--fg-subtle); font-family: var(--font-mono); font-size: 10px; }
.events-feed .ef-title { color: var(--fg); font-size: 12px; }
.events-feed .ef-where { color: var(--fg-muted); font-size: 11px; }
.events-feed .ef-critical { color: var(--critical); }
.events-feed .ef-warn { color: var(--warn); }

.cell-stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 12px; }
.cell-stats dt { color: var(--fg-muted); }
.cell-stats dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

.vessels-list { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.vessels-list li {
  padding: 6px 4px; border-bottom: 1px solid var(--border);
}
.vessels-list .vl-name { font-weight: 600; color: var(--fg); }
.vessels-list .vl-meta { color: var(--fg-muted); font-size: 11px; font-variant-numeric: tabular-nums; }

/* Plain-English explanation row that sits under each scoreboard data row. */
.scoreboard-mini .scoreboard-explain td,
.scoreboard      .scoreboard-explain td {
  padding: 2px 8px 8px 22px !important;
  font-size: 10px; line-height: 1.45;
  font-style: italic;
  color: var(--fg-subtle);
  border-bottom: 1px solid var(--border) !important;
  border-left: 0 !important;
  font-variant-numeric: normal;
  text-align: left !important;
  white-space: normal;
}
.scoreboard-mini .scoreboard-explain--ok   td,
.scoreboard      .scoreboard-explain--ok   td { border-left: 3px solid var(--accent) !important; }
.scoreboard-mini .scoreboard-explain--warn td,
.scoreboard      .scoreboard-explain--warn td { border-left: 3px solid var(--warn) !important; }
.scoreboard-mini .scoreboard-explain--crit td,
.scoreboard      .scoreboard-explain--crit td { border-left: 3px solid var(--critical) !important; }

/* Info-quote shown above the scoreboard table (widget + modal). */
.scoreboard-quote {
  display: block;
  font-size: 11px; line-height: 1.55;
  color: var(--gray-700);
  font-style: italic;
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  margin: 0 0 8px 0;
  background: var(--emerald-50);
  border-radius: 0 6px 6px 0;
}
.scoreboard-quote::before { content: "ℹ "; font-style: normal; color: var(--accent); margin-right: 2px; font-weight: 700; }

/* Column-header tooltips: dotted underline + help cursor signals hoverable.
   Matches both raw [title] and the legacy [data-tt] attribute used by the
   custom tooltip system (see #custom-tooltip and JS handler). */
.scoreboard-mini th[title],
.scoreboard-mini th[data-tt],
.scoreboard      th[title],
.scoreboard      th[data-tt] {
  cursor: help;
  text-decoration: underline dotted var(--fg-subtle);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* Custom tooltip — single element appended to body, positioned on hover.
   Replaces native [title] tooltips, which have ~500ms delay and inconsistent
   styling across browsers. JS in app.js manages the show/hide + positioning. */
#custom-tooltip {
  position: fixed;
  z-index: 10000;
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.5;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
  max-width: 320px;
  width: max-content;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease-out;
}
#custom-tooltip[data-visible="true"] { opacity: 1; }
#custom-tooltip[hidden] { display: none; }

.scoreboard-mini { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.scoreboard-mini th, .scoreboard-mini td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
.scoreboard-mini th { color: var(--fg-muted); font-weight: 500; text-transform: uppercase; font-size: 10px; letter-spacing: 0.4px; text-align: right; }
.scoreboard-mini td { text-align: right; }
.scoreboard-mini th:first-child, .scoreboard-mini td:first-child { text-align: left; }
.scoreboard-mini .ok { color: var(--accent); }
.scoreboard-mini .gated { color: var(--warn); }

/* Live-status pill that flashes per row.
   Green = publication-qualified, Orange = borderline (skill 0.85–0.95),
   Red   = severely-gated (skill ≥ 0.95). */
.status-pill {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.status-pill--ok   { background: var(--accent);   animation: pulse-green  1.8s ease-in-out infinite; }
.status-pill--warn { background: var(--warn);     animation: pulse-orange 1.4s ease-in-out infinite; }
.status-pill--crit { background: var(--critical); animation: pulse-red    0.9s ease-in-out infinite; }

@keyframes pulse-green  {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 164, 79, 0.55); opacity: 1; }
  50%      { box-shadow: 0 0 0 5px rgba(46, 164, 79, 0);   opacity: 0.55; }
}
@keyframes pulse-orange {
  0%, 100% { box-shadow: 0 0 0 0 rgba(210, 153, 34, 0.55); opacity: 1; }
  50%      { box-shadow: 0 0 0 5px rgba(210, 153, 34, 0);  opacity: 0.55; }
}
@keyframes pulse-red    {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.65);  opacity: 1; }
  50%      { box-shadow: 0 0 0 7px rgba(248, 81, 73, 0);   opacity: 0.45; }
}

.status-row--ok   td:first-child { border-left: 3px solid var(--accent); }
.status-row--warn td:first-child { border-left: 3px solid var(--warn); }
.status-row--crit td:first-child { border-left: 3px solid var(--critical); }
.status-row--ok   td:first-child,
.status-row--warn td:first-child,
.status-row--crit td:first-child { padding-left: 6px !important; }

/* "LIVE" badge in the scoreboard widget header (shown via app.js). */
.live-badge {
  display: inline-block; vertical-align: middle;
  font-size: 9px; font-weight: 700; letter-spacing: 0.8px;
  padding: 1px 6px; border-radius: 8px;
  background: rgba(248, 81, 73, 0.15); color: var(--critical);
  border: 1px solid var(--critical);
  animation: live-blink 1.4s ease-in-out infinite;
}
@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.spark { width: 100%; height: 60px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark .spark-area { fill: rgba(46, 164, 79, 0.15); stroke: none; }
.spark .axis { stroke: var(--border); stroke-width: 0.5; }

/* EVENT PANEL */
.event-panel {
  position: absolute; top: 16px; right: 16px; width: 360px;
  max-height: calc(100% - 32px); overflow-y: auto;
  z-index: 40;
  box-shadow: var(--shadow);
}
.event-panel[hidden] { display: none; }
.event-panel__header { display: flex; align-items: flex-start; gap: 8px; }
.event-panel__header .card-title { flex: 1; text-transform: none; font-size: 14px; color: var(--fg); letter-spacing: 0; }
.event-panel__when, .event-panel__where {
  margin: 4px 0 0 0; font-size: 12px; color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.event-panel__summary { margin: 12px 0; font-size: 13px; line-height: 1.5; }
.attribution h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--fg-muted); margin: 12px 0 4px 0;
}
.attribution table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.attribution td { padding: 4px 0; border-bottom: 1px solid var(--border); }
.attribution td:last-child { text-align: right; font-weight: 600; }
.attribution .pos { color: var(--accent); }
.attribution .neg { color: var(--warn); }
.event-panel__meta { margin-top: 14px; font-size: 11px; color: var(--fg-subtle); }

.close {
  background: transparent; border: 0; color: var(--fg-muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.close:hover { color: var(--fg); }

/* SCRUBBER */
.time-scrubber {
  position: fixed; bottom: 0; left: 0; right: 0; height: 56px; z-index: 60;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 6px rgba(17, 24, 39, 0.04);
}
#scrubber-play {
  background: var(--gray-100); border: 1px solid var(--border-strong); color: var(--fg);
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
}
#scrubber-play:hover { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-200); }
#scrubber { flex: 1; accent-color: var(--accent); }
#scrubber-label { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); min-width: 220px; }
.window-label { font-size: 11px; color: var(--fg-subtle); font-weight: 500; }

/* SCOREBOARD MODAL */
.scoreboard-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.scoreboard-modal[hidden] { display: none; }
.scoreboard-modal__inner {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
  padding: 18px; max-width: 960px; width: 100%; max-height: 90%; overflow-y: auto;
}
.scoreboard-modal header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.scoreboard-help { color: var(--fg-muted); font-size: 12px; margin: 4px 0 16px 0; }
.scoreboard-help code { background: var(--bg); padding: 1px 6px; border-radius: 3px; font-size: 11px; }
.scoreboard {
  width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums;
}
.scoreboard th, .scoreboard td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.scoreboard th { color: var(--fg-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.6px; text-align: right; }
.scoreboard th:first-child, .scoreboard td:first-child { text-align: left; }
.scoreboard td.published-yes { color: var(--accent); }
.scoreboard td.published-no { color: var(--warn); }

/* RESPONSIVE */
@media (max-width: 900px) {
  .app-main { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .widget { width: calc(100% - 32px) !important; right: 16px; }
  .event-panel { width: calc(100% - 16px); right: 8px; left: 8px; }
}
@media (max-width: 540px) {
  .horizons th, .horizons td { padding: 3px 4px; font-size: 11px; }
  .headline__value { font-size: 22px; }
}
