/* ============================================
   enowxai Dashboard — Dark Mode CSS
   ============================================ */

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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-elevated: #16162a;
  --border: #2a2a3e;
  --border-subtle: #1e1e32;
  --text-primary: #e4e4e7;
  --text-secondary: #71717a;
  --text-muted: #52525b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-subtle: rgba(99, 102, 241, 0.12);
  --success: #22c55e;
  --success-subtle: rgba(34, 197, 94, 0.12);
  --warning: #eab308;
  --warning-subtle: rgba(234, 179, 8, 0.12);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --sidebar-width: 260px;
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', monospace;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* --- Layout --- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.mobile-header .logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 199;
  opacity: 0;
  transition: opacity var(--transition);
}

.sidebar-overlay.active {
  opacity: 1;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg {
  width: 18px;
  height: 18px;
  color: white;
}

.logo-text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.version {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

/* --- Sidebar Nav --- */
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

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

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg {
  opacity: 1;
}

/* --- Sidebar Footer --- */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

.update-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--accent-subtle);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
  animation: bannerSlideIn 0.3s ease-out;
}

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

.update-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: updatePulse 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--accent);
}

@keyframes updatePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--accent); }
  50% { opacity: 0.5; box-shadow: 0 0 4px var(--accent); }
}

.update-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Update Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 92vw;
  min-height: 280px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: modalSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-color: var(--border);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
}

/* Version badges */
.update-version-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.version-tag {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 100px;
  letter-spacing: -0.01em;
}

.version-tag.current {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.version-tag.new {
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* Changelog */
.update-changelog {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  font-family: var(--font-sans);
}

.update-changelog:empty {
  display: none;
}

/* Progress steps */
.update-progress-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.progress-step.pending {
  color: var(--text-muted);
}

.progress-step.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.progress-step.done {
  color: var(--success);
}

.progress-step.error {
  color: var(--danger);
}

.step-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  position: relative;
}

.step-icon svg {
  width: 18px;
  height: 18px;
  display: none;
  position: absolute;
  top: 0;
  left: 0;
}

.progress-step .icon-pending { display: block; }
.progress-step .icon-active { display: none; }
.progress-step .icon-done { display: none; }
.progress-step .icon-error { display: none; }

.progress-step.pending .icon-pending { display: block; }
.progress-step.pending .icon-active,
.progress-step.pending .icon-done,
.progress-step.pending .icon-error { display: none; }

.progress-step.active .icon-active { display: block; }
.progress-step.active .icon-pending,
.progress-step.active .icon-done,
.progress-step.active .icon-error { display: none; }
.progress-step.active .icon-active { animation: spin 1s linear infinite; }

.progress-step.done .icon-done { display: block; }
.progress-step.done .icon-pending,
.progress-step.done .icon-active,
.progress-step.done .icon-error { display: none; }

.progress-step.error .icon-error { display: block; }
.progress-step.error .icon-pending,
.progress-step.error .icon-active,
.progress-step.error .icon-done { display: none; }

.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
}

.btn-accent:hover {
  opacity: 0.9;
}

.btn-xs {
  padding: 3px 10px;
  font-size: 0.7rem;
  border-radius: var(--radius-sm);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 32px;
}

#content {
  max-width: 1200px;
  margin: 0 auto;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* --- Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  border-color: var(--border);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.stat-card-icon svg {
  width: 18px;
  height: 18px;
}

.stat-card-icon.accent {
  background: var(--accent-subtle);
  color: var(--accent);
}

.stat-card-icon.success {
  background: var(--success-subtle);
  color: var(--success);
}

.stat-card-icon.warning {
  background: var(--warning-subtle);
  color: var(--warning);
}

.stat-card-icon.danger {
  background: var(--danger-subtle);
  color: var(--danger);
}

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Section --- */
.section {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.section-header h3 {
  font-size: 0.95rem;
}

.section-body {
  padding: 20px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

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

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--bg-tertiary);
}

td.mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.badge-active {
  background: var(--success-subtle);
  color: var(--success);
}

.badge-active::before {
  background: var(--success);
}

.badge-exhausted {
  background: var(--warning-subtle);
  color: var(--warning);
}

.badge-exhausted::before {
  background: var(--warning);
}

.badge-rate_limited {
  background: rgba(249, 115, 22, 0.1);
  color: #f97316;
}

.badge-rate_limited::before {
  background: #f97316;
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.badge-error::before {
  background: #ef4444;
}

.badge-banned {
  background: rgba(127, 29, 29, 0.15);
  color: #991b1b;
}

.badge-banned::before {
  background: #991b1b;
}

.badge-info {
  background: var(--accent-subtle);
  color: var(--accent);
}

.badge-info::before {
  background: var(--accent);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.97);
}

.btn svg {
  width: 16px;
  height: 16px;
}

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

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

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border);
}

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

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

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

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-input,
.form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  transition: all var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.empty-state-icon svg {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.empty-state h4 {
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 320px;
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

.toast.toast-out {
  animation: toastOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

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

.toast-info {
  border-left: 3px solid var(--accent);
}

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

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(24px);
  }
}

/* --- HTMX Indicator --- */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Loading bar (top of page) --- */
.htmx-request #loading-bar {
  display: block;
}

#loading-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 9999;
  animation: loadingBar 1.5s ease-in-out infinite;
}

@keyframes loadingBar {
  0% { transform: scaleX(0); transform-origin: left; }
  50% { transform: scaleX(0.7); transform-origin: left; }
  100% { transform: scaleX(1); transform-origin: left; }
}

/* --- Inline Form --- */
.inline-form {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  display: none;
}

.inline-form.active {
  display: block;
  animation: slideDown 0.2s ease-out;
}

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

.inline-form .form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* --- Hamburger Button --- */
.hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.hamburger-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.hamburger-btn svg {
  width: 18px;
  height: 18px;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: calc(var(--header-height) + 16px);
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card-value {
    font-size: 1.35rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .account-tabs {
    padding: 0 16px;
  }

  .toast-container {
    left: 16px;
    right: 16px;
  }

  .toast {
    max-width: 100%;
  }

  table {
    font-size: 0.8rem;
  }

  thead th,
  tbody td {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Utility --- */
.text-mono {
  font-family: var(--font-mono);
}

.text-muted {
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-danger {
  color: var(--danger);
}

.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

/* ============================================
   Models Page
   ============================================ */
.models-section {
  margin-bottom: 24px;
}

.models-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.provider-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.provider-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.provider-dot {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.models-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.model-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.model-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.model-card:hover {
  border-color: var(--border);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.model-card:hover::before {
  opacity: 1;
}

.model-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.model-id {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.provider-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}



.model-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-vendor {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.vendor-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vendor-dot.vendor-anthropic { background: #d97706; }
.vendor-dot.vendor-google { background: #4285f4; }
.vendor-dot.vendor-deepseek { background: #06b6d4; }
.vendor-dot.vendor-minimax { background: #f472b6; }
.vendor-dot.vendor-qwen { background: #8b5cf6; }
.vendor-dot.vendor-enowxlabs { background: var(--accent); }
.vendor-dot.vendor-zhipu { background: #f59e0b; }
.vendor-dot.vendor-kimi { background: #ec4899; }

/* ============================================
   API Key Page
   ============================================ */
.api-key-display {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.api-key-code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
  user-select: all;
}

.api-key-copy {
  flex-shrink: 0;
}

.api-key-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.inline-code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--accent);
}

/* --- Code Block --- */
.code-block {
  background: #0d0d14;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
}

.code-block-lang {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.code-block pre {
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre;
}

/* ============================================
   Docs Page — Multi-page Layout
   ============================================ */
.docs-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
}

.docs-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 16px;
  align-self: start;
}

.docs-nav-link {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
  border-left: 2px solid transparent;
}

.docs-nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.docs-nav-link.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-left-color: var(--accent);
}

.docs-main {
  min-width: 0;
}

.docs-main > h3 {
  font-size: 1.125rem;
  margin-bottom: 16px;
}

/* Steps */
.docs-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.docs-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
  margin-top: 2px;
}

.step-content h4 {
  margin-bottom: 2px;
  font-size: 0.95rem;
}

.step-content p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* API Endpoints */
.api-endpoint {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.api-endpoint:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.api-method-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.api-method {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.api-method.get {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
}

.api-method.post {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
}

.api-path {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-primary);
}

.api-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.api-params {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.api-param {
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.api-param-required {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--danger);
}

.api-param-optional {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Model Families */
.docs-model-families {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.model-family {
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.model-family h4 {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.model-family p {
  font-size: 0.82rem;
}

/* FAQ / Troubleshooting */
.docs-faq {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.faq-item {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-item h4 {
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.faq-item p {
  font-size: 0.82rem;
}

/* ============================================
   Accounts Page — Account Groups
   ============================================ */
.account-list {
  display: flex;
  flex-direction: column;
}

.account-group {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}

.account-group:last-child {
  border-bottom: none;
}

.account-group:hover {
  background: rgba(255, 255, 255, 0.01);
}

.account-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.account-email {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.account-providers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 24px;
}

.account-provider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}

.provider-name {
  color: var(--text-secondary);
  min-width: 80px;
  font-weight: 500;
}

.account-credits {
  font-size: 0.78rem;
  margin-left: auto;
}

/* --- Password Input --- */
.password-input-wrapper {
  position: relative;
}

.password-input-wrapper .form-input {
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.password-toggle:hover {
  color: var(--text-primary);
}

/* ============================================
   Slide Panel (Right Drawer)
   ============================================ */
.slide-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.slide-panel.open {
  display: flex;
}

.slide-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-panel-content {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}

.slide-panel.open .slide-panel-content {
  transform: translateX(0);
}

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

.slide-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.slide-panel-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.slide-panel-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--warning-subtle);
  border: 1px solid rgba(234, 179, 8, 0.15);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.78rem;
  color: var(--warning);
  line-height: 1.5;
}

/* --- Batch Progress --- */
.batch-progress {
  display: none;
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
}

.batch-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-subtle);
}

.batch-item:last-child {
  border-bottom: none;
}

.batch-item-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: 0.75rem;
}

.batch-item-email {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-item-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.batch-item-pending {
  color: var(--text-secondary);
}

.batch-item-pending .batch-item-icon {
  color: var(--warning);
}

.batch-item-success .batch-item-icon {
  color: var(--success);
}

.batch-item-success .batch-item-status {
  color: var(--success);
}

.batch-item-error .batch-item-icon {
  color: var(--danger);
}

.batch-item-error .batch-item-status {
  color: var(--danger);
}

.batch-summary {
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.batch-summary strong {
  color: var(--accent);
}

@media (max-width: 480px) {
  .slide-panel-content {
    width: 100vw;
    max-width: 100vw;
  }
}

/* ============================================
   Batch Job — Log Viewer & Progress
   ============================================ */
.batch-progress-bar-wrap {
  margin-bottom: 12px;
}

.batch-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.batch-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.batch-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: progressShimmer 1.5s ease-in-out infinite;
}

@keyframes progressShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.batch-progress-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 6px;
  letter-spacing: 0.01em;
}

.batch-logs {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
  max-height: 400px;
  min-height: 120px;
  overflow-y: auto;
  flex: 1;
}

.batch-logs-done {
  max-height: 300px;
  margin-top: 12px;
}

.log-line {
  padding: 2px 0;
  line-height: 1.6;
  word-break: break-word;
}

.log-time {
  color: var(--text-muted);
  margin-right: 8px;
  font-size: 0.68rem;
}

.log-info { color: var(--text-secondary); }
.log-success { color: var(--success); }
.log-error { color: var(--danger); }
.log-warn { color: var(--warning); }

.batch-done-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: center;
}

.batch-done-icon {
  font-size: 2rem;
  line-height: 1;
}

.batch-done-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.batch-done-stats {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ============================================
   Responsive — Models, Docs, API Key
   ============================================ */
@media (max-width: 1024px) {
  .models-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .models-grid {
    grid-template-columns: 1fr;
  }

  .api-key-display {
    flex-direction: column;
    align-items: stretch;
  }

  .api-key-copy {
    align-self: flex-end;
  }

  .account-providers {
    padding-left: 0;
  }

  .account-provider-row {
    flex-wrap: wrap;
  }

  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
  }

  .docs-nav-link {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .docs-nav-link.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
}

/* ============================================
   Tier Badges
   ============================================ */
.tier-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.tier-standard {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.tier-max {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

/* ============================================
   Account Tabs
   ============================================ */
.account-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.account-tab {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.account-tab:hover {
  color: var(--text-primary);
}

.account-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.account-tab .tab-count {
  margin-left: 6px;
  font-size: 0.75rem;
  opacity: 0.6;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================
   Dashboard — Tier Panels & Secondary Stats
   ============================================ */
.tier-panels {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.tier-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: box-shadow var(--transition);
}

.tier-panel:hover {
  box-shadow: var(--shadow-sm);
}

.tier-panel-standard {
  border-left: 3px solid rgba(148, 163, 184, 0.3);
}

.tier-panel-max {
  border-left: 3px solid rgba(251, 191, 36, 0.3);
}

.tier-panel-header {
  margin-bottom: 16px;
}

.tier-panel-body {
  display: flex;
  flex-direction: column;
}

.tier-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.tier-stat-row:last-child {
  border-bottom: none;
}

.tier-stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.tier-stat-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.tier-stat-dim {
  font-weight: 400;
  opacity: 0.5;
}

.tier-stat-highlight {
  color: var(--success);
}

/* --- Secondary Stats --- */
.secondary-stats {
  display: flex;
  flex-direction: row;
  gap: 24px;
  padding: 16px 0;
  margin-top: 8px;
  margin-bottom: 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.secondary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.secondary-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.secondary-stat-value {
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* --- Responsive: Tier Panels & Secondary Stats --- */
@media (max-width: 768px) {
  .tier-panels {
    grid-template-columns: 1fr;
  }

  .secondary-stats {
    flex-wrap: wrap;
  }
}

/* Status pills */
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0;
}

.pill-success {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
}

.pill-warning {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

.pill-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

/* General panel */
.tier-panel-general {
  margin-top: 16px;
  margin-bottom: 24px;
  border-left: 3px solid rgba(99, 102, 241, 0.3);
}

.tier-badge.tier-general {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.25);
}
