* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  font-size: 15px;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: #1a1d27;
  border-bottom: 1px solid #2d3348;
  flex-shrink: 0;
}

header h1 { font-size: 18px; font-weight: 600; color: #94a3b8; }

.toolbar {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}

.toolbar button, .controls button {
  padding: 8px 16px;
  font-size: 15px;
  border: 1px solid #3d4560;
  background: #232738;
  color: #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
}
.toolbar button:hover, .controls button:hover { background: #2d3348; }
.toolbar button.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }

.controls {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}

.controls .sim-status {
  font-size: 15px;
  padding: 6px 12px;
  border-radius: 4px;
  background: #1e293b;
}
.controls .sim-status.running { color: #4ade80; }
.controls .sim-status.stopped { color: #f87171; }

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Sidebars */
.sidebar {
  width: 320px;
  background: #1a1d27;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-left { border-right: 1px solid #2d3348; overflow-y: auto; }
.sidebar-right { border-left: 1px solid #2d3348; overflow-y: auto; }

.sidebar .section {
  padding: 10px 14px;
  border-bottom: 1px solid #1e2132;
  flex-shrink: 0;
}

/* Collapsible section */
.collapsible { cursor: pointer; user-select: none; }
.collapsible:hover { color: #93c5fd; }
.collapse-icon { font-size: 10px; margin-left: 4px; transition: transform 0.15s; display: inline-block; }
.section.collapsed .collapse-icon { transform: rotate(-90deg); }
.section.collapsed .epc-list-scroll { display: none; }

/* EPC list scrollable container */
.epc-list-scroll { max-height: 280px; overflow-y: auto; }

.sidebar .log-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-bottom: none;
}

.sidebar h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 6px;
}

.sidebar .item {
  font-size: 15px;
  padding: 5px 6px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.sidebar .item:hover { background: #232738; }

.sidebar .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Parameters — slider + text input combo */
.param-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
}
.param-row label { font-size: 14px; color: #94a3b8; }
.param-row label span { color: #e2e8f0; font-weight: 600; }
.param-combo {
  display: flex;
  align-items: center;
  gap: 6px;
}
.param-combo input[type="range"] { flex: 1; accent-color: #3b82f6; }
.param-combo input[type="text"] {
  width: 64px;
  padding: 5px 6px;
  font-size: 14px;
  background: #232738;
  border: 1px solid #3d4560;
  color: #e2e8f0;
  border-radius: 3px;
  text-align: right;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.param-combo input[type="text"]:focus {
  outline: none;
  border-color: #3b82f6;
}

/* Selection */
.selection-info { font-size: 14px; color: #64748b; margin-bottom: 6px; }

.action-btn {
  width: 100%;
  padding: 8px 14px;
  font-size: 14px;
  border: 1px solid #3d4560;
  background: #232738;
  color: #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
}
.action-btn:hover:not(:disabled) { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.action-btn:disabled { opacity: 0.4; cursor: default; }

/* EPC controls */
.epc-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}
.epc-controls input[type="number"] {
  width: 56px;
  padding: 6px 6px;
  font-size: 14px;
  background: #232738;
  border: 1px solid #3d4560;
  color: #e2e8f0;
  border-radius: 3px;
}
.epc-controls button {
  padding: 6px 14px;
  font-size: 14px;
  border: 1px solid #3d4560;
  background: #232738;
  color: #cbd5e1;
  border-radius: 3px;
  cursor: pointer;
}
.epc-controls button:hover { background: #2d3348; }

/* Counters */
.counters {
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.counter-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  color: #94a3b8;
}
.counter-row .val { color: #e2e8f0; font-weight: 600; }
.counter-row.detected .val { color: #60a5fa; }
.counter-row.zone-entered .val { color: #4ade80; }
.counter-row.zone-exited .val { color: #f87171; }

/* NATS streams canvas */
#streams-canvas {
  width: 100%;
  height: 140px;
  border-radius: 4px;
  background: #0c0e14;
}

/* EPC list */
.epc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
}
.epc-item .epc-hex {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #93c5fd;
}
.epc-item .epc-zone {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 3px;
}

/* Zone antenna items */
.zone-antenna-item {
  font-size: 13px;
  color: #64748b;
  padding-left: 16px;
  padding-top: 1px;
}

/* Event log (in sidebar) */
.event-log {
  flex: 1;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.7;
}
.event-log .entry { padding: 1px 0; }
.event-log .ts { color: #475569; margin-right: 6px; }
.event-log .detected { color: #60a5fa; }
.event-log .zone-entered { color: #4ade80; }
.event-log .zone-exited { color: #f87171; }
.event-log .read { color: #334155; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: #1a1d27;
  border: 1px solid #3d4560;
  border-radius: 8px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #2d3348;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #e2e8f0;
  text-transform: none;
  letter-spacing: normal;
}
.modal-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: #e2e8f0; }
.modal-body { padding: 18px; }
.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid #2d3348;
}
.modal-footer .action-btn { margin: 0; }
