/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252833;
  --border: #2d3142;
  --text: #e4e6ed;
  --text-dim: #8b8fa3;
  --accent: #6c5ce7;
  --accent-hover: #7f70f0;
  --success: #00b894;
  --danger: #e17055;
  --warning: #fdcb6e;
  --radius: 10px;
  --sidebar-w: 240px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ─── Layout ──────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  max-width: 1200px;
}

/* ─── Logo ────────────────────────────────────────────── */
.logo { padding: 0 20px 24px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.logo-icon { font-size: 24px; color: var(--accent); margin-right: 8px; }
.logo-text { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.logo-sub { display: block; font-size: 11px; color: var(--text-dim); margin-top: 2px; padding-left: 34px; }

/* ─── Nav ─────────────────────────────────────────────── */
nav { flex: 1; padding: 8px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-input); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); transition: background 0.3s;
}
.status-dot.connected { background: var(--success); }

/* ─── Pages ───────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }
h1 { font-size: 24px; font-weight: 700; margin-bottom: 24px; }
h2 { font-size: 18px; font-weight: 600; margin: 32px 0 16px; }
h3 { font-size: 14px; font-weight: 600; color: var(--text-dim); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── Stats grid ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
}
.stat-card.success::before { background: var(--success); }
.stat-card.danger::before { background: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.progress-bar { height: 6px; background: var(--bg-input); border-radius: 3px; margin-top: 12px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.5s ease; width: 0%; }

/* ─── Report grid ─────────────────────────────────────── */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.report-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
}
.report-card h3 { margin-bottom: 12px; }
.report-item { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.report-item:last-child { border-bottom: none; }
.report-item .label { color: var(--text-dim); }
.report-item .value { font-weight: 600; }
.report-bar {
  height: 20px; background: var(--bg-input); border-radius: 4px; margin: 4px 0; overflow: hidden; position: relative;
}
.report-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.report-bar-label {
  position: absolute; top: 50%; left: 8px; transform: translateY(-50%);
  font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ─── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--bg-input); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
}
.badge-success { background: rgba(0,184,148,0.15); color: var(--success); }
.badge-danger { background: rgba(225,112,85,0.15); color: var(--danger); }
.badge-running { background: rgba(108,92,231,0.15); color: var(--accent); }

/* ─── Form ────────────────────────────────────────────── */
.form-grid { max-width: 800px; }
.form-section {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%; padding: 10px 12px; font-size: 14px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); outline: none; transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
small { display: block; margin-top: 4px; font-size: 12px; color: var(--text-dim); }
.form-actions { margin-top: 8px; display: flex; gap: 12px; }

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
  padding: 12px 28px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }

/* ─── Empty state ─────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-icon { font-size: 48px; color: var(--border); margin-bottom: 16px; }

/* ─── History ─────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: border-color 0.15s;
}
.history-card:hover { border-color: var(--accent); }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history-date { font-size: 13px; color: var(--text-dim); }
.history-stats { display: flex; gap: 20px; font-size: 13px; }
.history-stat { display: flex; align-items: center; gap: 4px; }

/* ─── Log panel ───────────────────────────────────────── */
.log-panel {
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-height: 350px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.7;
}
.log-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-ts { color: #555; margin-right: 8px; }
.log-level-info { color: var(--accent); }
.log-level-warn { color: var(--warning); }
.log-level-error { color: var(--danger); }
.log-level-debug { color: #555; }
.log-msg { color: var(--text); }
.log-meta { color: var(--text-dim); margin-left: 6px; }

/* ─── Utility ─────────────────────────────────────────── */
.hidden { display: none !important; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-dim { color: var(--text-dim); }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; padding: 16px 0; }
  .logo-text, .logo-sub, .nav-item span:not(.nav-icon), .sidebar-footer span { display: none; }
  .content { margin-left: 60px; padding: 20px; }
  .nav-item { justify-content: center; padding: 12px; }
  .logo { padding: 0 0 16px; text-align: center; }
  .sidebar-footer { justify-content: center; }
}
