/* ============================================================
   Cahors Virtual Charging Station - Real-Time Simulation
   Companion stylesheet for the simulation page.
   Design system: Material Design, Roboto, Cahors brand tokens.
   ============================================================ */

/* -------------------------------------------------------
   OFFLINE BANNER (exponential backoff)
   ------------------------------------------------------- */
.sim-offline-banner {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 8px 16px; background: #FFF3E0; color: #E65100;
  font-size: 13px; font-weight: 500; border-bottom: 2px solid #FF9800;
  animation: sim-pulse-banner 2s ease-in-out infinite;
}
.sim-offline-banner .mdi { font-size: 18px; }
@keyframes sim-pulse-banner {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* -------------------------------------------------------
   0. DESIGN TOKENS (local custom properties)
   ------------------------------------------------------- */
:root {
  --sim-green: #4CAF50;
  --sim-green-dark: #388E3C;
  --sim-blue: #2196F3;
  --sim-blue-dark: #1565C0;
  --sim-orange: #FF9800;
  --sim-red: #f44336;
  --sim-red-dark: #D32F2F;
  --sim-grey: #9E9E9E;
  --sim-bg: #f5f5f5;
  --sim-card: #fff;
  --sim-border: #e0e0e0;
  --sim-text-primary: rgba(0, 0, 0, 0.87);
  --sim-text-secondary: #666;
  --sim-text-hint: #999;
  --sim-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --sim-radius: 10px;
  --sim-radius-sm: 8px;
  --sim-radius-lg: 12px;
  --sim-transition: 0.3s ease;
}
[data-theme="dark"] {
  --sim-green: #66BB6A;
  --sim-green-dark: #4CAF50;
  --sim-blue: #42A5F5;
  --sim-blue-dark: #1E88E5;
  --sim-bg: #1a1a2e;
  --sim-card: #16213e;
  --sim-border: #2a2a4a;
  --sim-text-primary: #e0e0e0;
  --sim-text-secondary: rgba(255,255,255,.6);
  --sim-text-hint: rgba(255,255,255,.35);
  --sim-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* -------------------------------------------------------
   1. LAYOUT
   ------------------------------------------------------- */
/* Override parent .main-content padding when simulation is active */
.main-content:has(.sim-page) {
  padding: 0 !important;
  padding-top: 64px !important;   /* just clear the fixed app-bar */
  overflow: hidden !important;
  height: 100vh !important;
  box-sizing: border-box !important;
}
/* Hide footer when simulation is active */
body:has(.sim-page) > .app-footer {
  display: none;
}

.sim-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--sim-bg);
  font-family: 'Roboto', sans-serif;
  color: var(--sim-text-primary);
}

/* --- Control Bar (sticky top strip) --- */
.sim-control-bar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--sim-card);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.sim-control-bar button,
.sim-control-bar select {
  font-family: 'Roboto', sans-serif;
  font-size: 0.85rem;
  outline: none;
}

/* --- Main area (content + fault panel) --- */
.sim-main {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sim-content {
  flex: 1;
  min-width: 0;            /* prevent overflow in flex child */
  padding: 16px 20px;
  overflow-y: auto;
}

/* -------------------------------------------------------
   2. TAB NAVIGATION
   ------------------------------------------------------- */
.sim-tabs {
  display: flex;
  flex-direction: row;
  border-bottom: 2px solid var(--sim-border);
  background: var(--sim-card);
  overflow-x: auto;
}

.sim-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sim-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--sim-transition),
              border-color var(--sim-transition),
              background var(--sim-transition);
  user-select: none;
}

.sim-tab--active {
  border-bottom-color: var(--sim-blue);
  font-weight: 700;
  color: var(--sim-blue);
}

.sim-tab:hover {
  background: rgba(33, 150, 243, 0.05);
}

/* Alert dots on tabs */
.sim-tab .sim-alert-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sim-alert-dot--ok {
  background: var(--sim-green);
}

.sim-alert-dot--warn {
  background: var(--sim-orange);
  animation: pulse-warn 1.8s ease-in-out infinite;
}

.sim-alert-dot--fault {
  background: var(--sim-red);
  animation: pulse-fault 1s ease-in-out infinite;
}

/* -------------------------------------------------------
   3. TAB PANELS
   ------------------------------------------------------- */
.sim-panel {
  display: none;
}

.sim-panel--active {
  display: block;
}

.sim-panel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* -------------------------------------------------------
   4. GAUGE CARDS
   ------------------------------------------------------- */
.sim-gauge-card {
  background: var(--sim-card);
  padding: 16px;
  border-radius: var(--sim-radius);
  box-shadow: var(--sim-shadow);
  text-align: center;
  transition: border-color var(--sim-transition),
              background var(--sim-transition),
              box-shadow var(--sim-transition);
}

.sim-gauge-card--warn {
  border-left: 4px solid var(--sim-orange);
}

.sim-gauge-card--fault {
  border-left: 4px solid var(--sim-red);
  background: rgba(244, 67, 54, 0.03);
}

.sim-gauge-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.sim-gauge-value--green  { color: var(--sim-green); }
.sim-gauge-value--orange { color: var(--sim-orange); }
.sim-gauge-value--red    { color: var(--sim-red); }
.sim-gauge-value--blue   { color: var(--sim-blue); }

.sim-gauge-label {
  font-size: 0.8rem;
  color: var(--sim-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 4px;
}

.sim-gauge-unit {
  font-size: 0.9rem;
  color: var(--sim-text-hint);
}

/* -------------------------------------------------------
   5. WAVEFORM / CHART CONTAINERS
   ------------------------------------------------------- */
.sim-chart-container {
  background: var(--sim-card);
  padding: 16px;
  border-radius: var(--sim-radius);
  box-shadow: var(--sim-shadow);
  margin-bottom: 16px;
}

.sim-chart-container canvas {
  width: 100%;
  max-height: 250px;
}

.sim-chart-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--sim-text-primary);
}

/* -------------------------------------------------------
   6. SoC PROGRESS BAR
   ------------------------------------------------------- */
.sim-soc-bar {
  position: relative;
  height: 24px;
  background: #e0e0e0;
  border-radius: 12px;
  overflow: hidden;
  margin: 12px 0;
}

.sim-soc-fill {
  height: 100%;
  border-radius: 12px;
  transition: width 0.5s ease;
}

.sim-soc-fill--low {
  background: linear-gradient(90deg, #FF9800, #FFC107);
}

.sim-soc-fill--mid {
  background: linear-gradient(90deg, #2196F3, #42A5F5);
}

.sim-soc-fill--high {
  background: linear-gradient(90deg, #4CAF50, #66BB6A);
}

.sim-soc-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

/* -------------------------------------------------------
   7. TEMPERATURE GAUGE
   ------------------------------------------------------- */
.sim-temp-gauge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sim-temp-bar {
  width: 100px;
  height: 8px;
  border-radius: 4px;
  background: #e0e0e0;
  overflow: hidden;
}

.sim-temp-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.sim-temp-fill--cold { background: var(--sim-blue); }
.sim-temp-fill--warm { background: var(--sim-orange); }
.sim-temp-fill--hot  { background: var(--sim-red); }

/* -------------------------------------------------------
   8. ENERGY CHAIN DIAGRAM
   ------------------------------------------------------- */
.sim-energy-chain {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 16px;
  overflow-x: auto;
}

.sim-energy-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--sim-radius);
  background: var(--sim-card);
  border: 2px solid var(--sim-border);
  min-width: 100px;
  transition: border-color var(--sim-transition),
              background var(--sim-transition),
              box-shadow var(--sim-transition);
}

.sim-energy-node--active {
  border-color: var(--sim-green);
  background: rgba(76, 175, 80, 0.05);
  box-shadow: 0 0 12px rgba(76, 175, 80, 0.3);
}

.sim-energy-node--fault {
  border-color: var(--sim-red);
  background: rgba(244, 67, 54, 0.05);
}

.sim-energy-node__icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.sim-energy-node__label {
  font-size: 0.75rem;
  color: var(--sim-text-secondary);
}

.sim-energy-node__value {
  font-weight: 700;
  font-size: 0.9rem;
}

/* Energy flow arrows */
.sim-energy-arrow {
  position: relative;
  width: 40px;
  height: 2px;
  background: var(--sim-green);
  flex-shrink: 0;
}

.sim-energy-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--sim-green);
}

.sim-energy-arrow--animated {
  background: repeating-linear-gradient(
    90deg,
    var(--sim-green) 0px,
    var(--sim-green) 6px,
    transparent 6px,
    transparent 12px
  );
  background-size: 40px 2px;
  animation: flow 1s linear infinite;
}

/* -------------------------------------------------------
   9. OCPP TERMINAL
   ------------------------------------------------------- */
.sim-ocpp-terminal {
  background: #263238;
  border-radius: var(--sim-radius);
  padding: 16px;
  font-family: 'Roboto Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  max-height: 400px;
  overflow-y: auto;
  color: #CFD8DC;
}

.sim-ocpp-entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sim-ocpp-entry__ts {
  color: #78909C;
  margin-right: 8px;
}

.sim-ocpp-entry__dir--cs {
  color: var(--sim-green);
  margin-right: 6px;
}

.sim-ocpp-entry__dir--csms {
  color: var(--sim-blue);
  margin-right: 6px;
}

.sim-ocpp-entry__action {
  color: #FFC107;
  font-weight: 600;
  margin-right: 6px;
}

.sim-ocpp-entry__payload {
  color: #90A4AE;
  font-size: 0.75rem;
  display: none;
  margin-top: 4px;
  padding-left: 16px;
  white-space: pre-wrap;
  word-break: break-all;
}

.sim-ocpp-entry:hover .sim-ocpp-entry__payload {
  display: block;
}

.sim-ocpp-status-bar {
  display: flex;
  flex-direction: row;
  gap: 24px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--sim-radius-sm);
  margin-bottom: 12px;
  font-size: 0.8rem;
}

/* -------------------------------------------------------
   10. FAULT PANEL (right sidebar)
   ------------------------------------------------------- */
.sim-fault-panel {
  width: 340px;
  background: var(--sim-card);
  border-left: 1px solid var(--sim-border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px;
  flex-shrink: 0;
  height: 100%;
  transition: width var(--sim-transition), padding var(--sim-transition);
}
.sim-fault-panel::-webkit-scrollbar { width: 6px; }
.sim-fault-panel::-webkit-scrollbar-track { background: transparent; }
.sim-fault-panel::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 3px; }

.sim-fault-panel--collapsed {
  width: 48px;
  overflow: hidden;
  padding: 8px;
}

.sim-fault-panel__toggle {
  position: sticky;
  top: 0;
  z-index: 5;
  width: 100%;
  height: 26px;
  cursor: pointer;
  background: var(--sim-card);
  border-bottom: 1px solid var(--sim-border);
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  font-size: 0.9rem;
  color: var(--sim-text-secondary);
  transition: transform var(--sim-transition);
}

.sim-fault-panel--collapsed .sim-fault-panel__toggle {
  transform: rotate(180deg);
}

.sim-fault-panel__title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--sim-text-primary);
}

.sim-fault-panel__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--sim-red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 8px;
  vertical-align: middle;
}

/* -------------------------------------------------------
   11. FAULT CARDS
   ------------------------------------------------------- */
.sim-fault-card {
  border: 1px solid var(--sim-border);
  border-radius: var(--sim-radius-sm);
  padding: 5px 10px;
  margin-bottom: 4px;
  transition: all var(--sim-transition);
}

.sim-fault-card--expanded {
  padding: 8px 10px;
  margin-bottom: 6px;
}

.sim-fault-card--active {
  border-color: var(--sim-red);
  background: rgba(244, 67, 54, 0.03);
  box-shadow: 0 2px 8px rgba(244, 67, 54, 0.15);
}

.sim-fault-card__header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 1px 0;
  font-size: 0.82rem;
}

.sim-fault-card__header:hover {
  opacity: 0.8;
}

/* Chevron indicator */
.sim-fault-card__chevron {
  font-size: 0.7rem;
  color: var(--sim-text-hint);
  transition: transform 0.25s ease;
  margin-left: 6px;
  flex-shrink: 0;
}

.sim-fault-card--expanded .sim-fault-card__chevron {
  transform: rotate(90deg);
}

/* Status dot on collapsed cards */
.sim-fault-card__status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  margin-left: 6px;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.sim-fault-card--active .sim-fault-card__status-dot {
  background: var(--sim-red);
  box-shadow: 0 0 6px rgba(244, 67, 54, 0.6);
  animation: sim-pulse-dot 1.5s infinite;
}

@keyframes sim-pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sim-fault-card__name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-fault-card__direction {
  font-size: 0.7rem;
  color: var(--sim-text-hint);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sim-fault-card__direction .arrow--grid-to-car { color: var(--sim-blue); }
.sim-fault-card__direction .arrow--car-to-grid { color: var(--sim-orange); }
.sim-fault-card__direction .arrow--internal    { color: var(--sim-grey); }

/* Accordion: body hidden by default, shown when expanded */
.sim-fault-card__body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, padding-top 0.3s ease;
}

.sim-fault-card--expanded .sim-fault-card__body {
  max-height: 500px;
  overflow: visible;
  opacity: 1;
  padding-top: 10px;
}

/* Severity buttons */
.sim-fault-card__severity {
  display: flex;
  flex-direction: row;
  gap: 6px;
}

.sim-fault-card__sev-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  border: 1px solid #ddd;
  cursor: pointer;
  background: var(--sim-card);
  font-family: 'Roboto', sans-serif;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.sim-fault-card__sev-btn:hover {
  background: #f5f5f5;
}

.sim-fault-card__sev-btn--selected {
  background: var(--sim-red);
  color: #fff;
  border-color: var(--sim-red);
}

.sim-fault-card__sev-btn--low.sim-fault-card__sev-btn--selected {
  background: var(--sim-orange);
  border-color: var(--sim-orange);
}

.sim-fault-card__sev-btn--medium.sim-fault-card__sev-btn--selected {
  background: #FF5722;
  border-color: #FF5722;
}

/* Fault parameters (slider controls) */
.sim-fault-card__param {
  margin-top: 8px;
}

.sim-fault-card__param label {
  display: block;
  font-size: 0.75rem;
  color: var(--sim-text-secondary);
  margin-bottom: 4px;
}

.sim-fault-card__param input[type="range"] {
  width: 100%;
  accent-color: var(--sim-red);
}

.sim-fault-card__param .param-value {
  font-weight: 600;
  font-size: 0.85rem;
}

/* -------------------------------------------------------
   12. FAULT PROPAGATION CHAIN
   ------------------------------------------------------- */
.sim-propagation {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  margin-top: 8px;
  padding: 8px 0;
  overflow-x: auto;
}

.sim-propagation__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}

.sim-propagation__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e0e0e0;
  transition: all var(--sim-transition);
}

.sim-propagation__dot--active {
  background: var(--sim-red);
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
}

.sim-propagation__dot--warn {
  background: var(--sim-orange);
  box-shadow: 0 0 8px rgba(255, 152, 0, 0.5);
}

.sim-propagation__line {
  width: 20px;
  height: 2px;
  background: #e0e0e0;
  flex-shrink: 0;
  transition: background var(--sim-transition);
}

.sim-propagation__line--active {
  background: var(--sim-red);
}

.sim-propagation__label {
  font-size: 0.6rem;
  color: var(--sim-text-hint);
  max-width: 60px;
  text-align: center;
  margin-top: 4px;
  line-height: 1.2;
}

/* -------------------------------------------------------
   13. FAULT ACTION BUTTONS
   ------------------------------------------------------- */
.sim-fault-card__actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 10px;
}

.sim-btn-inject {
  padding: 6px 16px;
  border-radius: var(--sim-radius-sm);
  background: var(--sim-red);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  font-family: 'Roboto', sans-serif;
  transition: background 0.2s;
}

.sim-btn-inject:hover {
  background: var(--sim-red-dark);
}

.sim-btn-inject:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.sim-btn-clear {
  padding: 6px 16px;
  border-radius: var(--sim-radius-sm);
  background: var(--sim-grey);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  font-family: 'Roboto', sans-serif;
  transition: background 0.2s;
}

.sim-btn-clear:hover {
  background: #757575;
}

.sim-btn-reset-all {
  width: 100%;
  padding: 10px;
  background: var(--sim-red);
  color: #fff;
  border: none;
  border-radius: var(--sim-radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: 'Roboto', sans-serif;
  margin-top: 16px;
  transition: background 0.2s;
}

.sim-btn-reset-all:hover {
  background: var(--sim-red-dark);
}

/* -------------------------------------------------------
   14. CONTROL BAR BUTTONS & BADGES
   ------------------------------------------------------- */
.sim-btn {
  padding: 8px 20px;
  border-radius: var(--sim-radius-sm);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: 'Roboto', sans-serif;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sim-btn--plug           { background: var(--sim-blue);  color: #fff; }
.sim-btn--plug:hover     { background: #1976D2; }
.sim-btn--start          { background: var(--sim-green); color: #fff; }
.sim-btn--start:hover    { background: var(--sim-green-dark); }
.sim-btn--stop           { background: var(--sim-red);   color: #fff; }
.sim-btn--stop:hover     { background: var(--sim-red-dark); }

.sim-btn:disabled {
  background: #e0e0e0;
  color: var(--sim-text-hint);
  cursor: not-allowed;
}

.sim-select {
  padding: 8px 12px;
  border-radius: var(--sim-radius-sm);
  border: 1px solid #ddd;
  font-size: 0.85rem;
  font-family: 'Roboto', sans-serif;
  background: var(--sim-card);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.sim-select:focus {
  border-color: var(--sim-blue);
}

/* FSM State Badges */
.sim-fsm-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.sim-fsm-badge--available { background: #E8F5E9; color: #2E7D32; }
.sim-fsm-badge--preparing { background: #FFF3E0; color: #E65100; }
.sim-fsm-badge--charging  { background: #E3F2FD; color: #1565C0; }
.sim-fsm-badge--faulted   { background: #FFEBEE; color: #C62828; }
.sim-fsm-badge--finishing  { background: #F3E5F5; color: #6A1B9A; }
.sim-fsm-badge--suspended  { background: #FFF8E1; color: #F57F17; }

/* OCPP Live quick link in control bar */
.sim-ocpp-link {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 8px;
  font-size: 11px; font-weight: 500; color: #4CAF50; text-decoration: none;
  padding: 4px 10px; border-radius: 12px; background: #E8F5E9;
  transition: all .2s; white-space: nowrap;
}
.sim-ocpp-link:hover { background: #C8E6C9; color: #2E7D32; }
.sim-ocpp-link .mdi { font-size: 14px; }

/* FAULTED banner (link to Dépannage) */
.sim-fault-banner {
  background: linear-gradient(135deg, #C62828, #D32F2F);
  color: #fff;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  box-shadow: 0 2px 8px rgba(198,40,40,.3);
  animation: sim-fault-pulse 2s ease-in-out infinite;
}
.sim-fault-banner .mdi { font-size: 20px; }
@keyframes sim-fault-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .85; }
}

/* -------------------------------------------------------
   14b. DEMO MODE
   ------------------------------------------------------- */
.sim-btn--demo {
  background: #f0f9ff;
  color: #0284c7;
  border: 2px solid #0284c7;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}
.sim-btn--demo:hover {
  background: #e0f2fe;
}
.sim-btn--demo-active {
  background: #0284c7;
  color: #fff;
  animation: demo-pulse 2s ease-in-out infinite;
}
@keyframes demo-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(2,132,199,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(2,132,199,0); }
}

.sim-page--demo {
  border: 3px solid #0284c7;
  border-radius: 8px;
}
.sim-page--demo::before {
  content: "MODE D\00C9MONSTRATION \2014  D\00E9fauts sans coupure";
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: #0284c7;
  color: white;
  padding: 4px 24px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 0 0 8px 8px;
  z-index: 1000;
  pointer-events: none;
}

/* -------------------------------------------------------
   15. NORMS REFERENCE BOX
   ------------------------------------------------------- */
.sim-norms-box {
  background: var(--sim-card);
  border: 1px solid var(--sim-border);
  border-radius: var(--sim-radius-sm);
  padding: 12px;
  font-size: 0.8rem;
  color: var(--sim-text-secondary);
  line-height: 1.6;
}

.sim-norms-box strong {
  color: var(--sim-text-primary);
}

/* -------------------------------------------------------
   16. KEYFRAME ANIMATIONS
   ------------------------------------------------------- */
@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes pulse-fault {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.7; transform: scale(1.2); }
}

@keyframes flow {
  from { background-position: 0 0; }
  to   { background-position: 40px 0; }
}

/* -------------------------------------------------------
   17. RESPONSIVE BREAKPOINTS
   ------------------------------------------------------- */

/* -- Below 1200px: collapse fault panel -- */
@media (max-width: 1200px) {
  .sim-fault-panel {
    width: 48px;
    overflow: hidden;
    padding: 8px;
  }

  .sim-fault-panel__title,
  .sim-fault-card,
  .sim-btn-reset-all {
    display: none;
  }

  .sim-fault-panel--collapsed .sim-fault-panel__toggle {
    left: 8px;
  }
}

/* -------------------------------------------------------
   18. GRID SUPPLY CONTROL BAR (Linky)
   ------------------------------------------------------- */
.sim-grid-bar {
  background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
  color: #fff;
  padding: 0;
  border-bottom: 2px solid #3949ab;
}

.sim-grid-bar__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.sim-grid-bar__header:hover {
  background: rgba(255,255,255,0.06);
}

.sim-grid-bar__icon { font-size: 1.3rem; }

.sim-grid-bar__title {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex: 1;
}

.sim-grid-bar__toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: transform 0.25s;
}

.sim-grid-bar--open .sim-grid-bar__toggle {
  transform: rotate(180deg);
}

.sim-grid-bar__body {
  display: none;
  flex-flow: row wrap;
  align-items: flex-end;
  gap: 16px;
  padding: 0 20px 14px;
}

.sim-grid-bar--open .sim-grid-bar__body {
  display: flex;
}

.sim-grid-mode {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-grid-mode label {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.sim-grid-mode select {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
}

.sim-grid-mode select option {
  background: #1a237e;
  color: #fff;
}

.sim-grid-sliders {
  display: flex;
  flex-flow: row wrap;
  gap: 14px;
}

.sim-grid-slider {
  display: flex;
  flex-direction: column;
  min-width: 130px;
}

.sim-grid-slider label {
  font-size: 0.72rem;
  margin-bottom: 2px;
  color: rgba(255,255,255,0.8);
}

.sim-grid-slider input[type="range"] {
  width: 100%;
  accent-color: #64b5f6;
  height: 4px;
}

.sim-grid-slider .param-value {
  font-weight: 700;
  color: #fff;
}

.sim-grid-info {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(255,255,255,0.1);
  padding: 6px 14px;
  border-radius: 8px;
  white-space: nowrap;
}

.sim-grid-info span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* -------------------------------------------------------
   19. PWM / CP OSCILLOSCOPE
   ------------------------------------------------------- */
.sim-pwm-scope {
  background: #0f1419;
  border: 1px solid #1e293b;
  border-radius: var(--sim-radius);
  overflow: hidden;
  margin-top: 16px;
}

.sim-pwm-scope__title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 6px;
  color: #e2e8f0;
  font-size: 0.9rem;
  font-weight: 600;
}

.sim-cp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #64748b;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  transition: background 0.3s ease;
}

.sim-pwm-scope canvas {
  display: block;
  width: 100%;
  height: 200px;
}

.sim-pwm-legend {
  display: flex;
  gap: 16px;
  padding: 6px 16px 4px;
  font-size: 0.72rem;
  color: #94a3b8;
}

.sim-pwm-legend__item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sim-pwm-info {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 4px 16px 10px;
  font-size: 0.78rem;
  color: #94a3b8;
}

.sim-pwm-info strong {
  color: #e2e8f0;
  font-family: 'Roboto Mono', monospace;
  transition: color 0.3s ease;
}

/* DDR status animations for earth fault indicators */
.sim-pwm-info .sim-ddr-warning {
  animation: pulse-warn 1.8s ease-in-out infinite;
}
.sim-pwm-info .sim-ddr-trip {
  animation: pulse-fault 1s ease-in-out infinite;
  color: #ef4444 !important;
}
.sim-pwm-info .sim-thd-warning {
  animation: pulse-warn 1.8s ease-in-out infinite;
  color: #fbbf24 !important;
}

/* -- Below 768px: single-column grid, control bar wraps -- */
@media (max-width: 768px) {
  .sim-panel__grid {
    grid-template-columns: 1fr;
  }

  .sim-control-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
  }

  .sim-energy-chain {
    flex-wrap: wrap;
    gap: 8px;
  }

  .sim-energy-arrow {
    width: 24px;
  }

  .sim-fault-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--sim-border);
  }

  .sim-main {
    flex-direction: column;
  }

  .sim-content {
    padding: 12px;
  }

  .sim-ocpp-terminal {
    max-height: 280px;
    font-size: 0.7rem;
  }

  .sim-grid-bar__body {
    flex-direction: column;
    align-items: stretch;
  }

  .sim-grid-sliders {
    flex-direction: column;
  }

  .sim-grid-info {
    flex-wrap: wrap;
  }

  .sim-scenario-bar {
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px;
  }

  .sim-scenario-btn {
    font-size: 0.65rem;
    padding: 3px 6px;
  }
}

/* -------------------------------------------------------
   18. SCENARIO BAR
   ------------------------------------------------------- */
.sim-scenario-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--sim-card);
  border-bottom: 1px solid var(--sim-border);
  flex-wrap: wrap;
}

.sim-scenario-bar__label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sim-text-primary);
  white-space: nowrap;
}

.sim-scenario-btn {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid var(--sim-border);
  border-radius: 6px;
  background: var(--sim-card);
  color: var(--sim-text-primary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.sim-scenario-btn:hover {
  background: var(--sim-bg);
  border-color: var(--sim-text-hint);
}

.sim-scenario-btn--active {
  background: #1e40af;
  color: #fff;
  border-color: #1e40af;
}

/* -------------------------------------------------------
   19. OCPP FILTER BUTTONS
   ------------------------------------------------------- */
.sim-ocpp-filters {
  background: var(--sim-bg);
  border-bottom: 1px solid var(--sim-border);
}

.sim-ocpp-filter-btn {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border: 1px solid var(--sim-border);
  border-radius: 4px;
  background: var(--sim-card);
  color: var(--sim-text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.sim-ocpp-filter-btn:hover {
  background: var(--sim-bg);
}

.sim-ocpp-filter-btn--active {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
}

/* OCPP entry payload: collapsible JSON */
.sim-ocpp-entry__payload--collapsed {
  max-height: 1.4em;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.sim-ocpp-entry__payload--collapsed::after {
  content: " \u25BC";
  color: #94a3b8;
  font-size: 0.6rem;
}
.sim-ocpp-entry__payload:not(.sim-ocpp-entry__payload--collapsed) {
  cursor: pointer;
}

/* -------------------------------------------------------
   20. LEAKAGE DIAGNOSTIC PANEL
   ------------------------------------------------------- */
.sim-leakage-diag {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
  padding: 10px 14px;
  margin: 12px 0;
}

.sim-leakage-diag .sim-gauge-card {
  padding: 6px;
  min-width: 0;
}

.sim-leakage-diag .sim-gauge-label {
  font-size: 0.65rem;
}

.sim-leakage-diag .sim-gauge-value {
  font-size: 1rem;
}

/* -------------------------------------------------------
   21. ENHANCED DEMO BADGES
   ------------------------------------------------------- */
.sim-fault-card__would-trip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
  animation: pulse-warn 1.5s ease-in-out infinite;
  white-space: nowrap;
}

.sim-fault-card__would-trip small {
  font-weight: 500;
  font-size: 0.6rem;
  opacity: 0.85;
}

/* ============================================================
   TAB 5: BOXEO LOGS — irve-manager.log real-time terminal
   ============================================================ */

.sim-boxeo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
  border-radius: var(--sim-radius) var(--sim-radius) 0 0;
  color: #fff;
  font-size: 0.8rem;
}

.sim-boxeo-header__info {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sim-boxeo-header__model {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.sim-boxeo-header__serial {
  color: #90caf9;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.75rem;
}

.sim-boxeo-header__fw {
  color: #64b5f6;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.12);
  padding: 2px 8px;
  border-radius: 10px;
}

.sim-boxeo-header__stats {
  display: flex;
  gap: 14px;
  font-size: 0.75rem;
}

.sim-boxeo--err { color: #ef5350; }
.sim-boxeo--warn { color: #ffa726; }

.sim-boxeo-filters {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  background: #1b2a38;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-wrap: wrap;
  align-items: center;
}

.sim-boxeo-filters__group {
  display: flex;
  gap: 4px;
  margin-right: 8px;
}

.sim-boxeo-filter {
  padding: 3px 10px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  background: transparent;
  color: #90a4ae;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.sim-boxeo-filter:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sim-boxeo-filter--active {
  background: rgba(66, 165, 245, 0.2);
  color: #42a5f5;
  border-color: #42a5f5;
}

.sim-boxeo-filter--err { color: #ef5350; border-color: #ef5350; }
.sim-boxeo-filter--warn { color: #ffa726; border-color: #ffa726; }
.sim-boxeo-filter--info { color: #66bb6a; border-color: #66bb6a; }
.sim-boxeo-filter--err.sim-boxeo-filter--active { background: rgba(239,83,80,0.2); }
.sim-boxeo-filter--warn.sim-boxeo-filter--active { background: rgba(255,167,38,0.2); }
.sim-boxeo-filter--info.sim-boxeo-filter--active { background: rgba(102,187,106,0.2); }

.sim-boxeo-filter--export {
  margin-left: auto;
  color: #4fc3f7;
  border-color: #4fc3f7;
}

.sim-boxeo-filter--export:hover {
  background: rgba(79,195,247,0.15);
}

.sim-boxeo-terminal {
  background: #0d1117;
  padding: 10px 12px;
  font-family: 'Roboto Mono', 'Consolas', 'Courier New', monospace;
  font-size: 0.68rem;
  line-height: 1.5;
  max-height: 420px;
  overflow-y: auto;
  color: #8b949e;
  border-radius: 0 0 var(--sim-radius) var(--sim-radius);
}

.sim-boxeo-terminal__empty {
  color: #484f58;
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
}

.sim-boxeo-line {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  display: flex;
  gap: 6px;
  white-space: pre-wrap;
  word-break: break-all;
}

.sim-boxeo-line:hover {
  background: rgba(255,255,255,0.04);
}

.sim-boxeo-line__lvl {
  display: inline-block;
  width: 36px;
  text-align: center;
  font-weight: 700;
  font-size: 0.65rem;
  border-radius: 3px;
  padding: 0 4px;
  flex-shrink: 0;
}

.sim-boxeo-line__lvl--err {
  color: #fff;
  background: #c62828;
}

.sim-boxeo-line__lvl--warn {
  color: #000;
  background: #ff8f00;
}

.sim-boxeo-line__lvl--info {
  color: #c8e6c9;
  background: rgba(76,175,80,0.2);
}

.sim-boxeo-line__lvl--debug {
  color: #90a4ae;
  background: rgba(120,144,156,0.15);
}

.sim-boxeo-line__raw {
  color: #c9d1d9;
  flex: 1;
}

.sim-boxeo-line--err .sim-boxeo-line__raw {
  color: #f48771;
}

.sim-boxeo-line--warn .sim-boxeo-line__raw {
  color: #e5c07b;
}

/* Scrollbar styling for Boxeo terminal */
.sim-boxeo-terminal::-webkit-scrollbar {
  width: 6px;
}

.sim-boxeo-terminal::-webkit-scrollbar-track {
  background: #161b22;
}

.sim-boxeo-terminal::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 3px;
}

.sim-boxeo-terminal::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

/* ============================================================
   DDR SIMULATOR PANEL (Simulation page) — ddr-sim- prefix
   ============================================================ */
.sim-scenario-btn--critical { border-color: #e53935 !important; color: #e53935 !important; font-weight: 600; }
.sim-scenario-btn--critical:hover, .sim-scenario-btn--critical.sim-scenario-btn--active { background: #e53935 !important; color: #fff !important; }

/* Wrapper & grid */
.ddr-sim-wrap { margin: 0 16px 16px; animation: ddrPanelSlide .3s ease-out; }
.ddr-sim-grid { display: grid; grid-template-columns: 380px 1fr 320px; gap: 12px; }
.ddr-sim-panel { background: var(--sim-card); border: 1px solid var(--sim-border); border-radius: var(--sim-radius); box-shadow: var(--sim-shadow); }
.ddr-sim-panel--header { grid-column: 1 / -1; border: 2px solid #e53935; margin-bottom: 4px; }
.ddr-sim-panel__header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: linear-gradient(135deg, #e53935, #c62828); border-radius: 8px 8px 0 0; color: #fff; }
.ddr-sim-panel__header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.ddr-sim-panel__close { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; opacity: .7; }
.ddr-sim-panel__close:hover { opacity: 1; }

/* Left panel: controls */
.ddr-sim-panel--left { padding: 14px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; max-height: 600px; }
.ddr-sim-section-title { margin: 8px 0 4px; font-size: 12px; font-weight: 700; color: var(--sim-text-secondary); text-transform: uppercase; letter-spacing: .4px; display: flex; align-items: center; gap: 6px; }
.ddr-sim-section-title .mdi { font-size: 16px; }
.ddr-sim-slider { margin-bottom: 6px; }
.ddr-sim-slider label { display: block; font-size: 11px; font-weight: 600; color: #555; margin-bottom: 2px; }
.ddr-sim-slider input[type="range"] { width: 100%; height: 6px; }
.ddr-sim-slider--orange input[type="range"] { accent-color: #FF9800; }
.ddr-sim-slider--purple input[type="range"] { accent-color: #7B1FA2; }
.ddr-sim-slider--red input[type="range"] { accent-color: #e53935; }
.ddr-sim-slider__val { text-align: center; font-size: 14px; font-weight: 700; color: #1565c0; }
.ddr-sim-dc-warn { font-size: 9px; color: #e53935; background: #ffebee; padding: 3px 6px; border-radius: 4px; margin-top: 2px; line-height: 1.3; }
.ddr-sim-config-row { margin-bottom: 6px; }
.ddr-sim-config-row label { display: block; font-size: 11px; font-weight: 600; color: #555; margin-bottom: 2px; }
.ddr-sim-select { width: 100%; padding: 5px 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 12px; font-weight: 600; font-family: 'Roboto', sans-serif; background: #fff; color: #333; cursor: pointer; }
/* Scenario preset buttons 2x2 */
.ddr-sim-scenario-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 4px; }
.ddr-sim-scenario-btn { padding: 5px 8px; border: 1px solid #ccc; border-radius: 8px; background: #fff; font-size: 10px; font-weight: 600; cursor: pointer; transition: all .2s; font-family: 'Roboto', sans-serif; text-align: center; }
.ddr-sim-scenario-btn:hover { background: #e3f2fd; border-color: #1565c0; }
.ddr-sim-scenario-btn--danger { border-color: #e53935; color: #e53935; }
.ddr-sim-scenario-btn--danger:hover { background: #ffebee; }
.ddr-sim-scenario-btn--ok { border-color: #4CAF50; color: #2E7D32; }
.ddr-sim-scenario-btn--ok:hover { background: #E8F5E9; }
.ddr-sim-reset-btn { margin-top: 8px; padding: 8px; border: 1px solid #1565c0; border-radius: 8px; background: #e3f2fd; color: #1565c0; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s; font-family: 'Roboto', sans-serif; }
.ddr-sim-reset-btn:hover { background: #1565c0; color: #fff; }

/* Center panel: SVG */
.ddr-sim-panel--center { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ddr-sim-svg { width: 100%; height: auto; border: 1px solid #e0e0e0; border-radius: 8px; background: #fafafa; }
.ddr-sim-svg-info { font-size: 11px; color: #555; line-height: 1.4; font-family: 'Roboto', sans-serif; padding: 4px 6px; background: rgba(255,255,255,.9); border-radius: 4px; }
.ddr-sim-cards { display: flex; gap: 6px; }
.ddr-sim-card { flex: 1; padding: 8px 6px; border-radius: 8px; text-align: center; font-size: 10px; font-weight: 700; opacity: .35; transition: all .3s; border: 2px solid transparent; }
.ddr-sim-card--ok { background: #E8F5E9; color: #2E7D32; border-color: #A5D6A7; }
.ddr-sim-card--trip { background: #FFF3E0; color: #E65100; border-color: #FFCC80; }
.ddr-sim-card--blind { background: #FFEBEE; color: #C62828; border-color: #EF9A9A; }
.ddr-sim-card--active { opacity: 1; transform: scale(1.03); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.ddr-sim-card__icon { font-size: 14px; margin-right: 4px; }

/* Right panel: metrics */
.ddr-sim-panel--right { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ddr-sim-status-box { color: #fff; border-radius: 10px; padding: 12px; text-align: center; transition: background .3s; }
.ddr-sim-status-box--ok { background: #4CAF50; }
.ddr-sim-status-box--warn { background: #FF9800; }
.ddr-sim-status-box--danger { background: #FF5722; animation: ddrPulse 1.2s ease-in-out infinite; }
.ddr-sim-status-box--tripped { background: #b71c1c; }
.ddr-sim-status-box__icon { font-size: 28px; font-weight: 700; line-height: 1; }
.ddr-sim-status-box__text { font-size: 13px; font-weight: 700; margin-top: 4px; letter-spacing: .5px; }
.ddr-sim-status-box__sub { font-size: 11px; opacity: .85; margin-top: 2px; }

.ddr-sim-metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ddr-sim-metric { padding: 8px; background: rgba(0,0,0,.03); border-radius: 8px; border-left: 3px solid #4CAF50; }
.ddr-sim-metric__label { display: block; font-size: 9px; font-weight: 700; text-transform: uppercase; color: #666; letter-spacing: .3px; }
.ddr-sim-metric__val { display: block; font-size: 15px; font-weight: 700; color: #333; font-family: 'Roboto Mono', monospace; margin-top: 2px; }

.ddr-sim-sens-bar__label { font-size: 10px; font-weight: 600; text-transform: uppercase; color: #666; margin-bottom: 4px; }
.ddr-sim-sens-bar__track { height: 14px; background: #e0e0e0; border-radius: 7px; overflow: hidden; }
.ddr-sim-sens-bar__fill { height: 100%; border-radius: 7px; background: #4CAF50; transition: width .3s, background .3s; width: 100%; }
.ddr-sim-sens-bar__ends { display: flex; justify-content: space-between; font-size: 9px; color: #888; margin-top: 2px; }

.ddr-sim-type-table__title { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #666; margin-bottom: 4px; }
.ddr-sim-type-table table { width: 100%; border-collapse: collapse; font-size: 11px; }
.ddr-sim-type-table th { padding: 4px 6px; background: #f5f5f5; font-weight: 700; text-align: left; border-bottom: 2px solid #ddd; }
.ddr-sim-type-table td { padding: 3px 6px; border-bottom: 1px solid #eee; }
.ddr-sim-type-table__active { background: #E3F2FD !important; font-weight: 700; }
.ddr-sim-type-table__active td { border-left: 3px solid #1565c0; }

.ddr-sim-warning-box { display: none; align-items: center; gap: 8px; padding: 10px 12px; background: #FFEBEE; border: 2px solid #e53935; border-radius: 8px; color: #C62828; font-size: 11px; font-weight: 600; animation: ddrPulse 1.2s ease-in-out infinite; }
.ddr-sim-warning-box .mdi { font-size: 22px; color: #e53935; }

.ddr-sim-verdict { margin-top: auto; }
.ddr-sim-verdict--danger { padding: 8px; background: #FFEBEE; border-radius: 8px; color: #C62828; font-size: 11px; font-weight: 600; }
.ddr-sim-verdict--ok { padding: 8px; background: #E8F5E9; border-radius: 8px; color: #2E7D32; font-size: 11px; font-weight: 600; }
.ddr-sim-verdict--warning { padding: 8px; background: #FFF3E0; border-radius: 8px; color: #E65100; font-size: 11px; font-weight: 600; }

@keyframes ddrPanelSlide { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ddrPulse { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }

/* Responsive: stack on narrow screens */
@media (max-width: 1100px) {
  .ddr-sim-grid { grid-template-columns: 1fr; }
}

/* Dark mode */
[data-theme="dark"] .ddr-sim-wrap .ddr-sim-panel { background: #1e1e2e; border-color: #444; }
[data-theme="dark"] .ddr-sim-panel--header { background: #1e1e2e; border-color: #c62828; }
[data-theme="dark"] .ddr-sim-slider label,
[data-theme="dark"] .ddr-sim-config-row label { color: #ccc; }
[data-theme="dark"] .ddr-sim-select { background: #1a1a2e; border-color: #444; color: #e0e0e0; }
[data-theme="dark"] .ddr-sim-scenario-btn { background: #1a1a2e; border-color: #444; color: #e0e0e0; }
[data-theme="dark"] .ddr-sim-reset-btn { background: #1a1a2e; border-color: #1565c0; }
[data-theme="dark"] .ddr-sim-svg { background: #1a1a2e; border-color: #444; }
[data-theme="dark"] .ddr-sim-svg-info { background: rgba(30,30,46,.9); color: #ccc; }
[data-theme="dark"] .ddr-sim-card--ok { background: #1b3a1b; color: #66BB6A; border-color: #2E7D32; }
[data-theme="dark"] .ddr-sim-card--trip { background: #3e2a10; color: #FFB74D; border-color: #E65100; }
[data-theme="dark"] .ddr-sim-card--blind { background: #3e1a1a; color: #EF9A9A; border-color: #C62828; }
[data-theme="dark"] .ddr-sim-metric { background: rgba(255,255,255,.06); }
[data-theme="dark"] .ddr-sim-metric__label { color: #aaa; }
[data-theme="dark"] .ddr-sim-metric__val { color: #e0e0e0; }
[data-theme="dark"] .ddr-sim-sens-bar__track { background: #333; }
[data-theme="dark"] .ddr-sim-sens-bar__label,
[data-theme="dark"] .ddr-sim-type-table__title { color: #aaa; }
[data-theme="dark"] .ddr-sim-sens-bar__ends { color: #777; }
[data-theme="dark"] .ddr-sim-type-table th { background: #2a2a3e; border-color: #444; }
[data-theme="dark"] .ddr-sim-type-table td { border-color: #333; color: #ccc; }
[data-theme="dark"] .ddr-sim-type-table__active { background: #1a2a4e !important; }
[data-theme="dark"] .ddr-sim-warning-box { background: #3e1a1a; border-color: #c62828; }
[data-theme="dark"] .ddr-sim-dc-warn { background: #3e1a1a; color: #ef9a9a; }
[data-theme="dark"] .ddr-sim-section-title { color: #aaa; }

/* -------------------------------------------------------
   CHART MODE TOGGLE (Oscillo / Bargraph)
   ------------------------------------------------------- */
.sim-chart-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.sim-chart-header .sim-chart-title {
  margin-bottom: 0;
}
.sim-chart-mode-toggle {
  display: flex; gap: 2px; background: #e5e7eb; border-radius: 6px; padding: 2px;
  flex-shrink: 0;
}
.sim-chart-mode {
  padding: 3px 10px; border: none; border-radius: 4px; cursor: pointer;
  font-size: 11px; font-weight: 600; background: transparent; color: #666;
  transition: all .2s; line-height: 1.2;
}
.sim-chart-mode.active {
  background: #1565c0; color: white;
}
.sim-chart-mode:hover:not(.active) { background: rgba(0,0,0,.08); }

/* Dark mode */
[data-theme="dark"] .sim-chart-mode-toggle { background: #2a2a4a; }
[data-theme="dark"] .sim-chart-mode { color: #aaa; }
[data-theme="dark"] .sim-chart-mode.active { background: #1565c0; color: white; }
[data-theme="dark"] .sim-chart-mode:hover:not(.active) { background: rgba(255,255,255,.1); }
