/* ==========================================================================
   Supply Chain Simulation & Optimization Studio Pro - Design System
   Best-Practice Drag & Drop Dashboard Grid System with Visual Insertion Placeholders,
   Responsive Text-Wrapped Metric Selector Dropdowns, & Daylight GIS Maps
   ========================================================================== */

:root {
  --bg-dark: #f0fdf4; /* Soft Light Pastel Green Background */
  --bg-panel: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.96);
  --bg-card-hover: #ffffff;
  --border-glass: rgba(16, 185, 129, 0.22);
  --border-active: #059669;

  --text-primary: #064e3b; /* Deep Forest Green for high contrast readability */
  --text-secondary: #374151;
  --text-muted: #6b7280;

  --color-accent: #059669; /* Pastel Emerald Green */
  --color-accent-hover: #047857;
  --color-accent-light: #10b981;
  --color-success: #10b981;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-purple: #7c3aed;
  --color-cyan: #0284c7;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-card: 0 6px 20px rgba(6, 78, 59, 0.06);
  --shadow-hover: 0 12px 30px rgba(5, 150, 105, 0.16);

  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease-out;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-variant-numeric: tabular-nums;
}

/* Custom Info Icon Styling */
.info-icon {
  font-size: 11px;
  color: var(--color-accent-light);
  margin-left: 4px;
  cursor: help;
  transition: var(--transition-smooth);
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.info-icon:hover {
  color: var(--color-accent-hover);
  transform: scale(1.25) rotate(5deg);
}

/* Inline Unit Dropdowns inside Table Cells */
.unit-inline-dropdown {
  background: #f0fdf4;
  color: var(--color-accent-hover);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10px;
  font-family: var(--font-sans);
  outline: none;
  cursor: pointer;
  margin-left: 6px;
  display: inline-block;
  vertical-align: middle;
  transition: var(--transition-fast);
  max-width: 95px;
}

.unit-inline-dropdown:hover, .unit-inline-dropdown:focus {
  border-color: var(--color-accent);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.unit-tag-static {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
  font-weight: 500;
  display: inline-block;
  vertical-align: middle;
}

.sim-date-range-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  flex-wrap: wrap;
}

.date-input {
  width: 115px;
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  border-radius: 6px;
  transition: var(--transition-fast);
}

.date-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Responsive Metric Selection Dropdown Bar */
.plot-metric-selector-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  background: #f0fdf4;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  font-size: 11px;
  width: 100%;
  flex-wrap: wrap;
}

.plot-metric-selector-bar label {
  font-weight: 600;
  color: #064e3b;
  white-space: nowrap;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-select-dropdown {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
  background: #ffffff;
  color: #064e3b;
  border: 1px solid var(--border-glass);
  outline: none;
  flex: 1;
  min-width: 180px;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  word-wrap: break-word;
  text-overflow: ellipsis;

  /* Custom styling to ensure long option text does not overflow */
  line-height: 1.3;
}

.metric-select-dropdown option {
  padding: 4px;
  white-space: normal;
  word-wrap: break-word;
  font-size: 11px;
}

.metric-select-dropdown:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Custom Universal Smooth Scrollbar System */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #e6f7ed;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #059669;
  border-radius: 10px;
  border: 2px solid #e6f7ed;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: #047857;
}

body.light-theme {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Ultra Smooth Glassmorphism Card Component */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.glass-panel:hover {
  border-color: rgba(5, 150, 105, 0.35);
  box-shadow: var(--shadow-hover);
}

/* Resizer Dragger Controls */
.resizer-h {
  width: 8px;
  cursor: col-resize;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 100;
  transition: var(--transition-smooth);
  border-radius: 6px;
  margin: 0 2px;
  flex-shrink: 0;
}

.resizer-h::after {
  content: '';
  width: 4px;
  height: 36px;
  background: rgba(5, 150, 105, 0.25);
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.resizer-h:hover::after, .resizer-h.dragging::after {
  background: var(--color-accent);
  height: 54px;
  box-shadow: 0 0 10px rgba(5, 150, 105, 0.5);
}

.resizer-v {
  height: 10px;
  cursor: row-resize;
  background: rgba(16, 185, 129, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 100;
  transition: var(--transition-smooth);
  border-radius: 6px;
  margin: 3px 0;
  flex-shrink: 0;
}

.resizer-v::after {
  content: '';
  height: 4px;
  width: 44px;
  background: rgba(5, 150, 105, 0.35);
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.resizer-v:hover::after, .resizer-v.dragging::after {
  background: var(--color-accent);
  width: 64px;
  box-shadow: 0 0 10px rgba(5, 150, 105, 0.5);
}

/* Header Bar */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #ecfdf5, #ffffff);
  border-bottom: 1px solid var(--border-glass);
  padding: 8px 14px;
  min-height: 52px;
  z-index: 100;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(6, 78, 59, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 20px;
  color: #ffffff;
  background: var(--color-accent);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.35);
  transition: var(--transition-smooth);
  flex-shrink: 0;
}

.logo-icon:hover {
  transform: scale(1.08) rotate(-4deg);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 15px;
  font-weight: 700;
  color: #064e3b;
  white-space: nowrap;
}

.badge-tag {
  font-size: 9px;
  background: rgba(5, 150, 105, 0.15);
  color: var(--color-accent-hover);
  border: 1px solid rgba(5, 150, 105, 0.3);
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: 6px;
  white-space: nowrap;
}

.app-subtitle {
  font-size: 11px;
  color: #047857;
  white-space: nowrap;
}

.scenario-selector-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 5px 12px;
  border-radius: 12px;
  border: 1px solid rgba(5, 150, 105, 0.2);
  font-size: 12px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(6, 78, 59, 0.04);
}

.scenario-selector-wrap label {
  color: #064e3b;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-weight: 600;
}

.preset-dropdown {
  background: #ffffff;
  color: #064e3b;
  border: 1px solid var(--border-glass);
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  max-width: 320px;
  transition: var(--transition-fast);
}

.preset-dropdown:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Main Navigation Tabs Bar */
.main-nav-tabs {
  display: flex;
  align-items: center;
  background: #ffffff;
  border-bottom: 2px solid #d1fae5;
  padding: 6px 14px;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(6, 78, 59, 0.05);
  z-index: 90;
  position: relative;
  clear: both;
}

.nav-tab {
  background: #f0fdf4;
  border: 1px solid rgba(5, 150, 105, 0.2);
  color: #064e3b;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-tab:hover {
  color: #047857;
  background: #d1fae5;
  border-color: #059669;
  transform: translateY(-1px);
}

.nav-tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, #059669, #047857);
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.35);
}

/* Workspace Layout & Universal Scrollability */
.app-workspace, .workspace {
  flex: 1;
  overflow-y: auto !important;
  overflow-x: hidden;
  position: relative;
  padding: 10px;
  background: #f0fdf4;
  height: auto;
  min-height: calc(100vh - 110px);
}

.tab-pane {
  display: none !important;
  width: 100%;
  min-height: 100%;
}

.tab-pane.active {
  display: flex !important;
  flex-direction: column;
}

/* Common Layout Helpers */
.flex-column {
  display: flex;
  flex-direction: column;
}

.flex-1 {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.w-350 { width: 350px; }
.w-400 { width: 400px; }

.chart-card-h250 {
  height: 230px;
  min-height: 120px;
}

.position-relative {
  position: relative;
}

.overflow-auto {
  overflow-y: auto;
  overflow-x: auto;
}

.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }

/* Chart Container Sizing (Fixes Canvas Infinite Expansion Loop) */
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chart-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}

/* Light Pastel Smooth Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 11px;
  border-radius: 14px;
}

.btn-block {
  width: 100%;
  border-radius: 10px;
}

.btn-primary {
  background: var(--color-accent);
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.25);
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 5px 14px rgba(5, 150, 105, 0.4);
}

.btn-action {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  font-weight: 600;
  padding: 9px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-action:hover {
  opacity: 0.96;
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.45);
}

.btn-secondary {
  background: #e2e8f0;
  color: #1e293b;
  border-color: #cbd5e1;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-warning {
  background: var(--color-warning);
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(217, 119, 6, 0.25);
}

.btn-danger {
  background: var(--color-danger);
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(220, 38, 38, 0.25);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--color-accent);
  color: var(--color-accent-hover);
}

.btn-outline:hover {
  background: rgba(16, 185, 129, 0.12);
}

.btn-outline-danger {
  background: transparent;
  border-color: rgba(220, 38, 38, 0.5);
  color: var(--color-danger);
}

.btn-outline-danger:hover {
  background: rgba(220, 38, 38, 0.1);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Forms */
.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-weight: 600;
  flex-wrap: wrap;
  line-height: 1.4;
}

.form-control {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  transition: var(--transition-fast);
}

.form-control:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: var(--text-primary);
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: normal;
  line-height: 1.3;
}

.checkbox-group label:hover {
  color: var(--color-accent-hover);
}

.divider {
  border: none;
  border-top: 1px solid var(--border-glass);
  margin: 12px 0;
}

/* TAB 1: MODELLING LAYOUT */
.split-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.table-sidebar {
  width: 240px;
  min-width: 180px;
  max-width: 450px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: #064e3b;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-glass);
}

.table-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.table-nav-item {
  padding: 8px 12px;
  border-radius: 10px;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  transition: var(--transition-fast);
  border-left: 3px solid transparent;
  white-space: nowrap;
}

.table-nav-item:hover {
  background: rgba(16, 185, 129, 0.12);
  color: #064e3b;
}

.table-nav-item.active {
  background: rgba(5, 150, 105, 0.18);
  color: #064e3b;
  font-weight: 700;
  border-left-color: var(--color-accent);
}

.table-content-area {
  flex: 1;
  gap: 8px;
  min-width: 0;
  overflow-y: auto !important;
  overflow-x: hidden;
  max-height: 100%;
}

/* Header Toolbar & Action Bands */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: linear-gradient(135deg, #ffffff, #f0fdf4);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(6, 78, 59, 0.04);
  flex-wrap: wrap;
  gap: 12px;
  min-height: 62px;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.section-heading {
  font-size: 16px;
  font-weight: 700;
  color: #064e3b;
  white-space: nowrap;
}

.section-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.header-buttons .btn {
  height: 36px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
}

#add-row-btn {
  background: linear-gradient(135deg, #059669, #047857);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.35);
  border: none;
}

#add-row-btn:hover {
  background: linear-gradient(135deg, #047857, #064e3b);
  box-shadow: 0 5px 14px rgba(5, 150, 105, 0.45);
}

/* Custom Plot Inserter Band */
.custom-plot-inserter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(5, 150, 105, 0.25);
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.06);
  flex-wrap: wrap;
}

.custom-plot-inserter-bar label {
  font-weight: 700;
  color: #064e3b;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

#custom-plot-select {
  flex: 1 1 320px;
  max-width: 480px;
  min-height: 38px;
  height: 38px;
  background: #ffffff;
  color: #064e3b;
  border: 1px solid rgba(5, 150, 105, 0.3);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

#add-custom-plot-btn {
  height: 38px;
  padding: 0 18px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
}

/* Metric Selector Bar & Dropdowns inside Plot Cards */
.plot-metric-selector-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  background: #f0fdf4;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(5, 150, 105, 0.15);
}

.plot-metric-selector-bar label {
  font-size: 11px;
  font-weight: 600;
  color: #064e3b;
  margin: 0;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-select-dropdown {
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-height: 32px;
  background: #ffffff;
  color: #064e3b;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(5, 150, 105, 0.25);
  border-radius: 8px;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.3;
}

.metric-select-dropdown:focus {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

/* Dashboard Card Header */
.dashboard-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  cursor: grab;
  padding: 8px 12px;
  background: linear-gradient(135deg, #f0fdf4, #e6f7ed);
  border-radius: 10px;
  border: 1px solid rgba(5, 150, 105, 0.2);
  user-select: none;
  min-height: 38px;
}

.dashboard-card h3 {
  font-size: 13px;
  font-weight: 700;
  color: #064e3b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-responsive {
  overflow: auto;
  min-height: 100px;
  flex: 1;
  background: #ffffff;
  border-radius: 10px;
  max-width: 100%;
}

.resizable-table-box {
  min-height: 120px;
  max-height: 800px;
  overflow: auto;
}

.alx-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

/* Interactive Column Width Drag Handles */
.alx-data-table th {
  background: #d1fae5;
  color: #065f46;
  font-weight: 700;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  user-select: none;
  position: relative;
}

.col-resizer {
  position: absolute;
  right: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 20;
  background: transparent;
}

.col-resizer:hover, .col-resizer.resizing {
  background: var(--color-accent);
}

.alx-data-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0fdf4;
  color: var(--text-primary);
  white-space: nowrap;
  transition: var(--transition-fast);
}

.alx-data-table tr:nth-child(even) {
  background: #f9fefb;
}

.alx-data-table tr:hover {
  background: rgba(16, 185, 129, 0.08);
}

.alx-data-table tr.selected {
  background: rgba(5, 150, 105, 0.2);
}

/* Executive KPI Summary Matrix Table - Strict Aligned Layout System */
.executive-summary-table {
  width: 100%;
  border-collapse: collapse;
}

.executive-summary-table th, .executive-summary-table td {
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
  vertical-align: middle;
}

.executive-summary-table th:nth-child(1), .executive-summary-table td:nth-child(1) {
  text-align: left;
  font-weight: 600;
  color: #064e3b;
}

.executive-summary-table th:nth-child(2), .executive-summary-table td:nth-child(2),
.executive-summary-table th:nth-child(3), .executive-summary-table td:nth-child(3),
.executive-summary-table th:nth-child(4), .executive-summary-table td:nth-child(4) {
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.executive-summary-table th:nth-child(5), .executive-summary-table td:nth-child(5) {
  text-align: center;
  font-weight: 500;
  color: var(--text-secondary);
}

.cell-editable {
  outline: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 4px;
  display: inline-block;
  min-width: 30px;
  transition: var(--transition-fast);
}

.cell-editable:focus {
  border-color: var(--color-accent);
  background: #f0fdf4;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.compact-table th, .compact-table td {
  padding: 6px 10px;
  font-size: 11px;
}

/* Executive KPI Summary Banner Cards */
.kpi-card-banner {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 6px rgba(6, 78, 59, 0.04);
}

.kpi-card-banner .lbl {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.kpi-card-banner .val {
  font-size: 13px;
  font-weight: 700;
  color: #064e3b;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Mini Map Preview Card - Generous Height & Non-Collapsible */
.mini-map-card {
  height: 380px;
  min-height: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  margin-top: 8px;
}

.map-card-header {
  padding: 7px 14px;
  background: #e6f7ed;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #064e3b;
  flex-wrap: wrap;
  gap: 6px;
}

.legend-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.pill-customer { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
.pill-dc { background: rgba(16, 185, 129, 0.2); color: #059669; }
.pill-factory { background: rgba(124, 58, 237, 0.15); color: #7c3aed; }

.map-view-container {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #ffffff;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
}

/* UNIVERSAL MAP PANELS & HEIGHT TRANSITIONS */
#modelling-map-card, #gfa-map-panel, #no-map-panel, #sim-map-panel {
  width: 100%;
  min-height: 200px;
  height: 350px;
  transition: height 0.25s ease-out, min-height 0.25s ease-out;
}

#modelling-map-card.map-height-reduced,
#gfa-map-panel.map-height-reduced,
#no-map-panel.map-height-reduced,
#sim-map-panel.map-height-reduced {
  height: 200px !important;
  min-height: 200px !important;
}

/* TAB 4: DYNAMIC SIMULATION (SIM) - OVERALL SCROLLER + DEDICATED PLOT SIDEBAR SCROLLER */
#tab-sim {
  width: 100%;
  min-height: 100%;
  overflow-y: auto !important;
}

#tab-sim.active {
  display: flex !important;
  flex-direction: column;
}

.sim-layout {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 100%;
  width: 100%;
  overflow-y: auto !important;
  gap: 8px;
}

.sim-grid {
  display: flex;
  gap: 10px;
  width: 100%;
  flex: 1;
  align-items: flex-start;
}

#sim-map-panel {
  flex: 1 1 auto;
  width: 100%;
  min-height: 400px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* SIM Telemetry Sidebar - Dedicated Independent Vertical Scroller */
.sim-live-dashboards {
  width: 420px;
  min-width: 320px;
  flex-shrink: 0;
  height: calc(100vh - 180px);
  max-height: 600px;
  overflow-y: auto !important;
  overflow-x: hidden;
  padding-right: 6px;
  border-left: 1px solid var(--border-glass);
}
.gfa-grid, .no-grid {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-y: auto !important;
}

.gfa-controls, .no-controls {
  width: 310px;
  min-width: 220px;
  max-width: 480px;
  overflow-y: auto !important;
  flex-shrink: 0;
}

.results-summary-card h4 {
  font-size: 12px;
  color: #064e3b;
  margin-bottom: 6px;
}

.kpi-grid-mini {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.kpi-box {
  background: #f0fdf4;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
}

.kpi-lbl {
  font-size: 10px;
  color: var(--text-muted);
}

.kpi-val {
  font-size: 13px;
  font-weight: 700;
  color: #064e3b;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-val-highlight {
  color: #059669;
  font-size: 14px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.gfa-views, .no-views {
  flex: 1;
  min-width: 0;
  gap: 6px;
  overflow-y: auto !important;
  max-height: 100%;
}

.split-horizontal-card {
  display: flex;
  height: 250px;
  min-height: 140px;
  gap: 8px;
}

.card-header-clean {
  margin-bottom: 6px;
}

.card-header-clean h3 {
  font-size: 12px;
  color: #064e3b;
  font-weight: 600;
}

/* TAB 4: DYNAMIC SIMULATION (SIM) - EXECUTIVE TELEMETRY SIDEBAR */
.sim-layout {
  gap: 8px;
  height: 100%;
}

.sim-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  height: auto;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.sim-playback-controls,
.sim-date-range-group,
.sim-status-display,
.sim-settings-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  white-space: nowrap;
  font-size: 11px;
}

.sim-date-range-group label,
.sim-settings-group label {
  font-weight: 600;
  color: #064e3b;
  font-size: 11px;
  margin: 0;
}

.date-input {
  width: 120px !important;
  height: 28px !important;
  padding: 2px 6px !important;
  font-size: 11px !important;
  border-radius: 8px;
  border: 1px solid rgba(5, 150, 105, 0.3);
}

.speed-slider {
  width: 75px;
  accent-color: var(--color-accent);
}

.sim-date-range-group label,
.sim-settings-group label {
  font-weight: 600;
  color: #064e3b;
  font-size: 11px;
  margin: 0;
}

.sim-date-range-group input[type="date"] {
  padding: 2px 6px;
  font-size: 11px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(5, 150, 105, 0.3);
}

.speed-slider {
  width: 65px;
  accent-color: var(--color-accent);
}

.active-shipments-counter {
  color: #059669;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* SIM Telemetry Sidebar & Layout Shift Prevention */

.sidebar-dashboard-header {
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-glass);
}

.sidebar-dashboard-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: #064e3b;
}

.sidebar-dashboard-header p {
  font-size: 10px;
  color: var(--text-secondary);
}

.sim-kpi-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.sim-kpi-card {
  background: #f0fdf4;
  padding: 7px;
  border-radius: 10px;
  border: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
}

.sim-kpi-card .lbl { font-size: 10px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.sim-kpi-card .val { font-size: 14px; font-weight: 700; font-family: var(--font-mono); color: #064e3b; font-variant-numeric: tabular-nums; min-width: 60px; white-space: nowrap; }

.dashboard-plot-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-top: 3px solid #059669;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(6, 78, 59, 0.04);
}

.dashboard-plot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #064e3b;
  flex-wrap: wrap;
  gap: 4px;
}

.expand-hint {
  font-size: 10px;
  color: var(--color-accent-light);
  font-weight: 600;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.expand-hint:hover {
  color: var(--color-accent-hover);
}

.text-success { color: #059669; }
.text-danger { color: #dc2626; }
.text-warning { color: var(--color-warning); }
.text-purple { color: #7c3aed; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

.event-log-container h4 {
  font-size: 11px;
  color: #064e3b;
  margin-bottom: 4px;
}

.event-log-box {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  height: 100px;
  overflow-y: scroll !important;
  overflow-anchor: none;
  padding: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  resize: vertical;
}

/* TAB 5: ANALYTICS & EXECUTIVE KPI DASHBOARD (HORIZONTAL RESIZABLE & DRAGGABLE PLOTS GRID) */
.dashboards-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
  overflow-y: auto !important;
  overflow-x: hidden;
  max-height: 100%;
  padding-right: 4px;
}

.dashboards-header {
  padding: 14px 20px;
  flex-shrink: 0;
  border-top: 4px solid var(--color-accent);
}

.dashboards-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: #064e3b;
}

.dashboards-header p {
  font-size: 12px;
  color: var(--text-secondary);
}

.dashboards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 14px;
  width: 100%;
  position: relative;
}

/* Best-Practice Horizontal Resizable & Drag-and-Drop Plot Cards */
.dashboard-card {
  display: flex;
  flex-direction: column;
  height: 350px;
  min-width: 320px;
  resize: horizontal;
  overflow: auto;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-top: 4px solid var(--color-accent);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  position: relative;
}

.dashboard-card-header:active {
  cursor: grabbing;
}

.dashboard-card.dragging-card {
  opacity: 0.35;
  border: 2px dashed var(--color-accent);
  box-shadow: 0 12px 30px rgba(5, 150, 105, 0.35);
  transform: scale(0.96);
}

.dashboard-card.dragging-card canvas {
  pointer-events: none;
}

.dashboard-card.drag-target-before {
  border-top: 4px solid #059669;
  box-shadow: 0 -4px 15px rgba(5, 150, 105, 0.4);
}

.dashboard-card.drag-target-after {
  border-bottom: 4px solid #059669;
  box-shadow: 0 4px 15px rgba(5, 150, 105, 0.4);
}

.dashboard-card:hover {
  border-color: rgba(5, 150, 105, 0.4);
  box-shadow: var(--shadow-hover);
}

/* Modal Overlay & Scrollable Container */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 78, 59, 0.4);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  width: 440px;
  padding: 24px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(6, 78, 59, 0.2);
  overflow-y: auto;
  max-height: 90vh;
}

.modal-content h3 {
  font-size: 15px;
  margin-bottom: 4px;
  color: #064e3b;
}

.modal-content p {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* RESPONSIVE MEDIA QUERIES FOR SMALLER SCREENS & RESOLUTIONS */
@media (max-width: 1100px) {
  .gfa-grid, .no-grid, .split-layout, .sim-grid {
    flex-direction: column;
    overflow-y: auto;
  }
  .gfa-controls, .no-controls, .table-sidebar, .w-400, .w-350 {
    width: 100% !important;
    max-width: 100% !important;
  }
  .resizer-h {
    display: none;
  }
  .dashboards-grid {
    grid-template-columns: 1fr;
  }
  .split-horizontal-card {
    flex-direction: column;
    height: auto;
  }
}
