/* ==========================================================================
   Global Maritime Digital Twin v3 — Dark Maritime Control-Room Theme
   100-Vessel Global Fleet · 8 Ports · Financial P&L · HiGHS MILP Optimizer
   Zero external CDN or font dependencies
   ========================================================================== */

:root {
  /* Core Palette (Exact v1/v2 Dark Maritime Control-Room Tokens) */
  --bg-abyss: #050c16;
  --bg-navy: #07111e;
  --bg-panel: #0d1b2a;
  --bg-panel-alt: #102033;
  --bg-elevated: #132438;
  --bg-hover: #182e47;
  --bg-input: #091524;

  /* Semantic Accents */
  --cyan: #38bdf8;
  --cyan-bright: #7dd3fc;
  --cyan-dim: #0284c7;
  --cyan-soft: rgba(56, 189, 248, 0.14);
  --cyan-border: rgba(56, 189, 248, 0.38);

  --emerald: #10b981;
  --emerald-bright: #34d399;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --emerald-border: rgba(16, 185, 129, 0.38);

  --amber: #f59e0b;
  --amber-bright: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --amber-border: rgba(245, 158, 11, 0.42);

  --rose: #f43f5e;
  --rose-bright: #fb7185;
  --rose-soft: rgba(244, 63, 94, 0.16);
  --rose-border: rgba(244, 63, 94, 0.44);

  --violet: #a78bfa;
  --violet-bright: #c4b5fd;
  --violet-soft: rgba(167, 139, 250, 0.16);
  --violet-border: rgba(167, 139, 250, 0.42);

  /* Typography Colors */
  --text-primary: #e6f0fa;
  --text-secondary: #9bb1c9;
  --text-muted: #6c849f;
  --text-inverse: #04101d;

  /* Borders & Dividers */
  --border-subtle: rgba(148, 179, 212, 0.12);
  --border-default: rgba(148, 179, 212, 0.2);
  --border-strong: rgba(148, 179, 212, 0.32);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(2, 8, 16, 0.35);
  --shadow-md: 0 8px 24px rgba(2, 8, 16, 0.45);
  --shadow-lg: 0 14px 36px rgba(2, 8, 16, 0.58);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --glow-cyan: 0 0 0 3px rgba(56, 189, 248, 0.22);

  /* Spacing & Layout */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --topbar-height: 68px;
  --sidebar-width: 320px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;

  /* Motion */
  --transition-fast: 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-base: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-navy);
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(56, 189, 248, 0.1), transparent 65%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(16, 185, 129, 0.06), transparent 60%);
  background-attachment: fixed;
}

h1,
h2,
h3,
h4,
p,
ul,
ol {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.mono,
.num,
.tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Custom Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 179, 212, 0.28) rgba(7, 17, 30, 0.6);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(7, 17, 30, 0.65);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 179, 212, 0.26);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.45);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ==========================================================================
   Topbar (Sticky Header)
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: rgba(7, 17, 30, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-default);
  box-shadow: 0 4px 20px rgba(2, 8, 16, 0.45);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), rgba(16, 185, 129, 0.85), transparent 80%);
  opacity: 0.92;
  pointer-events: none;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.22), rgba(13, 27, 42, 0.95));
  border: 1px solid var(--cyan-border);
  color: var(--cyan);
  box-shadow: inset 0 1px 0 rgba(125, 211, 252, 0.2), 0 0 18px rgba(56, 189, 248, 0.14);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--cyan-soft);
  border: 1px solid var(--cyan-border);
  color: var(--cyan-bright);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 6px;
  border-right: 1px solid var(--border-subtle);
}

.topbar a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 11.5px !important;
  color: var(--text-secondary);
  border-color: var(--border-subtle) !important;
  background: rgba(13, 27, 42, 0.65) !important;
}

.nav-link:hover {
  color: var(--cyan-bright) !important;
  border-color: var(--cyan-border) !important;
  background: var(--cyan-soft) !important;
}

.btn-sla-log {
  border-color: rgba(244, 63, 94, 0.55) !important;
  background: rgba(244, 63, 94, 0.14) !important;
  color: #fda4af !important;
}

.btn-sla-log:hover {
  background: rgba(244, 63, 94, 0.24) !important;
  border-color: rgba(244, 63, 94, 0.85) !important;
  color: #fff1f2 !important;
}

.preset-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.preset-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar select {
  min-width: 215px;
  max-width: 295px;
  height: 36px;
  padding: 0 32px 0 12px;
}

/* ==========================================================================
   Buttons & Loading Spinner
   ========================================================================== */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #38bdf8 0%, #0ea5e9 100%);
  border-color: rgba(125, 211, 252, 0.7);
  color: var(--text-inverse);
  box-shadow: 0 2px 12px rgba(56, 189, 248, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #7dd3fc 0%, #38bdf8 100%);
  border-color: #bae6fd;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-default);
  color: var(--text-primary);
  box-shadow: var(--shadow-inset);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--cyan-border);
  color: var(--cyan-bright);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(148, 179, 212, 0.1);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn.is-active,
.btn.active {
  background: var(--cyan-soft);
  border-color: var(--cyan-border);
  color: var(--cyan-bright);
}

.btn.is-loading,
.btn.loading,
.btn[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.85;
}

.btn.is-loading::before,
.btn.loading::before {
  content: "";
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.82);
  }
}

/* ==========================================================================
   Executive P&L Banner (#pnlBanner)
   ========================================================================== */

#pnlBanner,
.pnl-banner {
  --banner-accent: var(--emerald);
  --banner-soft: var(--emerald-soft);
  --banner-border: var(--emerald-border);

  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-4) var(--space-5) 0;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(105deg, var(--banner-soft) 0%, rgba(13, 27, 42, 0.94) 48%, var(--bg-panel) 100%);
  border: 1px solid var(--banner-border);
  border-left: 4px solid var(--banner-accent);
  box-shadow: var(--shadow-md), var(--shadow-inset);
  transition: border-color var(--transition-base), background var(--transition-base);
}

#pnlBanner.status-profitable {
  --banner-accent: var(--emerald);
  --banner-soft: var(--emerald-soft);
  --banner-border: var(--emerald-border);
}

#pnlBanner.status-thin {
  --banner-accent: var(--amber);
  --banner-soft: var(--amber-soft);
  --banner-border: var(--amber-border);
}

#pnlBanner.status-loss {
  --banner-accent: var(--rose);
  --banner-soft: var(--rose-soft);
  --banner-border: var(--rose-border);
}

.pnl-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.pnl-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.pnl-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--banner-accent);
  background: var(--banner-soft);
  border: 1px solid var(--banner-border);
}

.pnl-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--banner-accent);
  box-shadow: 0 0 8px var(--banner-accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

.pnl-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.math-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: rgba(7, 17, 30, 0.72);
  border: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.25;
}

.chip .chip-label {
  color: var(--text-muted);
}

.chip .chip-value {
  color: var(--cyan-bright);
  font-weight: 700;
}

#pnlBanner.status-profitable .chip.chip-accent {
  border-color: var(--emerald-border);
}
#pnlBanner.status-profitable .chip.chip-accent .chip-value {
  color: var(--emerald-bright);
}

#pnlBanner.status-thin .chip.chip-accent {
  border-color: var(--amber-border);
}
#pnlBanner.status-thin .chip.chip-accent .chip-value {
  color: var(--amber-bright);
}

#pnlBanner.status-loss .chip.chip-accent {
  border-color: var(--rose-border);
}
#pnlBanner.status-loss .chip.chip-accent .chip-value {
  color: var(--rose-bright);
}

.recommendations-list {
  list-style: none;
  padding: var(--space-2) 0 0;
  margin: 0;
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--border-subtle);
}

.recommendations-list:empty {
  display: none;
}

.recommendations-list li {
  position: relative;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.recommendations-list li::before {
  content: "▸";
  position: absolute;
  left: 2px;
  top: 0;
  color: var(--banner-accent, var(--cyan));
  font-weight: 700;
}

/* ==========================================================================
   Main Workspace Layout (2-Column Grid)
   ========================================================================== */

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-5) var(--space-6);
  max-width: 1960px;
  margin: 0 auto;
}

.main-stage {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

/* ==========================================================================
   Controls Sidebar (.controls-panel)
   ========================================================================== */

.controls-panel {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
  max-height: calc(100vh - var(--topbar-height) - var(--space-6));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md), var(--shadow-inset);
}

.controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.controls-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan-bright);
}

.controls-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(19, 36, 56, 0.55);
  border: 1px solid var(--border-subtle);
  margin: 0;
}

.control-group legend {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan-bright);
  padding: 0 0 7px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
  display: block;
}

.fleet-mix-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: rgba(7, 17, 30, 0.7);
  border: 1px dashed var(--cyan-border);
  font-size: 11.5px;
}

.fleet-mix-label {
  color: var(--text-muted);
}

.fleet-mix-val {
  color: var(--emerald-bright);
  font-weight: 700;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px var(--space-2);
}

.range-row label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.range-row .value-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--cyan-soft);
  border: 1px solid var(--cyan-border);
  color: var(--cyan-bright);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.range-row input[type="range"] {
  grid-column: 1 / -1;
}

/* Range Inputs */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.32), rgba(148, 179, 212, 0.22));
  border: 1px solid rgba(148, 179, 212, 0.14);
  cursor: pointer;
  margin: 3px 0;
  transition: background var(--transition-fast);
}

input[type="range"]:hover {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.48), rgba(148, 179, 212, 0.3));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid var(--bg-navy);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35), 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform var(--transition-fast), background-color var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.14);
  background: var(--cyan-bright);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: rgba(148, 179, 212, 0.22);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--cyan);
}

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid var(--bg-navy);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35), 0 2px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

/* Select, Number & Search Inputs */
select,
input[type="number"],
input[type="text"],
input[type="search"] {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: 12.5px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

input[type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.25L6 7.75L9.5 4.25' stroke='%239bb1c9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

select:hover,
input[type="number"]:hover,
input[type="text"]:hover,
input[type="search"]:hover {
  border-color: var(--border-strong);
  background-color: #0b1829;
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus,
input[type="search"]:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}

select option {
  background-color: var(--bg-panel);
  color: var(--text-primary);
}

::placeholder {
  color: var(--text-muted);
}

/* Checkbox Switch */
.checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
}

.checkbox-row label {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
}

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform var(--transition-fast), background-color var(--transition-fast);
}

input[type="checkbox"]:checked {
  background: var(--cyan-soft);
  border-color: var(--cyan);
  box-shadow: inset 0 0 8px rgba(56, 189, 248, 0.25);
}

input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: var(--cyan-bright);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.65);
}

.controls-actions {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-1);
}

.controls-actions .btn {
  flex: 1;
}

/* ==========================================================================
   Executive Financial & Network KPI Grid (8 Cards)
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
}

.kpi-card {
  --kpi-accent: var(--cyan);

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border-default);
  border-top: 2px solid var(--kpi-accent);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  border-top-color: var(--kpi-accent);
  box-shadow: var(--shadow-md);
}

.kpi-card.accent-cyan { --kpi-accent: var(--cyan); }
.kpi-card.accent-emerald { --kpi-accent: var(--emerald); }
.kpi-card.accent-amber { --kpi-accent: var(--amber); }
.kpi-card.accent-rose { --kpi-accent: var(--rose); }
.kpi-card.accent-violet { --kpi-accent: var(--violet); }

.kpi-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  line-height: 1.3;
}

.kpi-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

/* ==========================================================================
   Shared Card Surfaces (.twin-card, .panel-card, .manifest-card)
   ========================================================================== */

.twin-card,
.panel-card,
.manifest-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md), var(--shadow-inset);
  overflow: hidden;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 13px 18px;
  background: rgba(19, 36, 56, 0.55);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* Legend Helpers */
.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.cyan { background: var(--cyan); }
.legend-dot.emerald { background: var(--emerald); }
.legend-dot.amber { background: var(--amber); }
.legend-dot.rose { background: var(--rose); }
.legend-dot.violet { background: var(--violet); }

/* ==========================================================================
   Global World Map Canvas & Playback Bar
   ========================================================================== */

.playback-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 10px 18px;
  background: rgba(7, 17, 30, 0.65);
  border-bottom: 1px solid var(--border-subtle);
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.playback-bar select {
  width: auto;
  min-width: 74px;
  height: 30px;
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 0 26px 0 9px;
}

.scrubber-wrap {
  flex: 1 1 220px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 160px;
}

#timelineScrubber {
  flex: 1 1 180px;
  min-width: 140px;
  margin: 0;
}

#simClock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-abyss);
  border: 1px solid var(--cyan-border);
  color: var(--cyan-bright);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.55);
}

.live-metrics {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.metric-pill strong {
  color: var(--text-primary);
  font-weight: 700;
}

.metric-pill.pill-cyan {
  background: var(--cyan-soft);
  border-color: var(--cyan-border);
  color: var(--cyan-bright);
}
.metric-pill.pill-cyan strong {
  color: var(--cyan-bright);
}

.metric-pill.pill-ok {
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
  color: var(--emerald-bright);
}
.metric-pill.pill-ok strong {
  color: var(--emerald-bright);
}

.metric-pill.pill-warn {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: var(--amber-bright);
}
.metric-pill.pill-warn strong {
  color: var(--amber-bright);
}

.metric-pill.pill-alert {
  background: var(--rose-soft);
  border-color: var(--rose-border);
  color: var(--rose-bright);
}
.metric-pill.pill-alert strong {
  color: var(--rose-bright);
}

.canvas-wrap {
  width: 100%;
  height: 460px;
  position: relative;
  background:
    radial-gradient(ellipse 80% 70% at 50% 45%, #0c223a 0%, #071322 72%, #050d18 100%);
  overflow: hidden;
}

.canvas-wrap.world-map-wrap {
  height: 470px;
}

.canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   Compact 8-Port Status Strip (#portCardsStrip)
   ========================================================================== */

#portCardsStrip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px;
  background: rgba(7, 17, 30, 0.52);
  border-top: 1px solid var(--border-subtle);
}

#portCardsStrip:empty {
  display: none;
}

.port-mini-card {
  --port-accent: var(--emerald);

  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--port-accent);
  min-width: 0;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.port-mini-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  border-left-color: var(--port-accent);
}

.port-mini-card.state-clear { --port-accent: var(--emerald); }
.port-mini-card.state-busy { --port-accent: var(--cyan); }
.port-mini-card.state-congested { --port-accent: var(--amber); }
.port-mini-card.state-critical { --port-accent: var(--rose); }

.port-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.port-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.port-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--border-default);
  background: rgba(148, 179, 212, 0.14);
  color: var(--text-secondary);
}

.port-status-pill.clear {
  background: var(--emerald-soft);
  color: var(--emerald-bright);
  border-color: var(--emerald-border);
}

.port-status-pill.busy {
  background: var(--cyan-soft);
  color: var(--cyan-bright);
  border-color: var(--cyan-border);
}

.port-status-pill.congested {
  background: var(--amber-soft);
  color: var(--amber-bright);
  border-color: var(--amber-border);
}

.port-status-pill.critical {
  background: var(--rose-soft);
  color: var(--rose-bright);
  border-color: var(--rose-border);
}

.port-mini-name {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.port-mini-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--text-secondary);
}

.port-mini-metrics strong {
  color: var(--text-primary);
}

.util-bar {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: rgba(7, 17, 30, 0.85);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.util-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
  transition: width 240ms ease;
}

.util-fill.healthy { background: linear-gradient(90deg, #059669, var(--emerald)); }
.util-fill.stressed { background: linear-gradient(90deg, #d97706, var(--amber)); }
.util-fill.saturated { background: linear-gradient(90deg, #e11d48, var(--rose)); }

/* ==========================================================================
   Operations Research Global Fleet & Speed Optimizer (.or-card)
   ========================================================================== */

.or-card {
  display: flex;
  flex-direction: column;
}

.or-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: 16px 18px;
}

.or-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
}

.or-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(19, 36, 56, 0.55);
  border: 1px solid var(--border-subtle);
}

.or-stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.or-stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  font-weight: 700;
  color: var(--emerald-bright);
  line-height: 1.2;
}

.or-stat-value.val-negative {
  color: var(--rose-bright);
}

.or-stat-value.val-neutral {
  color: var(--cyan-bright);
}

.or-stat-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.or-subpanel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(7, 17, 30, 0.45);
  border: 1px solid var(--border-subtle);
  min-width: 0;
}

.or-subpanel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.or-subpanel-head h4 {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cyan-bright);
  margin: 0;
}

.or-table-wrap {
  max-height: 290px;
}

.or-table-wrap th,
.or-table-wrap td {
  padding: 7px 10px !important;
  font-size: 12px;
  white-space: nowrap;
}

.or-table-wrap th {
  font-size: 10.5px !important;
}

.or-delta-pos {
  color: var(--emerald-bright);
  font-weight: 700;
}

.or-delta-neg {
  color: var(--rose-bright);
  font-weight: 700;
}

.or-delta-neutral {
  color: var(--text-secondary);
  font-weight: 600;
}

.or-insights {
  margin-top: 0;
}

/* ==========================================================================
   Charts Grid (.charts-grid & .chart-wrap)
   ========================================================================== */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.chart-wrap {
  width: 100%;
  height: 290px;
  position: relative;
  padding: 12px 14px;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   Tables: Trade Corridor P&L & 100-Vessel Fleet Financial Ledger
   ========================================================================== */

.logs-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.manifest-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 11px 18px;
  background: rgba(7, 17, 30, 0.55);
  border-bottom: 1px solid var(--border-subtle);
}

.manifest-filters,
.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.manifest-toolbar input[type="search"],
.manifest-toolbar input[type="text"] {
  width: 260px;
  height: 32px;
  font-size: 12.5px;
}

.manifest-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-muted);
}

.table-wrap {
  max-height: 380px;
  overflow: auto;
  position: relative;
}

.corridor-table-wrap {
  max-height: 300px;
}

.vessel-table-wrap {
  max-height: 440px;
}

.table-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 12px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  background: #0a1726;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.table-wrap tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  white-space: nowrap;
  vertical-align: middle;
}

.table-wrap tbody tr:nth-child(even) {
  background: rgba(19, 36, 56, 0.32);
}

.table-wrap tbody tr:hover {
  background: rgba(56, 189, 248, 0.08);
}

.table-wrap tbody tr:last-child td {
  border-bottom: none;
}

.table-wrap th.num,
.table-wrap td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.table-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.profit-pos {
  color: var(--emerald-bright) !important;
  font-weight: 700;
}

.profit-neg {
  color: var(--rose-bright) !important;
  font-weight: 700;
}

.cost-sla {
  color: var(--amber-bright) !important;
  font-weight: 600;
}

/* Status & Vessel Class Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid var(--border-default);
  background: rgba(148, 179, 212, 0.14);
  color: var(--text-secondary);
}

.badge-completed,
.badge-at_berth,
.badge-berth,
.badge-profitable {
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
  color: var(--emerald-bright);
}

.badge-in_service,
.badge-at_sea,
.badge-sailing,
.badge-ulcv {
  background: var(--cyan-soft);
  border-color: var(--cyan-border);
  color: var(--cyan-bright);
}

.badge-waiting,
.badge-panamax {
  background: var(--amber-soft);
  border-color: var(--amber-border);
  color: var(--amber-bright);
}

.badge-breakdown,
.badge-loss {
  background: var(--rose-soft);
  border-color: var(--rose-border);
  color: var(--rose-bright);
}

.badge-feeder,
.badge-canal {
  background: var(--violet-soft);
  border-color: var(--violet-border);
  color: var(--violet-bright);
}

.corridor-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.corridor-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.route-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Alerts & Utilities
   ========================================================================== */

.error-banner {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--rose-soft);
  border: 1px solid var(--rose-border);
  color: var(--rose-bright);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1540px) {
  #portCardsStrip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1360px) {
  .or-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1240px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
    padding: var(--space-4);
  }

  .controls-panel {
    position: static;
    top: auto;
    max-height: none;
    overflow-y: visible;
  }

  #pnlBanner {
    margin: var(--space-4) var(--space-4) 0;
  }
}

@media (max-width: 1000px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: var(--space-3) var(--space-4);
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-nav {
    border-right: none;
    padding-right: 0;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .topbar select {
    min-width: 0;
    max-width: none;
    flex: 1 1 180px;
  }

  #portCardsStrip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .canvas-wrap.world-map-wrap {
    height: 360px;
  }

  .chart-wrap {
    height: 250px;
  }

  .manifest-toolbar input[type="search"] {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
