/* ── EVASIM Dynamic Simulation Environment ─────────────────────────────────── */

/* Control panel card */
.evac-sim-panel {
  border: 1px solid rgba(52, 152, 219, 0.22) !important;
  background: rgba(10, 15, 30, 0.35) !important;
  backdrop-filter: blur(6px);
  /* Must be visible so the dropdown menu can overflow outside the card */
  overflow: visible !important;
  position: relative;
  z-index: 50;
}

/* Ensure the card body doesn't clip the dropdown */
.evac-sim-panel .card-body {
  overflow: visible !important;
}

/* dcc.Dropdown menu portal — must render above Plotly charts (z-index ~10) */
.evac-sim-panel .Select-menu-outer,
.evac-sim-panel .VirtualizedSelectFocusedOption {
  z-index: 9999 !important;
}
.evac-sim-panel .Select.is-open {
  z-index: 9999 !important;
}
/* Dash 4.x / React-Select v1 fallback */
.Select-menu-outer {
  z-index: 9999 !important;
}

/* Speed + control buttons */
.evac-ctrl-btn {
  min-width: 44px;
  font-size: 14px;
  letter-spacing: 0.03em;
}

/* Simulated-time monospace display */
.evac-time-code {
  font-family: 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 14px;
  opacity: 0.75;
  letter-spacing: 0.05em;
}

/* ── Event log ─────────────────────────────────────────────────────────────── */
.evac-event-log {
  background: #080c18;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  font-family: 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.65;
  padding: 10px 12px;
  height: 250px;
  overflow-y: auto;
  color: #c0cce0;
}

/* thin custom scrollbar */
.evac-event-log::-webkit-scrollbar      { width: 4px; }
.evac-event-log::-webkit-scrollbar-track { background: transparent; }
.evac-event-log::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

/* each event line slides in */
.evac-event-item {
  padding: 2px 0 2px 8px;
  margin-bottom: 3px;
  border-radius: 0 3px 3px 0;
  animation: evac-slide-in 0.25s ease-out both;
}

@keyframes evac-slide-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Progress bar pulse when running ──────────────────────────────────────── */
.progress-bar.bg-success {
  transition: width 0.5s ease;
}

/* ── Scenario selector cards ─────────────────────────────────────────────── */
.evac-sc-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  position: relative;
  overflow: hidden;
  height: 100%;
  user-select: none;
}

.evac-sc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 10px 10px 0 0;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.evac-sc-night::before     { background: #6495ed; }
.evac-sc-risk::before      { background: linear-gradient(90deg, #c0392b, #8e44ad); }
.evac-sc-cyber::before     { background: linear-gradient(90deg, #f1c40f, #1abc9c); }
.evac-sc-day::before       { background: #f39c12; }
.evac-sc-emergency::before { background: #e74c3c; }

.evac-sc-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.07);
}

.evac-sc-night:hover,
.evac-sc-night.active {
  border-color: rgba(100, 149, 237, 0.6);
}
.evac-sc-risk:hover,
.evac-sc-risk.active {
  border-color: rgba(192, 57, 43, 0.65);
}
.evac-sc-cyber:hover,
.evac-sc-cyber.active {
  border-color: rgba(241, 196, 15, 0.65);
}
.evac-sc-day:hover,
.evac-sc-day.active {
  border-color: rgba(243, 156, 18, 0.6);
}
.evac-sc-emergency:hover,
.evac-sc-emergency.active {
  border-color: rgba(231, 76, 60, 0.6);
}

.evac-sc-card.active {
  background: rgba(255, 255, 255, 0.08);
}
.evac-sc-card.active::before { opacity: 1; }

.evac-sc-night.active     { background: rgba(100, 149, 237, 0.10); }
.evac-sc-risk.active      { background: rgba(192,  57,  43, 0.09); }
.evac-sc-cyber.active     { background: rgba(241, 196,  15, 0.08); }
.evac-sc-day.active       { background: rgba(243, 156,  18, 0.10); }
.evac-sc-emergency.active { background: rgba(231,  76,  60, 0.10); }

/* ── Light theme overrides ────────────────────────────────────────────────── */
body[data-theme="light"] .evac-sim-panel {
  border: 1px solid rgba(52, 152, 219, 0.28) !important;
  background: rgba(235, 245, 255, 0.55) !important;
}

body[data-theme="light"] .evac-event-log {
  background: #f2f5fa;
  border: 1px solid rgba(0, 0, 0, 0.09);
  color: #2c3e50;
}

body[data-theme="light"] .evac-time-code {
  color: #2c3e50;
}

body[data-theme="light"] .evac-sc-card {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.12);
}
body[data-theme="light"] .evac-sc-card:hover {
  background: rgba(0, 0, 0, 0.06);
}
body[data-theme="light"] .evac-sc-night.active    { background: rgba(100, 149, 237, 0.12); }
body[data-theme="light"] .evac-sc-risk.active     { background: rgba(192,  57,  43, 0.11); }
body[data-theme="light"] .evac-sc-cyber.active    { background: rgba(241, 196,  15, 0.10); }
body[data-theme="light"] .evac-sc-day.active      { background: rgba(243, 156,  18, 0.12); }
body[data-theme="light"] .evac-sc-emergency.active{ background: rgba(231,  76,  60, 0.12); }

/* ── GAMA headless log output ──────────────────────────────────────────────── */
.gama-hl-log {
  background-color: #0d1117;
  color: #c9d1d9;
  border: 1px solid #30363d;
}

body[data-theme="light"] .gama-hl-log {
  background-color: #f5f6f8;
  color: #2c3e50;
  border: 1px solid #d0d5dd;
}

/* ── GAMA AI Studio ────────────────────────────────────────────────────────── */

/* Root wrapper — sets a readable base for everything inside */
.ai-lab-root {
  padding: 8px 4px;
  font-size: 0.95rem;
}

/* ── Dividers ─────────────────────────────────────────────────── */
.ai-divider {
  border-color: rgba(255, 255, 255, 0.09);
  margin: 8px 0 20px;
}
body[data-theme="light"] .ai-divider {
  border-color: rgba(0, 0, 0, 0.09);
}

/* ── Parameter block (label above + control below) ───────────── */
.ai-param-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Bold, clearly readable parameter title — no opacity tricks */
.ai-param-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--bs-body-color);
  letter-spacing: 0.01em;
}

/* Secondary label for description text */
.ai-sublabel {
  font-size: 0.9rem;
  color: var(--bs-secondary-color);
  line-height: 1.5;
}

/* Status badge next to generate button */
.ai-status-badge {
  font-size: 0.85rem !important;
  padding: 6px 16px !important;
}

/* Action buttons (Save / Run) */
.ai-action-btn {
  font-size: 0.9rem !important;
  padding: 7px 18px !important;
}

/* Text inputs inside AI Lab */
.ai-text-input.form-control,
.ai-text-input textarea.form-control {
  font-size: 0.925rem !important;
  border-radius: 8px !important;
  padding: 9px 14px !important;
}

body[data-theme="dark"] .ai-text-input.form-control,
body[data-theme="dark"] .ai-text-input textarea.form-control {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  color: #e9ecef !important;
}

body[data-theme="dark"] .ai-text-input.form-control:focus,
body[data-theme="dark"] .ai-text-input textarea.form-control:focus {
  border-color: #3498db !important;
  box-shadow: 0 0 0 0.15rem rgba(52, 152, 219, 0.22);
}

/* Hero banner with subtle dot-grid texture */
.gama-ai-studio-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 80% at 0% 50%, rgba(52, 152, 219, 0.14) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 100% 50%, rgba(155, 89, 182, 0.10) 0%, transparent 70%),
    rgba(10, 18, 36, 0.55);
  border: 1px solid rgba(52, 152, 219, 0.22);
  border-left: 4px solid #3498db;
  border-radius: 14px;
  padding: 22px 26px;
  backdrop-filter: blur(8px);
}

.gama-ai-studio-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
  border-radius: inherit;
}

body[data-theme="light"] .gama-ai-studio-hero {
  background:
    radial-gradient(ellipse 70% 80% at 0% 50%, rgba(52, 152, 219, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 100% 50%, rgba(155, 89, 182, 0.05) 0%, transparent 70%),
    rgba(245, 249, 255, 0.90);
  border-color: rgba(52, 152, 219, 0.24);
  border-left-color: #2980b9;
}

body[data-theme="light"] .gama-ai-studio-hero::before {
  background-image:
    radial-gradient(circle, rgba(0,0,0,0.05) 1px, transparent 1px);
}

/* Section panels — replaces Bootstrap cards */
.gama-ai-section {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 20px 22px;
}

body[data-theme="light"] .gama-ai-section {
  background: rgba(0, 0, 0, 0.018);
  border-color: rgba(0, 0, 0, 0.08);
}

/* Form controls inside sections */
body[data-theme="dark"] .gama-ai-section .form-control {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.13) !important;
  color: #e9ecef !important;
  border-radius: 8px;
  font-size: 0.875rem !important;
}

body[data-theme="dark"] .gama-ai-section .form-control:focus {
  border-color: #3498db !important;
  box-shadow: 0 0 0 0.15rem rgba(52, 152, 219, 0.20);
}

body[data-theme="light"] .gama-ai-section .form-control {
  font-size: 0.875rem !important;
}

/* Toggle button group */
.gama-ai-toggle-group {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 !important;
  border: none !important;
  background: none !important;
}

.gama-ai-toggle {
  display: inline-flex !important;
  align-items: center;
  background: transparent !important;
  border: 1.5px solid rgba(255, 255, 255, 0.22) !important;
  border-radius: 10px !important;
  color: #d0dff0 !important;
  font-size: 0.925rem !important;
  font-weight: 500 !important;
  padding: 9px 18px !important;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
  white-space: nowrap;
  line-height: 1.3;
  min-height: 40px;
}

.gama-ai-toggle:hover {
  background: rgba(255, 255, 255, 0.10) !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
  color: #fff !important;
}

.gama-ai-toggle.active {
  background: rgba(52, 152, 219, 0.22) !important;
  border-color: #3498db !important;
  color: #c5e8ff !important;
  font-weight: 600 !important;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.18);
}

body[data-theme="light"] .gama-ai-toggle {
  border-color: rgba(0, 0, 0, 0.20) !important;
  color: #1a2a40 !important;
}

body[data-theme="light"] .gama-ai-toggle:hover {
  background: rgba(0, 0, 0, 0.07) !important;
  border-color: rgba(0, 0, 0, 0.40) !important;
  color: #0a1020 !important;
}

body[data-theme="light"] .gama-ai-toggle.active {
  background: rgba(52, 152, 219, 0.12) !important;
  border-color: #2980b9 !important;
  color: #1a5276 !important;
  font-weight: 600 !important;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.18);
}

/* Hide the actual radio input but keep accessible */
.btn-check {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}

/* Hero text elements */
.ai-hero-icon {
  font-size: 2.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.ai-hero-title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-bottom: 5px;
  color: var(--bs-body-color);
}

.ai-hero-desc {
  font-size: 0.9rem;
  color: var(--bs-secondary-color);
  line-height: 1.55;
}

.ai-model-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.ai-model-dot {
  color: #2ecc71;
  font-size: 0.85rem;
  vertical-align: middle;
}

.ai-model-name {
  font-family: 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.82rem;
  color: var(--bs-secondary-color);
  letter-spacing: 0.03em;
}

/* Generate button */
.gama-ai-gen-btn {
  font-weight: 700 !important;
  font-size: 1.05rem !important;
  letter-spacing: 0.02em !important;
  padding: 13px 44px !important;
  border-radius: 12px !important;
  background: linear-gradient(135deg, #2471a3 0%, #2980b9 50%, #3498db 100%) !important;
  border: none !important;
  box-shadow: 0 4px 20px rgba(52, 152, 219, 0.40), 0 1px 4px rgba(0,0,0,0.20) !important;
  transition: transform 0.14s ease, box-shadow 0.14s ease !important;
  min-width: 220px;
}

.gama-ai-gen-btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 7px 28px rgba(52, 152, 219, 0.55), 0 2px 8px rgba(0,0,0,0.22) !important;
}

.gama-ai-gen-btn:active {
  transform: translateY(0) !important;
  box-shadow: 0 2px 10px rgba(52, 152, 219, 0.32) !important;
}

/* Scenario preview chips */
.gama-ai-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  background: rgba(52, 152, 219, 0.10);
  border: 1px solid rgba(52, 152, 219, 0.25);
  color: #7ec8f0;
  white-space: nowrap;
}

body[data-theme="light"] .gama-ai-chip {
  background: rgba(52, 152, 219, 0.08);
  border-color: rgba(52, 152, 219, 0.28);
  color: #1a6fa0;
}

.gama-ai-preview-row {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
}

body[data-theme="light"] .gama-ai-preview-row {
  border-top-color: rgba(0, 0, 0, 0.08);
}

/* Code output */
.gama-ai-code-out {
  font-size: 14px !important;
  padding: 18px !important;
  border-radius: 10px !important;
  min-height: 280px;
  max-height: 620px;
  overflow-y: auto;
  margin: 0;
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
}

.gama-ai-code-out:empty::before {
  content: "The generated .gaml file will appear here…";
  display: block;
  text-align: center;
  padding-top: 90px;
  opacity: 0.40;
  font-size: 14px;
  font-style: italic;
  pointer-events: none;
}
html[lang="it"] .gama-ai-code-out:empty::before {
  content: "Il file .gaml generato dagli agenti AI apparirà qui…";
}

/* ── AI Chat ────────────────────────────────────────────────────────────────── */
.ai-chat-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--bs-body-color);
}

.ai-chat-hint {
  font-size: 0.925rem;
  color: var(--bs-secondary-color);
  font-style: italic;
  text-align: center;
  padding: 32px 0;
}

.ai-chat-messages {
  min-height: 240px;
  max-height: 460px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
  padding: 4px 2px;
}

.ai-chat-messages::-webkit-scrollbar      { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.ai-chat-inputrow {
  gap: 10px;
}

.ai-chat-input.form-control {
  border-radius: 24px !important;
  font-size: 0.95rem !important;
  padding: 11px 20px !important;
  min-height: 46px;
}

body[data-theme="dark"] .ai-chat-input.form-control {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  color: #e9ecef !important;
}

body[data-theme="dark"] .ai-chat-input.form-control:focus {
  border-color: #3498db !important;
  box-shadow: 0 0 0 0.15rem rgba(52, 152, 219, 0.22);
}

.ai-chat-send.btn {
  border-radius: 24px !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  padding: 11px 26px !important;
  min-height: 46px;
  white-space: nowrap;
}

.ai-chat-bubble-user {
  max-width: 78%;
  padding: 11px 18px;
  border-radius: 20px 20px 5px 20px;
  background: #2471a3;
  color: #eaf4ff;
  font-size: 0.925rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  align-self: flex-end;
}

.ai-chat-bubble-ai {
  max-width: 86%;
  padding: 11px 18px;
  border-radius: 20px 20px 20px 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.11);
  color: var(--bs-body-color);
  font-size: 0.925rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  align-self: flex-start;
}

body[data-theme="light"] .ai-chat-bubble-ai {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.09);
}

/* ── GAMA Live 3D: hero section ───────────────────────────────────────────── */
.evac-live-hero {
  --live-accent: #ff5d4d;
  position: relative;
  padding: 20px 20px 8px;
  margin-bottom: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 93, 77, 0.35);
  background:
    radial-gradient(1200px 300px at 0% 0%, rgba(255, 93, 77, 0.16), transparent 60%),
    radial-gradient(900px 300px at 100% 0%, rgba(52, 152, 219, 0.14), transparent 60%),
    rgba(10, 15, 30, 0.45);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
body[data-theme="light"] .evac-live-hero {
  background:
    radial-gradient(1200px 300px at 0% 0%, rgba(255, 93, 77, 0.12), transparent 60%),
    radial-gradient(900px 300px at 100% 0%, rgba(52, 152, 219, 0.10), transparent 60%),
    rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10);
}
.live-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.live-title {
  font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ff5d4d, #ff9f43 55%, #3498db);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.live-new-badge {
  background: linear-gradient(90deg, #ff5d4d, #ff9f43) !important;
  letter-spacing: 0.1em; font-size: 14px; animation: live-glow 2.4s ease-in-out infinite;
}
@keyframes live-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 93, 77, 0.55); }
  50%      { box-shadow: 0 0 12px 3px rgba(255, 93, 77, 0.35); }
}
.live-sub { margin-top: 4px; max-width: 900px; font-size: 0.95rem; opacity: 0.85; }
.live-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #6c757d; display: inline-block;
}
.live-head:has(.bg-success) .live-dot { background: #2ee59d; animation: live-pulse 1.3s ease-out infinite; }
.live-head:has(.bg-warning) .live-dot { background: #f1c40f; }
.live-head:has(.bg-danger) .live-dot  { background: #ff5d4d; }
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(46, 229, 157, 0.7); }
  100% { box-shadow: 0 0 0 12px rgba(46, 229, 157, 0); }
}
.live-status { font-size: 0.85rem; padding: 6px 12px; letter-spacing: 0.04em; }

/* toolbar */
.live-toolbar {
  border-radius: 14px !important; padding: 10px 12px; margin-bottom: 10px;
}
.live-toolbar-main { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.live-btn {
  font-weight: 600; padding: 7px 18px !important;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.live-btns .live-btn:first-child { border-radius: 999px 0 0 999px; }
.live-btns .live-btn:last-child  { border-radius: 0 999px 999px 0; }
.live-btn:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.12); }
.live-spf-wrap { width: 100px; }
.live-figs { margin-bottom: 6px; }
.live-fs-btn {
  margin-left: auto; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.06);
  color: inherit; border-radius: 999px; padding: 6px 14px; font-size: 0.82rem;
  transition: background 0.15s ease, transform 0.12s ease;
}
.live-fs-btn:hover { background: rgba(255, 93, 77, 0.22); transform: translateY(-1px); }
.live-adv { margin-top: 8px; }
.live-adv-sum { cursor: pointer; font-size: 0.95rem; opacity: 0.9; user-select: none; }
.live-adv-sum:hover { opacity: 1; }
.live-msg { font-size: 14px; min-height: 18px; margin: 2px 4px 8px; }

/* stage 3D */
.live-stage {
  position: relative; height: 74vh; min-height: 460px; border-radius: 16px; overflow: hidden;
  background: #0d1117; border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
}
.live-stage:fullscreen { height: 100vh; border-radius: 0; border: 0; }
.live-placeholder {
  color: rgba(230, 237, 243, 0.7); font-size: 0.95rem;
  background: radial-gradient(circle at 50% 50%, rgba(255, 93, 77, 0.10), transparent 60%);
}
.live-hud {
  position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 10px;
  flex-wrap: wrap; pointer-events: none;
}
.live-hud-chip {
  min-width: 140px; padding: 10px 16px; border-radius: 12px;
  background: rgba(13, 17, 23, 0.62); backdrop-filter: blur(10px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.10); border-left: 3px solid var(--accent);
  color: #e6edf3;
}
.live-hud-label { font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.85; }
.live-hud-value {
  font-size: 1.7rem; font-weight: 800; line-height: 1.15; color: var(--accent);
  font-variant-numeric: tabular-nums; text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 45%, transparent);
}
.live-legend {
  position: absolute; left: 12px; bottom: 12px; padding: 10px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.7; max-width: 46%; pointer-events: none; color: #e6edf3;
  background: rgba(13, 17, 23, 0.62); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.10);
}
.live-legend:empty { display: none; }
.live-hint {
  position: absolute; right: 12px; bottom: 10px; font-size: 14px; text-align: right;
  color: rgba(230, 237, 243, 0.75); text-shadow: 0 1px 2px #000; pointer-events: none;
}
.live-graph-card {
  border-radius: 14px; padding: 6px; border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 15, 30, 0.35);
}
body[data-theme="light"] .live-graph-card { border-color: rgba(0, 0, 0, 0.08); background: rgba(255, 255, 255, 0.6); }

@media (max-width: 768px) {
  .evac-live-hero { padding: 12px 10px 4px; }
  .live-stage { height: 62vh; min-height: 380px; }
  .live-hud-chip { min-width: 84px; padding: 6px 10px; }
  .live-hud-value { font-size: 1.1rem; }
  .live-fs-btn { margin-left: 0; }
}

/* ══ EVASIM — struttura grafica unificata ═════════════════════════════════════
   Un solo ritmo: sezioni con titolo, pannelli con stesso bordo/raggio/padding,
   altezze condivise (--ev-h / --ev-h-sm), griglie 50/50 e KPI a 4 colonne uguali. */
.ev-page {
  --ev-gap: 16px;
  --ev-radius: 14px;
  --ev-h: 420px;
  --ev-h-sm: 340px;
  --ev-border: rgba(255, 255, 255, 0.09);
  --ev-bg: rgba(10, 15, 30, 0.35);
  padding-top: 8px;
}
body[data-theme="light"] .ev-page {
  --ev-border: rgba(0, 0, 0, 0.10);
  --ev-bg: rgba(255, 255, 255, 0.65);
}

.ev-section { margin-bottom: 32px; }
.ev-section-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--ev-border);
}
.ev-section-title { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.ev-section-sub { font-size: 0.85rem; opacity: 0.8; }

.ev-panel {
  background: var(--ev-bg); border: 1px solid var(--ev-border); border-radius: var(--ev-radius);
  padding: 10px; min-width: 0;
}
.ev-panel .js-plotly-plot, .ev-panel .dash-graph { height: 100% !important; }
.ev-h    { height: var(--ev-h); }
.ev-h-sm { height: var(--ev-h-sm); }
.ev-flex { display: flex; flex-direction: column; }
.ev-fill { flex: 1 1 auto; min-height: 0; }
.ev-fill > .leaflet-container { border-radius: 10px; }
.ev-panel-title {
  font-size: 0.85rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  opacity: 0.85; padding: 2px 4px 8px;
}
.ev-panel .zoom-nav { margin: 8px 0 0 !important; flex: 0 0 auto; }
.ev-panel .evac-event-log { flex: 1 1 auto; height: auto; min-height: 0; }

/* controlli: stesso pannello degli altri blocchi */
.ev-control { border-radius: var(--ev-radius) !important; }
.evac-sc-card { height: 100%; border-radius: var(--ev-radius); }

/* KPI: quattro tessere identiche */
.ev-kpi {
  height: 100%; background: var(--ev-bg); border: 1px solid var(--ev-border);
  border-radius: var(--ev-radius); box-shadow: none;
}
.ev-kpi .card-body { padding: 14px 16px; }
.ev-kpi h3 { margin: 0; font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.ev-page .row.g-3 { margin-bottom: 0; }
.ev-section > .row + .row { margin-top: var(--ev-gap) !important; }
.ev-section > .row:first-of-type + .row { margin-top: var(--ev-gap) !important; }

/* hero live 3D: stessa famiglia dei pannelli (meno decorazioni, stesso raggio) */
.ev-page .evac-live-hero {
  border-radius: var(--ev-radius); border: 1px solid var(--ev-border);
  background: var(--ev-bg); box-shadow: none; padding: 16px; margin-bottom: 32px;
}
.ev-page .live-title { font-size: 1.25rem; }
.ev-page .live-toolbar { border-radius: 10px !important; }
.ev-page .live-stage { border-radius: 10px; box-shadow: none; height: 62vh; min-height: 440px; }
.ev-page .live-graph-card { border-radius: 10px; padding: 4px; }

/* scheda GAMA: pannelli coerenti */
.ev-panel-card { border-radius: var(--ev-radius); border: 1px solid rgba(128,128,128,0.2); }

@media (max-width: 991px) {
  .ev-page { --ev-h: 360px; --ev-h-sm: 300px; }
  .ev-section { margin-bottom: 24px; }
}

/* ── Leggibilita': testi minimi e contrasto ─────────────────────────────────── */
.ev-page .text-muted, .ev-page .evac-sc-card, .ev-page small { opacity: 1; }
.ev-page .evac-sc-card div:last-child { font-size: 14px; opacity: 0.85 !important; line-height: 1.45; }
.ev-page .live-btn { font-size: 0.95rem; }
.ev-page .live-hint { font-size: 14px; max-width: 40%; }
.ev-page label.form-check-label, .ev-page .live-figs label { font-size: 0.95rem !important; }
.ev-panel-card code, .ev-panel-card .gama-hl-log { font-size: 14px !important; }
.gama-hl-log { font-size: 14px !important; line-height: 1.5; max-height: 280px !important; }
.ev-panel-card label { font-size: 0.95rem !important; }
.ev-panel-card .badge { font-size: 0.85rem !important; }
.ev-panel-card input[type=number], .ev-panel-card input.form-control { font-size: 0.95rem; }

/* testi descrittivi: abbreviati e piu' grandi */
.live-placeholder { font-size: 1.35rem !important; font-weight: 600; }
.ev-page .live-hint { font-size: 14px; max-width: 46%; }
.ai-hero-desc { font-size: 1.05rem; }
.ai-chat-hint { font-size: 1.05rem; }
#evac-metodologia p, #evac-metodologia li { font-size: 1.05rem; line-height: 1.6; }

/* Selettore vista 2D / 3D sul riquadro della simulazione */
.live-viewmode {
  position: absolute; right: 12px; bottom: 64px; z-index: 6; display: inline-flex;
  border-radius: 999px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(13, 17, 23, 0.7); backdrop-filter: blur(8px);
}
.live-view-btn {
  border: 0; background: transparent; color: #e6edf3; padding: 7px 16px; font-size: 0.95rem;
  font-weight: 700; letter-spacing: 0.04em; cursor: pointer; min-width: 52px;
  transition: background 0.15s ease, color 0.15s ease;
}
.live-view-btn:hover { background: rgba(255, 255, 255, 0.14); }
/* senza attributo (prima del primo disegno) vale il 2D, la vista predefinita */
.live-stage:not([data-view="3d"]) .live-view-btn[data-view="2d"],
.live-stage[data-view="3d"] .live-view-btn[data-view="3d"] { background: #ff5d4d; color: #fff; }
@media (max-width: 576px) { .live-viewmode { bottom: 70px; } .live-view-btn { padding: 8px 14px; } }

/* Testo dei pulsanti del riquadro: centrato verticalmente (icona e parola sulla stessa linea di mezzeria) */
.live-fs-btn, .live-view-btn {
  display: inline-flex; align-items: center; justify-content: center; line-height: 1; box-sizing: border-box;
}
.live-fs-btn { height: 38px; gap: 8px; padding: 0 16px; }
.live-fs-btn > span { display: inline-flex; align-items: center; line-height: 1; }
.live-fs-ico { font-size: 1.15em; transform: translateY(-1px); }
.live-view-btn { height: 36px; padding: 0 16px; }
@media (max-width: 576px) { .live-view-btn { height: 40px; padding: 0 14px; } }

/* ── Pannello "Parametri della simulazione" ─────────────────────────────────── */
.sp-panel {
  margin: 4px 0 10px; border: 1px solid rgba(52, 152, 219, 0.35); border-radius: 14px;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.10), rgba(46, 229, 157, 0.05));
  overflow: hidden;
}
.sp-summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; user-select: none; font-weight: 700; font-size: 1.02rem;
  transition: background 0.15s ease;
}
.sp-summary::-webkit-details-marker { display: none; }
.sp-summary:hover { background: rgba(52, 152, 219, 0.12); }
.sp-ico { font-size: 1.25rem; line-height: 1; margin-right: 2px; }
.sp-sum-sub { font-weight: 400; font-size: 0.85rem; opacity: 0.65; }
.sp-chev { margin-left: auto; font-size: 1.1rem; padding: 2px 10px; border-radius: 999px;
  background: rgba(52, 152, 219, 0.25); transition: transform 0.2s ease; }
.sp-panel:not([open]) .sp-chev { transform: rotate(-90deg); }
.sp-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 4px 14px 8px; }
.sp-card {
  display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: rgba(10, 15, 30, 0.35); border: 1px solid rgba(255, 255, 255, 0.09);
}
.sp-card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.95rem;
  padding-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.09); }
.sp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.sp-wide { grid-column: 1 / -1; }
.sp-field { min-width: 0; }
.sp-label { display: block; font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase;
  opacity: 0.75; margin-bottom: 3px; }
.sp-hint { font-size: 0.75rem; opacity: 0.6; margin-top: 2px; }
.sp-card-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: auto; }
.sp-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 14px 14px; }
body[data-theme="light"] .sp-panel { border-color: rgba(41, 128, 185, 0.4); }
body[data-theme="light"] .sp-card { background: rgba(255, 255, 255, 0.75); border-color: rgba(0, 0, 0, 0.1); }
body[data-theme="light"] .sp-card-title { border-bottom-color: rgba(0, 0, 0, 0.1); }
@media (max-width: 820px) {
  .sp-cards { grid-template-columns: 1fr; }
}

/* ── Parametri: rifinitura di pulsanti e controlli (solo aspetto) ───────────── */
.sp-panel .btn {
  border-radius: 999px; font-weight: 600; letter-spacing: 0.02em; padding: 7px 18px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.12s ease, background 0.15s ease;
}
.sp-panel .btn:hover { transform: translateY(-1px); }
.sp-panel .btn:active { transform: translateY(0) scale(0.98); }
.sp-panel .btn:focus-visible { outline: 2px solid #5dade2; outline-offset: 2px; box-shadow: none; }
.sp-panel .btn-primary {
  border: 0; background: linear-gradient(135deg, #3498db, #2575c4);
  box-shadow: 0 4px 14px rgba(52, 152, 219, 0.40);
}
.sp-panel .btn-primary:hover { filter: brightness(1.1); box-shadow: 0 6px 18px rgba(52, 152, 219, 0.55); }
.sp-panel .btn-outline-secondary { border-width: 1.5px; border-color: rgba(255, 255, 255, 0.28); color: inherit; }
.sp-panel .btn-outline-secondary:hover { background: rgba(52, 152, 219, 0.18); border-color: #5dade2; color: inherit; }
body[data-theme="light"] .sp-panel .btn-outline-secondary { border-color: rgba(0, 0, 0, 0.28); }
#gama-p-random { background: linear-gradient(135deg, rgba(155, 89, 182, 0.28), rgba(52, 152, 219, 0.22)); border-color: rgba(155, 89, 182, 0.6); }
.sp-actions { padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.07); margin: 0 14px; padding-left: 0; padding-right: 0; }
body[data-theme="light"] .sp-actions { border-top-color: rgba(0, 0, 0, 0.08); }

.sp-panel .form-control, .sp-panel .form-select, .sp-panel .input-group-text {
  border-radius: 10px; background-color: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.16);
  color: inherit; font-variant-numeric: tabular-nums; font-weight: 600;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.sp-panel .input-group > .form-control { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.sp-panel .input-group > .input-group-text { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0;
  font-size: 0.78rem; font-weight: 500; opacity: 0.8; min-width: 44px; justify-content: center; }
.sp-panel .form-control:hover, .sp-panel .form-select:hover { border-color: rgba(93, 173, 226, 0.65); }
.sp-panel .form-control:focus, .sp-panel .form-select:focus {
  border-color: #5dade2; background-color: rgba(52, 152, 219, 0.12); box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.28);
  color: inherit;
}
.sp-panel .form-select option { color: #111; }
body[data-theme="light"] .sp-panel .form-control, body[data-theme="light"] .sp-panel .form-select,
body[data-theme="light"] .sp-panel .input-group-text { background-color: #fff; border-color: rgba(0, 0, 0, 0.2); }
.sp-panel input[type=number] { -moz-appearance: textfield; }
.sp-panel input[type=number]::-webkit-inner-spin-button { opacity: 0.55; cursor: pointer; }
.sp-panel input[type=number]:hover::-webkit-inner-spin-button { opacity: 1; }
.sp-card { transition: border-color 0.15s ease, transform 0.15s ease; }
.sp-card:hover { border-color: rgba(93, 173, 226, 0.4); }
.sp-card-title { color: #7fb8e6; }
body[data-theme="light"] .sp-card-title { color: #1f6fa8; }

/* ── Personalizzazione scenario sotto la simulazione ── */
.sc-preview { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 14px 4px; }
.sc-chip { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; font-size: 0.85rem;
  font-weight: 600; background: rgba(52, 152, 219, 0.16); border: 1px solid rgba(52, 152, 219, 0.4); }
.sc-chip:last-child { background: transparent; border-style: dashed; font-weight: 400; opacity: 0.7; }
.sp-panel .ai-param-block { height: 100%; }
.sp-panel .gama-ai-toggle-group { flex-wrap: wrap; }
