:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #232735;
  --border: #2e3345;
  --text: #e4e7ef;
  --text2: #8b90a0;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
}

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

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

/* ============ Login ============ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 0%, #1a1040 100%);
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  max-width: 90vw;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.login-card .subtitle {
  color: var(--text2);
  text-align: center;
  margin-bottom: 32px;
  font-size: 14px;
}

.login-card .error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  text-align: center;
  min-height: 20px;
}

/* ============ Forms ============ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}

input:focus {
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-danger {
  background: transparent;
  color: var(--danger);
  padding: 6px 12px;
  font-size: 13px;
}

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

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-full { width: 100%; }

/* ============ Layout ============ */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 0 20px;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-brand span { font-size: 22px; }

.sidebar nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active { color: var(--primary); border-left-color: var(--primary); background: rgba(99,102,241,.08); }

.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-footer .btn { width: 100%; }

.main {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.page-header p {
  color: var(--text2);
  font-size: 14px;
  margin-top: 4px;
}

/* ============ Cards ============ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

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

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

/* ============ List Items ============ */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  word-break: break-all;
}

.list-item .url-text {
  flex: 1;
  margin-right: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}

.list-item .key-text {
  flex: 1;
  margin-right: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}

.list-empty {
  color: var(--text2);
  text-align: center;
  padding: 24px;
  font-size: 14px;
}

/* ============ Add Row ============ */
.add-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.add-row input { flex: 1; }

/* ============ Stats ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .label {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
}

.stat-card .value.success { color: var(--success); }
.stat-card .value.warning { color: var(--warning); }
.stat-card .value.danger { color: var(--danger); }

/* ============ Task Table ============ */
.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.task-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text2);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.task-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.task-table tr:hover { background: var(--bg3); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pending { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-succeeded { background: rgba(34,197,94,.15); color: var(--success); }
.badge-failed { background: rgba(239,68,68,.15); color: var(--danger); }

.prompt-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
}

.video-link:hover { text-decoration: underline; }

/* ============ Toggle ============ */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

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

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

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text2);
  border-radius: 50%;
  transition: .3s;
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: #fff; }

/* ============ Toast ============ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  margin-bottom: 8px;
  font-size: 14px;
  animation: slideIn .3s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
