:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-hover: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --accent: #38bdf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #64748b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

header .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}
.badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}
.badge-info {
  background: rgba(100, 116, 139, 0.2);
  color: var(--muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
  animation: pulse 2s infinite;
}

.live-dot.paused {
  background: var(--muted);
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

main {
  padding: 1.25rem;
  max-width: 1600px;
  margin: 0 auto;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.control input,
.control select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.65rem;
  font: inherit;
  outline: none;
}

.control input:focus,
.control select:focus {
  border-color: var(--accent);
}

.actions {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 0.5rem;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: opacity 0.15s, transform 0.05s;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  color: #0f172a;
}

button.secondary {
  background: var(--panel-hover);
  color: var(--text);
}

button.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

thead th {
  position: sticky;
  top: 0;
  background: #162032;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr.new {
  animation: highlight 1.2s ease-out;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

td {
  padding: 0.65rem 0.75rem;
  vertical-align: top;
}

td.time {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.8rem;
}

td.msg {
  max-width: 400px;
  word-break: break-word;
}

td .mono {
  font-size: 0.8rem;
  color: var(--muted);
}

.expand {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  user-select: none;
}

.details {
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px dashed var(--border);
}

.details pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  color: #cbd5e1;
}

.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes highlight {
  0% {
    background: rgba(56, 189, 248, 0.25);
  }
  100% {
    background: transparent;
  }
}

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 50;
  max-width: 320px;
  font-size: 0.85rem;
}

.toast.error {
  border-color: var(--error);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 60;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  width: min(90vw, 400px);
}

.modal h3 {
  margin: 0 0 0.5rem;
}

.modal input {
  width: 100%;
}

.tabs {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.25rem;
}

.tabs button {
  background: transparent;
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  border-radius: 0.35rem;
}

.tabs button.active {
  background: var(--panel-hover);
  color: var(--text);
}

.recap-status {
  color: var(--muted);
  font-size: 0.8rem;
}

.recap-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.summary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.summary-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
}

.chart-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}
