/* ============================================================
   SERVO-U Simulator — Theme based on Getinge Servo-U reference
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-body:       #2c2c34;
  --bg-panel:      #363640;
  --bg-waveform:   #1a1a24;
  --bg-menu:       #2a2a32;
  --bg-cell:       #303038;
  --bg-cell-hover: #3a3a44;
  --bg-modal:      #2e2e38;
  --border:        #48485a;
  --border-light:  #55556a;

  --text:          #b0b0b8;
  --text-bright:   #e8e8f0;
  --text-dim:      #7a7a88;
  --text-header:   #9898a8;

  --color-pressure: #d4a030;
  --color-flow:     #40c870;
  --color-volume:   #40b8c8;

  --alarm-red:    #e83030;
  --alarm-yellow: #d8a020;
  --alarm-blue:   #4080d0;

  --accent:       #4080d0;
  --accent-hover: #5090e0;

  --font-mono:  'Consolas', 'Monaco', 'Courier New', monospace;
  --font-sans:  'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg-body);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  overflow: hidden;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== Top status bar ===== */
#status-bar {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  height: 32px;
  gap: 16px;
}

#mode-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 1px;
}

#alarm-banner {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
}

#btn-silence-alarm {
  background: transparent;
  border: 1px solid var(--alarm-yellow);
  color: var(--alarm-yellow);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
#btn-silence-alarm:hover {
  background: var(--alarm-yellow);
  color: var(--bg-dark);
}
#btn-silence-alarm.silenced {
  border-color: var(--text-dim);
  color: var(--text-dim);
}

#btn-sound-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 14px;
  padding: 1px 6px;
  border-radius: 3px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
#btn-sound-toggle:hover { color: var(--text-bright); }
#btn-sound-toggle.sound-off {
  color: var(--alarm-red);
  border-color: var(--alarm-red);
  opacity: 0.7;
}

#clock {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== Main area ===== */
#main-area {
  flex: 1;
  display: grid;
  grid-template-columns: 64px 1fr 340px;
  overflow: hidden;
  min-height: 0;
}

/* ===== Left icon menu ===== */
#left-menu {
  background: var(--bg-menu);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  gap: 2px;
  overflow-y: auto;
}

.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 2px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 54px;
}

.menu-btn:hover { background: var(--bg-cell-hover); }

.menu-icon { font-size: 18px; margin-bottom: 2px; }

.menu-text {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  line-height: 1.2;
  color: var(--text-dim);
}

.menu-spacer { flex: 1; }

/* ===== Waveform panel ===== */
#waveform-panel {
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  min-height: 0;
  background: var(--bg-waveform);
  position: relative;
}

.waveform-container {
  flex: 1;
  position: relative;
  min-height: 0;
  border-bottom: 1px solid #333340;
}

.waveform-container:last-child { border-bottom: none; }

.waveform-title {
  position: absolute;
  top: 4px;
  left: 32px;
  font-size: 11px;
  color: var(--text-dim);
  z-index: 1;
  pointer-events: none;
  letter-spacing: 0.5px;
}

.waveform-scale-label {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  z-index: 1;
  pointer-events: none;
}

.waveform-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Numeric panel (two columns) ===== */
#numeric-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.num-col { display: flex; flex-direction: column; }
.num-col-primary { border-right: 1px solid var(--border); }

.num-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  min-height: 0;
}

.num-cell:last-child { border-bottom: none; }

.num-header {
  font-size: 12px;
  color: var(--text-header);
  align-self: flex-start;
}

.num-big {
  font-family: var(--font-mono);
  font-size: 42px;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.1;
}

.num-highlight { color: var(--color-flow); }
.num-unit { font-size: 11px; color: var(--text-dim); }

.num-col-secondary { display: flex; flex-direction: column; }

.num-cell-sm {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  padding: 2px 6px;
  min-height: 0;
}

.num-cell-sm:last-child { border-bottom: none; }

.num-header-sm {
  font-size: 10px;
  color: var(--text-header);
  align-self: flex-start;
}

.num-med {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.1;
}

.num-unit-sm { font-size: 10px; color: var(--text-dim); }

/* ===== Event bar ===== */
#event-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--bg-menu);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  min-height: 34px;
}

.event-bar-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

.event-btn {
  background: var(--bg-cell);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.event-btn:hover {
  background: var(--accent);
  color: var(--text-bright);
  border-color: var(--accent);
}

.event-btn.event-active {
  background: var(--alarm-yellow);
  color: #000;
  border-color: var(--alarm-yellow);
}

.event-btn.event-reset {
  background: transparent;
  border-color: var(--color-flow);
  color: var(--color-flow);
}

.event-btn.event-reset:hover {
  background: var(--color-flow);
  color: #000;
}

#event-active-label {
  font-size: 11px;
  color: var(--alarm-yellow);
  font-weight: 600;
  margin-left: 8px;
}

/* ===== Event info panel (floating) ===== */
#event-info-panel {
  position: fixed;
  bottom: 90px;
  left: 80px;
  width: 400px;
  max-height: 320px;
  background: #1a1a24;
  border: 1px solid var(--alarm-yellow);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  z-index: 55;
  overflow: hidden;
  animation: eventInfoIn 0.25s ease-out;
}
#event-info-panel.hidden { display: none !important; }

@keyframes eventInfoIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.event-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(216, 160, 32, 0.12);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--alarm-yellow);
}

#event-info-text {
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
}

/* ===== Direct access bar (bottom) ===== */
#direct-access-bar {
  display: flex;
  align-items: center;
  background: var(--bg-panel);
  border-top: 2px solid var(--border);
  height: 52px;
  padding: 0 4px;
  gap: 0;
  overflow: visible;
}

.da-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-right: 1px solid var(--border);
  height: 100%;
  min-width: 54px;
}

.da-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: capitalize;
}

.da-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
}

.da-unit {
  font-size: 9px;
  color: var(--text-dim);
}

.da-spacer { flex: 1; }

.da-start {
  padding: 8px 24px;
  font-size: 14px;
  font-weight: 700;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
}

.da-start:hover {
  background: var(--accent);
  color: var(--text-bright);
}

.da-start.running {
  border-color: var(--alarm-red);
  color: var(--alarm-red);
}

.da-start.running:hover {
  background: var(--alarm-red);
  color: var(--text-bright);
}

/* --- Editable cells with popup slider --- */
.da-editable {
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.da-editable:hover {
  background: var(--bg-cell-hover);
}

.da-editable.da-editing {
  background: var(--bg-cell-hover);
}

.da-slider {
  position: absolute;
  bottom: 100%;
  left: 4px;
  right: 4px;
  width: auto;
  margin: 0;
  padding: 8px 4px;
  background: var(--bg-modal);
  border: 1px solid var(--border-light);
  border-radius: 4px 4px 0 0;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.4);
  z-index: 50;
  accent-color: var(--accent);
}

.da-slider.hidden {
  display: none;
}

/* ===== Modal (settings / scenario) ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-modal);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 15px;
  color: var(--text-bright);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover { color: var(--text-bright); }
.modal-body { padding: 16px; }

.setting-row {
  display: grid;
  grid-template-columns: 150px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.setting-row label { font-size: 13px; color: var(--text); }
.setting-row .s-unit { color: var(--text-dim); font-size: 11px; }
.setting-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.setting-row select {
  grid-column: 2 / 4;
  background: var(--bg-body);
  color: var(--text-bright);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 13px;
}

.s-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-bright);
  text-align: right;
}

.btn-accept {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--accent);
  color: var(--text-bright);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-accept:hover { background: var(--accent-hover); }

#scenario-select {
  width: 100%;
  background: var(--bg-body);
  color: var(--text-bright);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
  font-size: 13px;
  margin-bottom: 12px;
}

#scenario-select option { padding: 6px 8px; }

#scenario-description {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

#scenario-hint {
  font-size: 12px;
  color: var(--color-flow);
  padding: 8px;
  background: rgba(64, 200, 112, 0.08);
  border-radius: 4px;
  border-left: 3px solid var(--color-flow);
  line-height: 1.4;
}

/* ===== Alarm limits modal ===== */
.alarm-modal-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.alarm-modal-buttons .btn-accept {
  flex: 1;
}

/* ===== Maneuver modal ===== */
.maneuver-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.maneuver-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-cell);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.maneuver-btn:hover {
  background: var(--accent);
  color: var(--text-bright);
  border-color: var(--accent);
}
.maneuver-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.maneuver-icon { font-size: 20px; flex-shrink: 0; }
.maneuver-label { font-weight: 600; font-size: 13px; }
.maneuver-desc { font-size: 11px; color: var(--text-dim); margin-left: auto; }

.maneuver-status {
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(64, 128, 208, 0.12);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.maneuver-result {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(64, 200, 112, 0.1);
  border-left: 3px solid var(--color-flow);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-bright);
  line-height: 1.6;
}

.maneuver-result .result-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-flow);
}

/* ===== Select within settings ===== */
.s-select {
  background: var(--bg-cell);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 12px;
  flex: 1;
}

/* ===== Custom scenario editor ===== */
#custom-scenario-editor {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

#custom-scenario-editor summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  padding: 4px 0;
}

.custom-editor-grid {
  margin-top: 8px;
}

.custom-editor-grid .setting-row {
  margin-bottom: 6px;
}

.custom-editor-grid .btn-accept {
  margin-top: 8px;
}

/* ===== SpO₂ color states ===== */
#mon-spo2 {
  color: #2dd4bf;  /* teal — normal */
  transition: color 0.3s;
}
#mon-spo2.spo2-warning {
  color: #f59e0b;  /* amber — <94% */
}
#mon-spo2.spo2-low {
  color: #ef4444;  /* red — <90% */
}
#mon-spo2.spo2-critical {
  color: #ef4444;
  animation: spo2Blink 0.6s ease-in-out infinite;
}
#mon-spo2.spo2-danger {
  color: #dc2626;
  animation: spo2Blink 0.35s ease-in-out infinite;
}
@keyframes spo2Blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.2; }
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Alarm styling ===== */
.alarm-high {
  color: var(--alarm-red) !important;
  animation: blink 0.5s infinite;
}

.alarm-medium { color: var(--alarm-yellow) !important; }
.alarm-low { color: var(--alarm-blue) !important; }

@keyframes blink { 50% { opacity: 0.3; } }

/* ===== Trend panel (floating window) ===== */
#trend-panel {
  position: fixed;
  top: 60px;
  right: 80px;
  width: 560px;
  height: 320px;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  min-width: 360px;
  min-height: 200px;
}
#trend-panel.hidden { display: none !important; }

.trend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.trend-header:active { cursor: grabbing; }

.trend-canvases {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
  overflow: hidden;
}

.trend-row {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-height: 0;
}

.trend-label {
  width: 80px;
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.trend-canvas-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
}

.trend-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Loop panel (floating window) ===== */
#loop-panel {
  position: fixed;
  top: 60px;
  left: 80px;
  width: 520px;
  height: 280px;
  background: var(--bg-body);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  min-width: 340px;
  min-height: 200px;
}
#loop-panel.hidden { display: none !important; }

.loop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.loop-header:active { cursor: grabbing; }

.loop-canvases {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  min-height: 0;
}

.loop-container {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background: var(--bg-waveform);
}

.loop-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.loop-title {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  pointer-events: none;
  z-index: 1;
  letter-spacing: 0.5px;
}

/* ===== Info tooltips ===== */
.info-icon {
  display: inline-block;
  font-style: normal;
  font-size: 9px;
  width: 13px;
  height: 13px;
  line-height: 13px;
  text-align: center;
  border-radius: 50%;
  background: rgba(100, 160, 220, 0.2);
  color: var(--alarm-blue);
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  transition: background 0.15s;
  user-select: none;
}
.info-icon:hover {
  background: rgba(100, 160, 220, 0.5);
  color: #fff;
}

#tooltip-overlay {
  position: fixed;
  z-index: 1000;
  width: 280px;
  max-width: calc(100vw - 20px);
  background: #1a1a22;
  border: 1px solid var(--alarm-blue);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  pointer-events: auto;
}
#tooltip-overlay .tooltip-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--alarm-blue);
  margin-bottom: 6px;
}
#tooltip-overlay .tooltip-text {
  font-size: 11px;
  color: var(--text-main);
  line-height: 1.5;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== Responsive: Tablet (≤1100px) ===== */
@media (max-width: 1100px) {
  #main-area {
    grid-template-columns: 48px 1fr 240px;
  }

  .menu-btn { min-height: 44px; padding: 6px 2px; }
  .menu-icon { font-size: 16px; }
  .menu-text { font-size: 7px; }

  #numeric-panel { grid-template-columns: 1fr 1fr; }
  .num-big { font-size: 30px; }
  .num-med { font-size: 20px; }
  .num-header { font-size: 10px; }
  .num-cell { padding: 4px 4px; }

  .da-cell { padding: 4px 10px; min-width: 72px; }
  .da-value { font-size: 18px; }
  .da-label { font-size: 9px; }

  .event-btn { padding: 2px 6px; font-size: 10px; }

  /* Floating panels: a bit smaller on tablet */
  #trend-panel { width: 460px; height: 280px; }
  #loop-panel { width: 420px; height: 240px; }
}

/* ===== Responsive: Narrow tablet / large phone (≤800px) ===== */
@media (max-width: 800px) {
  #main-area {
    grid-template-columns: 42px 1fr;
    grid-template-rows: 1fr auto;
  }

  /* Numeric panel moves below waveforms */
  #numeric-panel {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(4, 1fr);
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 120px;
    overflow-y: auto;
  }

  .num-col-primary { border-right: 1px solid var(--border); }
  .num-col-secondary {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .num-cell-sm {
    flex: 0 0 50%;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
  }

  .num-big { font-size: 24px; }
  .num-med { font-size: 16px; }

  #waveform-panel { grid-column: 2; }

  .menu-text { display: none; }
  .menu-btn { min-height: 38px; }

  #direct-access-bar { height: 44px; }
  .da-cell { min-width: 60px; padding: 2px 6px; }
  .da-value { font-size: 16px; }

  #event-bar { padding: 3px 8px; }
  .event-bar-label { display: none; }
  .event-btn { font-size: 9px; padding: 2px 5px; }

  /* Floating panels: compact on narrow screens */
  #trend-panel { width: 340px; height: 220px; min-width: 300px; }
  #loop-panel { width: 320px; height: 200px; min-width: 280px; }

  .trend-label { width: 60px; font-size: 8px; }
}

/* ===== Progressive event severity states ===== */
.event-btn.event-severity-initial {
  background: #8b8000;
  color: #fff;
  border-color: #8b8000;
}

.event-btn.event-severity-progressing {
  background: #cc6600;
  color: #fff;
  border-color: #cc6600;
  animation: eventPulse 1.5s ease-in-out infinite;
}

.event-btn.event-severity-severe {
  background: var(--alarm-red, #ff3333);
  color: #fff;
  border-color: var(--alarm-red, #ff3333);
  animation: eventPulse 0.8s ease-in-out infinite;
}

.event-btn.event-severity-recovering {
  background: #2a7a4a;
  color: #fff;
  border-color: #2a7a4a;
}

@keyframes eventPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ===== Intervention buttons in info panel ===== */
.event-interventions {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border, #444);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 20px;
}

.event-interventions:empty {
  display: none;
}

.intervention-btn {
  background: #1a3a2a;
  color: #4ade80;
  border: 1px solid #4ade80;
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.intervention-btn:hover {
  background: #4ade80;
  color: #000;
}

.intervention-status {
  font-size: 11px;
  color: #4ade80;
  font-style: italic;
}

.async-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid #f59e0b;
  color: #f59e0b;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 3;
  pointer-events: none;
  animation: async-pulse 1.5s ease-in-out infinite;
}

.async-badge.hidden { display: none; }

@keyframes async-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.intervention-recovery {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.recovery-bar {
  height: 6px;
  background: #2a2a38;
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}

.recovery-bar-fill {
  height: 100%;
  background: #2dd4bf;
  border-radius: 3px;
  transition: width 0.3s ease;
}
CSSEOF 2>&1
