/* ── Reset & Base ───────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #050505;
  --surface: #0a0a0a;
  --surface-2: #111111;
  --border: #1e1e1e;
  --border-hover: #2e2e2e;
  --text: #ededed;
  --text-muted: #888888;
  --accent: #3ecf8e;
  --accent-hover: #2bb573;
  --danger: #f43f5e;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────── */
header {
  text-align: center;
  padding: 48px 24px 32px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 6px;
}

/* ── Main Layout ───────────────────────────────────── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 820px) {
  main {
    grid-template-columns: 1fr;
  }
}

/* ── Panels ────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  flex-direction: column;
}

.panel h2 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.live-indicator {
  color: var(--border-hover);
  font-size: 10px;
  transition: color 0.3s ease;
}

.live-indicator.connected {
  color: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

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

.panel-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
  line-height: 1.6;
}

/* ── Generate Button ───────────────────────────────── */
.generate-panel {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.btn-row {
  display: flex;
  gap: 12px;
}

.btn-row button {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 32px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  min-width: 150px;
}

.btn-row button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-row button:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-row button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-msg {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 20px;
}

.status-msg.error {
  color: var(--danger);
}

.status-msg.success {
  color: var(--accent);
}

/* ── Runs Panel ────────────────────────────────────── */
.teams {
  display: flex;
  gap: 16px;
}

.team-card {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.15s ease;
}

.team-card:hover {
  border-color: var(--border-hover);
}

.team-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.team-count {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-width: 32px;
  padding: 2px 10px;
  text-align: center;
}

.add-run {
  display: flex;
  gap: 6px;
}

.add-run input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

.add-run input:focus {
  border-color: var(--accent);
}

.add-run input::placeholder {
  color: var(--text-muted);
}

.add-run button {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.add-run button:hover {
  background: var(--accent-hover);
}

.run-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 340px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.run-list::-webkit-scrollbar {
  width: 6px;
}
.run-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.run-list::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

.run-list .empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 16px 0;
  font-style: italic;
}

.run-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.15s ease;
}

.run-item:hover {
  border-color: var(--border-hover);
}

.run-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.run-reason {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
}

.run-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.run-edit,
.run-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.run-edit:hover {
  color: var(--accent);
  background: rgba(62, 207, 142, 0.1);
}

.run-del {
  font-size: 18px;
}

.run-del:hover {
  color: var(--danger);
  background: rgba(244, 63, 94, 0.1);
}

/* ── Edit mode ─────────────────────────────────────── */
.run-item.editing {
  padding: 6px 8px;
}

.edit-form {
  display: flex;
  flex: 1;
  gap: 4px;
  align-items: center;
}

.edit-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.edit-save,
.edit-cancel {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.edit-save {
  color: var(--accent);
}

.edit-save:hover {
  background: rgba(62, 207, 142, 0.15);
}

.edit-cancel {
  color: var(--text-muted);
  font-size: 18px;
}

.edit-cancel:hover {
  color: var(--danger);
  background: rgba(244, 63, 94, 0.1);
}

/* ── Import / Export Actions ───────────────────────── */
.io-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.io-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  font-family: inherit;
}

.io-btn:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--surface);
}

/* ── Footer ────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}
