:root {
  color-scheme: light;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  --bg: #f5f7fb;
  --bg-soft: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-muted: #eef2ff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5f5;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --overlay: rgba(15, 23, 42, 0.4);
  --toast-bg: #0f172a;
  --toggle-bg: #e2e8f0;
  --toggle-thumb: #ffffff;
}

.dark {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-soft: #111827;
  --bg-elevated: #0f172a;
  --bg-muted: #111827;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-soft: #94a3b8;
  --border: #1f2937;
  --border-strong: #1f2937;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.4);
  --overlay: rgba(2, 6, 23, 0.7);
  --toast-bg: #1f2937;
  --toggle-bg: #1f2937;
  --toggle-thumb: #e2e8f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 28px;
  font-weight: 700;
}

.topbar p {
  color: var(--text-muted);
  margin-top: 6px;
}

.topbar-actions {
  display: flex;
  gap: 12px;
}

.btn {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.btn:hover {
  background: #1d4ed8;
}

.btn-outline {
  background: var(--bg-soft);
  color: #1e40af;
  border: 1px solid var(--border-strong);
}

.btn-outline:hover {
  background: var(--bg-muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

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

.card {
  background: var(--bg-soft);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.card-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.chip {
  background: var(--bg-muted);
  color: #1d4ed8;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.stat h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat p {
  font-size: 22px;
  font-weight: 700;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
}

.list-item .info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-item .title {
  font-weight: 600;
}

.list-item .meta {
  font-size: 12px;
  color: var(--text-muted);
}

.status {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
}

.status.success {
  background: #dcfce7;
  color: #15803d;
}

.status.error {
  background: #fee2e2;
  color: #b91c1c;
}

.status.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.status.paused {
  background: #fef3c7;
  color: #b45309;
}

body.dark .status.success {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

body.dark .status.error {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

body.dark .status.active {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

body.dark .status.paused {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle input {
  width: 42px;
  height: 22px;
  appearance: none;
  background: var(--toggle-bg);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: 0.2s ease;
}

.toggle input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 16px;
  height: 16px;
  background: var(--toggle-thumb);
  border-radius: 50%;
  transition: 0.2s ease;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.toggle input:checked {
  background: #2563eb;
}

.toggle input:checked::after {
  transform: translateX(18px);
}

.modal {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-soft);
  border-radius: 20px;
  padding: 24px;
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.modal-body input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: var(--bg-soft);
  color: var(--text);
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--toast-bg);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2);
  z-index: 100;
}

.toast.hidden {
  display: none;
}

@media (max-width: 768px) {
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
