:root {
  --bg: #0f1218;
  --bg-2: #161b24;
  --bg-3: #1d2531;
  --border: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a9;
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #38bdf8;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); font-size: 13px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.15s;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2b45 0%, var(--bg) 60%);
}
.login-card {
  width: 360px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: -6px 0 6px; }
.login-card label, .filters label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input, .filters input, .filters select, select, input {
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text);
  padding: 9px 11px; border-radius: 8px; font-size: 14px; outline: none;
}
.login-card input:focus, .filters input:focus, .filters select:focus { border-color: var(--primary); }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 8px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 18px; font-weight: 700; padding: 6px 10px 16px; }
.brand span { color: var(--muted); font-weight: 500; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
  color: var(--muted); text-decoration: none; padding: 10px 12px;
  border-radius: 8px; transition: 0.15s; font-size: 14px;
}
.sidebar nav a:hover { background: var(--bg-3); color: var(--text); }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-foot .btn { width: 100%; }

.page { flex: 1; padding: 28px 32px; overflow-x: auto; }
.page h1 { margin: 0 0 4px; font-size: 22px; }
.page .sub { color: var(--muted); margin: 0 0 22px; }

/* ---------- stat cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px;
}
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 30px; font-weight: 700; margin-top: 6px; }
.card.green .value { color: var(--green); }
.card.red .value { color: var(--red); }
.card.amber .value { color: var(--amber); }
.card.blue .value { color: var(--blue); }

.section-title { font-size: 16px; margin: 8px 0 12px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

.panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--bg-3); }
td.mono, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  text-transform: capitalize;
}
.badge.pending { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.badge.processing { background: rgba(56, 189, 248, 0.15); color: var(--blue); }
.badge.success { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.badge.failed { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.badge.type { background: var(--bg-3); color: var(--text); text-transform: none; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.filters > div { display: flex; flex-direction: column; gap: 6px; }
.filters label { font-size: 12px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters .grow input { width: 100%; }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; gap: 12px; margin-top: 16px; justify-content: flex-end; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  width: min(880px, 96vw); max-height: 90vh; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--border); }
.tab { background: transparent; border: none; color: var(--muted); padding: 8px 14px; cursor: pointer; border-radius: 8px 8px 0 0; font-size: 13px; }
.tab.active { color: var(--text); border-bottom: 2px solid var(--primary); }
.modal-body { padding: 18px 20px; overflow: auto; flex: 1; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-word; }
pre.code {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow: auto; font-size: 12px; max-height: 360px; white-space: pre-wrap; word-break: break-word;
}
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.img-grid a { display: block; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.img-grid img { width: 100%; display: block; background: var(--bg); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100;
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }

.loading { color: var(--muted); padding: 30px; text-align: center; }
.empty { color: var(--muted); padding: 40px; text-align: center; }
.bar { height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--green); }
.row-actions { display: flex; gap: 6px; }

/* ---------- settings ---------- */
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--border); gap: 16px;
}
.setting-row:last-of-type { border-bottom: none; }
.setting-actions { display: flex; gap: 10px; margin-top: 14px; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input {
  width: 72px; text-align: center; padding: 8px 6px;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; font-size: 14px;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input[type=number] { -moz-appearance: textfield; }
.stepper .btn { padding: 6px 12px; min-width: 34px; font-size: 15px; line-height: 1; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 999px; transition: 0.2s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; left: 3px; top: 2px; width: 18px; height: 18px;
  background: var(--muted); border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); background: #fff; }

.danger-zone { border-color: rgba(239, 68, 68, 0.35); }
.danger-zone .section-title { margin-top: 0; }

.dashboard-actions { display: flex; gap: 10px; margin: -8px 0 22px; }

/* Bulk selection on the task list */
.check-col { width: 34px; text-align: center; padding-right: 0; }
.check-col input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); vertical-align: middle; }
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bulk-bar b { color: var(--text); }
.bulk-bar .btn-ghost { margin-left: auto; }
