:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2535;
  --border: #2a3347;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --accent: #6366f1;
  --accent-hover: #4f52d6;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --purple: #a855f7;
  --blue: #3b82f6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── LOGIN ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #1e1b4b 0%, var(--bg) 70%);
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--accent);
}

.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 13px;
}

/* ── LAYOUT ── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-nav { flex: 1; padding: 0 10px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  transition: all .15s;
}

.nav-item:hover, .nav-item.active {
  background: var(--bg3);
  color: var(--text);
}

.nav-item.active { color: var(--accent); }

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* ── MAIN ── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.page-title { font-size: 22px; font-weight: 700; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ── STATS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon--blue   { background: rgba(59,130,246,.15); color: var(--blue); }
.stat-icon--green  { background: rgba(34,197,94,.15);  color: var(--green); }
.stat-icon--red    { background: rgba(239,68,68,.15);  color: var(--red); }
.stat-icon--purple { background: rgba(168,85,247,.15); color: var(--purple); }

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── CARD ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-header h3 { font-size: 15px; font-weight: 600; }

.search-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  width: 220px;
  outline: none;
  transition: border-color .15s;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* ── TABLE ── */
.table-wrapper { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tr:hover td { background: rgba(255,255,255,.02); }

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px !important;
}

.job-name { font-weight: 600; font-size: 13.5px; }
.job-url {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
}

.badge-method-get    { background: rgba(34,197,94,.15); color: #4ade80; }
.badge-method-post   { background: rgba(99,102,241,.15); color: #818cf8; }
.badge-method-put    { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-method-patch  { background: rgba(168,85,247,.15); color: #c084fc; }
.badge-method-delete { background: rgba(239,68,68,.15); color: #f87171; }

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.status-dot::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.ok::before   { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.err::before  { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.none::before { background: var(--border); }

/* Toggle */
.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

.actions { display: flex; gap: 6px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm   { padding: 5px 10px; font-size: 12px; }

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all .15s;
}

.btn-icon:hover { background: var(--bg3); color: var(--text); }

.btn-icon.danger:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ── FORMS ── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-span2 { grid-column: span 2; }
.field-row { flex-direction: row; align-items: center; }

label { font-size: 13px; font-weight: 500; color: var(--text-muted); }

.required { color: var(--accent); }

input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"],
select,
textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

select option { background: var(--bg2); }

textarea { resize: vertical; min-height: 80px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12.5px; }

.field-hint { font-size: 12px; color: var(--accent); margin-top: 2px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Headers editor */
.headers-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }

.header-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-row input { flex: 1; }

.error-msg {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #f87171;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
}

/* Toggle label */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 400;
}

.toggle-label input { display: none; }

.toggle-switch {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 20px;
  position: relative;
  transition: .2s;
  flex-shrink: 0;
}

.toggle-switch::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
}

.toggle-label input:checked ~ .toggle-switch { background: var(--accent); }
.toggle-label input:checked ~ .toggle-switch::before { transform: translateX(18px); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── DRAWER ── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  z-index: 100;
}

.drawer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 420px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: drawerIn .2s ease;
}

@keyframes drawerIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-header h3 { font-size: 16px; font-weight: 700; }
.drawer-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }

/* Log items */
.log-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.log-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

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

.log-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.badge-success { color: var(--green); font-weight: 600; }
.badge-error   { color: var(--red); font-weight: 600; }

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

.log-error {
  font-size: 12px;
  color: var(--red);
  background: rgba(239,68,68,.08);
  border-radius: 4px;
  padding: 6px 8px;
  margin-top: 6px;
  font-family: monospace;
}

.log-response {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 4px;
  padding: 6px 8px;
  margin-top: 6px;
  font-family: monospace;
  max-height: 80px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: toastIn .2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red); color: var(--red); }

/* ── CRON TAG ── */
.cron-tag {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--text-muted);
}
