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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #f9fafb;
  color: #111827;
}

/* ── Layout ──────────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 224px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 14px 24px;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Sidebar logo ────────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: #2563eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-logo-name { font-size: 14px; font-weight: 600; color: #111827; }
.sidebar-logo-ver  { font-size: 11px; color: #9ca3af; }

/* ── Nav ─────────────────────────────────────────────────── */
.nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.nav-group {
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
  user-select: none;
}

.nav-item:hover       { background: #f3f4f6; color: #111827; }
.nav-item.active      { background: #eff6ff; color: #1d4ed8; }
.nav-item.active i    { color: #1d4ed8; }
.nav-item i           { width: 16px; text-align: center; font-size: 13px; color: #9ca3af; }

/* ── Sidebar footer ──────────────────────────────────────── */
.sidebar-footer {
  padding: 10px;
  border-top: 1px solid #e5e7eb;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f9fafb;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name    { font-size: 13px; font-weight: 500; color: #374151; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout  { background: none; border: none; cursor: pointer; color: #9ca3af; font-size: 13px; padding: 2px 4px; transition: color 0.15s; }
.user-logout:hover { color: #ef4444; }

/* ── Topbar ──────────────────────────────────────────────── */
.page-title { font-size: 15px; font-weight: 600; color: #111827; }
.page-sub   { font-size: 12px; color: #9ca3af; margin-top: 1px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.card-body { padding: 20px; }

/* ── Stat cards ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px 20px;
}

.stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  margin-bottom: 12px;
}

.stat-value { font-size: 24px; font-weight: 700; color: #111827; }
.stat-label { font-size: 11px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-hint  { font-size: 11px; color: #9ca3af; margin-top: 3px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary   { background: #2563eb; color: #fff; }
.btn-primary:hover   { background: #1d4ed8; }
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger    { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover    { background: #fee2e2; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 6px; }
.form-hint   { font-size: 11px; color: #9ca3af; margin-top: 5px; }

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.form-input.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* Toggle switch */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; gap: 10px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 36px; height: 20px;
  background: #d1d5db;
  border-radius: 10px;
  transition: background 0.2s;
  position: relative;
  flex-shrink: 0;
}
.toggle input:checked + .toggle-track { background: #2563eb; }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* ── Table ───────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid #f3f4f6;
}
.table td { padding: 12px 14px; border-bottom: 1px solid #f9fafb; color: #374151; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f9fafb; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-success { background: #f0fdf4; color: #16a34a; }
.badge-danger  { background: #fef2f2; color: #dc2626; }
.badge-warning { background: #fffbeb; color: #d97706; }
.badge-info    { background: #eff6ff; color: #2563eb; }
.badge-gray    { background: #f3f4f6; color: #6b7280; }
.badge-running { background: #eff6ff; color: #2563eb; }

/* ── Empty state ─────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: #9ca3af;
  text-align: center;
}
.empty i      { font-size: 28px; margin-bottom: 10px; }
.empty p      { font-size: 13px; }
.empty small  { font-size: 12px; margin-top: 4px; }

/* ── Alert / status ──────────────────────────────────────── */
.alert {
  display: none;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
}
.alert.show       { display: flex; align-items: center; gap: 8px; }
.alert-success    { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-error      { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.alert-info       { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
}


.toast {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  min-width: 240px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(110%);
  transition: transform 0.25s ease;
}
.toast.show         { transform: translateX(0); }
.toast.toast-success { border-left: 3px solid #16a34a; }
.toast.toast-error   { border-left: 3px solid #dc2626; }
.toast.toast-info    { border-left: 3px solid #2563eb; }

/* ── Divider ─────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid #f3f4f6; margin: 16px 0; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 2px; }

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cron presets ────────────────────────────────────────── */
.cron-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cron-preset {
  padding: 3px 10px;
  border-radius: 6px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-size: 11px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'JetBrains Mono', monospace;
}
.cron-preset:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }


/* ── Monitoring ──────────────────────────────────────────── */

/* Status badge in page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

.badge-green  { background: #f0fdf4; color: #16a34a; }
.badge-red    { background: #fef2f2; color: #dc2626; }

/* ── Metric cards grid ───────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px 18px;
  transition: border-color 0.2s;
}

.metric-card.metric-ok     { border-left: 3px solid #16a34a; }
.metric-card.metric-warn   { border-left: 3px solid #d97706; }
.metric-card.metric-danger { border-left: 3px solid #dc2626; }

.metric-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.metric-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #6b7280;
  flex-shrink: 0;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 1;
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
  font-family: 'JetBrains Mono', monospace;
}

/* Progress bar */
.metric-bar-track {
  height: 5px;
  background: #f3f4f6;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

.metric-bar {
  height: 100%;
  border-radius: 3px;
  background: #2563eb;
  transition: width 0.4s ease;
}

.metric-card.metric-warn   .metric-bar { background: #d97706; }
.metric-card.metric-danger .metric-bar { background: #dc2626; }

.metric-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #9ca3af;
}

.metric-footer i { font-size: 10px; }

/* Network card rows */
.metric-net-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
}

.net-direction {
  width: 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 11px;
}

/* ── Section title ───────────────────────────────────────── */
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title span {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #9ca3af;
}

.section-title i { font-size: 11px; }

/* ── Chart range buttons ─────────────────────────────────── */
.chart-range-btns {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.btn-outline {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #6b7280;
}

.btn-outline:hover  { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.btn-outline.active { border-color: #2563eb; color: #2563eb; background: #eff6ff; }

/* ── Charts grid ─────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 8px;
}

.chart-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px 18px;
}

.chart-title {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-title i { font-size: 10px; }

/* ── Config form ─────────────────────────────────────────── */
.card { padding: 20px; }

.form-row {
  margin-bottom: 16px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.form-group label i { font-size: 11px; color: #9ca3af; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: #111827;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.form-group small {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-top: 5px;
}

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

.save-msg {
  font-size: 12px;
  font-weight: 500;
}

.save-msg.success { color: #16a34a; }
.save-msg.error   { color: #dc2626; }

/* ── Active alerts ───────────────────────────────────────── */
.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  border-left: 3px solid #d97706;
}

.alert-row.alert-cpu  { border-left-color: #2563eb; }
.alert-row.alert-ram  { border-left-color: #7c3aed; }
.alert-row.alert-disk { border-left-color: #dc2626; }

.alert-metric {
  font-size: 11px;
  font-weight: 700;
  color: #374151;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 5px;
  min-width: 44px;
  text-align: center;
}

.alert-value {
  flex: 1;
  color: #374151;
}

.alert-time {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  font-size: 13px;
  color: #9ca3af;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.chart-wrap {
  position: relative;
  height: 120px;
  width: 100%;
}
/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid  { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .charts-grid  { grid-template-columns: 1fr; }
  .form-grid    { grid-template-columns: 1fr; }
}