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

:root {
  --sidebar-w: 232px;
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,.06);
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-active-bg: rgba(99,102,241,.18);
  --sidebar-active-text: #a5b4fc;
  --sidebar-active-border: #6366f1;
  --sidebar-logo-text: #f1f5f9;

  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --accent-light: #e0e7ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;

  --page-bg: #f1f5f9;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,.12);
  --card-radius: 12px;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border: #e2e8f0;
  --border-focus: #6366f1;
  --input-bg: #f8fafc;

  --table-stripe: #f8fafc;
  --table-hover: #f1f5f9;
  --table-header: #f8fafc;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-logo-text {
  color: var(--sidebar-logo-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}
.sidebar-logo-sub {
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sidebar-text);
  padding: 10px 8px 4px;
  opacity: .6;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-left: 2px solid transparent;
}
.nav-link:hover {
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text-hover);
}
.nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--sidebar-active-border);
}
.nav-link svg { flex-shrink: 0; opacity: .8; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--sidebar-text);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-dot.running { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,.5); }
.status-dot.stopped { background: var(--danger); }

/* ── Main layout ──────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 56px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.content {
  padding: 24px;
  flex: 1;
  max-width: 1200px;
  width: 100%;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* ── Stat cards row ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--card-shadow-hover); }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}
.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }
.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.stat-icon {
  font-size: 20px;
  margin-bottom: 6px;
}

/* ── Two-col layout ───────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--table-header);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--table-hover); }
tbody tr:nth-child(even) { background: var(--table-stripe); }
tbody tr:nth-child(even):hover { background: var(--table-hover); }
td {
  padding: 11px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}
td .deal-title {
  color: var(--text-primary);
  font-weight: 500;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td .deal-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--table-stripe);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.table-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.table-empty-icon { font-size: 32px; display: block; margin-bottom: 8px; }

/* ── Badges / Pills ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger  { background: var(--danger-light);  color: #991b1b; }
.badge-accent  { background: var(--accent-light);  color: #3730a3; }
.badge-muted   { background: #f1f5f9; color: var(--text-muted); border: 1px solid var(--border); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  transition: background .15s, box-shadow .15s, opacity .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondary { background: var(--input-bg); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-section {
  margin-bottom: 28px;
}
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-field.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
label .label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
input.sensitive { font-family: var(--font-mono); letter-spacing: .05em; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
}

/* ── Filters bar ──────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.filters label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.filters input, .filters select { height: 32px; min-width: 130px; }
.filters .btn { height: 32px; }

/* ── Alert / Toast ────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: var(--info-light);    color: #1e40af; border: 1px solid #bfdbfe; }
.alert-icon { font-size: 16px; line-height: 1.3; flex-shrink: 0; }
.alert-close {
  margin-left: auto;
  cursor: pointer;
  opacity: .6;
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
  color: inherit;
  flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pagination-info {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  transition: background .1s, color .1s;
}
.page-btn:hover:not(:disabled) { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Link ─────────────────────────────────────────────────────────────────── */
.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.link:hover { text-decoration: underline; }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td { text-align: center; padding: 32px; }

/* ── Uptime indicator ─────────────────────────────────────────────────────── */
.uptime-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  border-radius: var(--card-radius);
  color: #e2e8f0;
  margin-bottom: 24px;
}
.uptime-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(16,185,129,.6);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
.uptime-dot.stopped { background: var(--danger); box-shadow: 0 0 8px rgba(239,68,68,.6); animation: none; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 6px rgba(16,185,129,.5); }
  50%      { box-shadow: 0 0 14px rgba(16,185,129,.9); }
}
.uptime-label { font-size: 13px; font-weight: 600; }
.uptime-meta { font-size: 11px; color: #94a3b8; margin-top: 1px; }
.uptime-right { margin-left: auto; text-align: right; }

/* ── Upcoming card ────────────────────────────────────────────────────────── */
.upcoming-list { display: flex; flex-direction: column; gap: 0; }
.upcoming-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.upcoming-item:last-child { border-bottom: none; }
.upcoming-item:hover { background: var(--table-hover); }
.upcoming-time {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 52px;
}
.upcoming-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upcoming-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex-gap { display: flex; align-items: center; gap: 8px; }
.mono { font-family: var(--font-mono); font-size: 12px; }
