/* ══════════════════════════════════════════════════════════════
   DASHBOARD COMPONENTS — Page-specific styles
   These are NOT generic utilities — they're specific to dashboard.html
   ══════════════════════════════════════════════════════════════ */

/* ── Dashboard Layout ─────────────────────────────────────── */
.dashboard-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.03);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  overflow: hidden;
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--border);
}

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

.sidebar-brand h1 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #e5e5e5;
}

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

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border);
}

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

.sidebar-nav-item:hover {
  color: var(--text);
  background: var(--surface2);
}

.sidebar-nav-item.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.sidebar-nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-nav-icon svg {
  width: 20px;
  height: 20px;
}

.sidebar-nav-info {
  flex: 1;
  min-width: 0;
}

.sidebar-nav-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.sidebar-nav-item.active .sidebar-nav-name {
  color: #a78bfa;
}

.sidebar-nav-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main area ────────────────────────────────────────────── */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
}

/* ── Theme Toggle ─────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* ── Light Mode ───────────────────────────────────────────── */
body.light {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface2: #f1f3f5;
  --surface3: #e9ecef;
  --border: #dee2e6;
  --border2: #ced4da;
  --text: #212529;
  --text-dim: #6c757d;
  --text-faint: #adb5bd;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99,102,241,0.1);
  --green: #16a34a;
  --green-bg: rgba(22,163,74,0.1);
  --yellow: #ca8a04;
  --red: #dc2626;
  --red-bg: rgba(220,38,38,0.1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.15);
}

body.light .topbar {
  background: rgba(255,255,255,0.85);
  border-bottom: 1px solid var(--border);
}

body.light .sidebar {
  background: #ffffff;
  border-right: 1px solid var(--border);
  box-shadow: none;
}

body.light .content::before {
  display: none;
}

body.light .sidebar-brand h1 {
  color: #212529;
}

body.light .sidebar-nav-item.active .sidebar-nav-name {
  color: #4f46e5;
}

body.light .dropdown-menu {
  background: var(--surface);
  border: 1px solid var(--border2);
}

body.light .dropdown-menu button:hover {
  background: var(--surface2);
}

body.light .field-input {
  background: var(--bg);
  border-color: var(--border2);
  color: var(--text);
}

body.light .field-input::placeholder {
  color: var(--text-faint);
}

body.light .badge {
  background: var(--accent-glow);
  color: var(--accent);
}

body.light .settings-section {
  background: var(--surface);
  border-color: var(--border);
}

body.light .api-key-display {
  background: var(--bg);
  border-color: var(--border2);
  color: var(--text);
}

body.light .credits-bar-track {
  background: var(--bg);
}

body.light .credits-bar-fill {
  background: var(--accent);
}

body.light .modal {
  background: var(--surface);
  border-color: var(--border2);
}

body.light .modal h3 {
  color: var(--text);
}

body.light .modal p {
  color: var(--text-dim);
}

body.light .toast {
  background: var(--surface);
  border-color: var(--green);
  color: var(--green);
}

body.light .empty-state svg {
  opacity: 0.4;
}

body.light .empty-state h3 {
  color: var(--text);
}

body.light .empty-state p {
  color: var(--text-dim);
}

body.light .doc-card {
  background: var(--surface);
  border-color: var(--border);
}

body.light .doc-name {
  color: var(--text);
}

body.light .doc-url {
  color: var(--accent);
}

body.light .upload-zone {
  background: var(--surface);
  border-color: var(--border2);
}

body.light .upload-zone:hover,
body.light .upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

body.light .upload-zone h3 {
  color: var(--text);
}

body.light .upload-zone p {
  color: var(--text-dim);
}

body.light .upload-result {
  background: var(--surface);
  border-color: var(--border);
}

body.light .upload-result .url-box {
  background: var(--bg);
  border-color: var(--border2);
  color: var(--accent);
}

body.light .template-chip {
  background: var(--bg);
  border-color: var(--border2);
  color: var(--text-dim);
}

body.light .template-chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface2);
}

body.light .template-chip.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

body.light .template-chip-wrapper {
  background: var(--bg);
  border-color: var(--border2);
}

body.light .template-chip-wrapper:hover {
  border-color: var(--accent);
}

body.light .template-chip-wrapper.active {
  background: var(--accent-glow);
  border-color: var(--accent);
}

body.light .template-chip-wrapper.active .template-chip {
  color: #4f46e5;
}

body.light .sidebar-generate-btn {
  background: var(--accent);
  color: white;
}

body.light .sidebar-generate-btn:hover {
  background: var(--accent-hover);
}

body.light .sidebar-input {
  background: var(--bg);
  border-color: var(--border2);
  color: var(--text);
}

body.light .sidebar-input::placeholder {
  color: var(--text-faint);
}

body.light .variable-chip {
  background: var(--bg);
  border-color: var(--border2);
  color: var(--text);
}

body.light .variable-chip:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

body.light .variable-chip.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

body.light .btn-secondary {
  background: var(--surface2);
  border-color: var(--border2);
  color: var(--text);
}

body.light .btn-secondary:hover {
  background: var(--surface3);
  border-color: var(--accent);
}

body.light .btn-danger {
  background: var(--red-bg);
  border-color: rgba(220,38,38,0.3);
  color: var(--red);
}

body.light .btn-danger:hover {
  background: rgba(220,38,38,0.15);
}

body.light .sidebar-actions {
  background: var(--surface);
  border-top-color: var(--border);
}

body.light .sidebar-share-row {
  color: var(--text-dim);
}

body.light .share-result {
  background: var(--green-bg);
  border-color: rgba(22,163,74,0.3);
  color: var(--green);
}

body.light .share-result a {
  color: var(--green);
}

body.light .download-result a {
  color: var(--accent);
}

body.light .job-status {
  background: var(--surface2);
  color: var(--text-dim);
}

body.light .auth-card {
  background: var(--surface);
  border-color: var(--border);
}

body.light .auth-card h2 {
  color: var(--text);
}

body.light .auth-card p {
  color: var(--text-dim);
}

body.light .auth-error {
  background: var(--red-bg);
  border-color: rgba(220,38,38,0.3);
  color: var(--red);
}

.user-menu {
  position: relative;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.user-avatar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border2);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.user-avatar-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

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

.user-menu-btn:hover {
  border-color: var(--accent);
}

.user-menu-btn svg {
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
}

.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}

.dropdown-menu button:hover {
  background: var(--surface2);
}

.dropdown-menu button svg {
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}

/* ── Content ──────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 32px 24px;
  min-height: 0;
  overflow-y: auto;
  position: relative;
}

/* Recessed workspace — content sits inside a subtle inset */
.content::before {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), inset 0 0 40px rgba(0,0,0,0.3);
  pointer-events: none;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}

/* ── Templates Tab ────────────────────────────────────────── */
.templates-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  min-height: 500px;
}

.template-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.template-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.template-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.template-list-item:hover {
  background: var(--surface2);
}

.template-list-item.active {
  background: var(--accent-glow);
  border-left: 2px solid var(--accent);
}

.template-list-item .name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--accent-glow);
  color: #a78bfa;
}

.template-form-area {
  display: flex;
  gap: 24px;
}

.template-form {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.template-preview {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-frame {
  flex: 1;
  background: white;
  min-height: 400px;
}

.preview-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  min-height: 400px;
}

.empty-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}

/* ── Form Fields ──────────────────────────────────────────── */
.field-group {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.field-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-input::placeholder {
  color: var(--text-faint);
}

textarea.field-input {
  min-height: 80px;
  resize: vertical;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.checkbox-group label {
  font-size: 0.85rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
}

.array-group {
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}

.array-group .field-group {
  margin-bottom: 10px;
}

.array-group .field-group:last-child {
  margin-bottom: 0;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: none;
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-remove {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: none;
  border: none;
  color: var(--red);
  font-size: 0.75rem;
  cursor: pointer;
}

.btn-remove:hover {
  text-decoration: underline;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--accent);
  color: white;
  border: 1px solid rgba(99,102,241,0.5);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 0 0 0 rgba(99,102,241,0);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(99,102,241,0.3);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn-icon {
  padding: 6px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── Upload Tab ───────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  padding: 64px 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--surface);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-zone svg {
  width: 48px;
  height: 48px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.upload-zone.dragover svg {
  color: var(--accent);
}

.upload-zone h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.upload-zone p {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-slug {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-slug label {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.upload-slug .slug-prefix {
  font-size: 0.85rem;
  color: var(--text-faint);
  font-family: var(--mono);
}

.upload-slug input {
  flex: 1;
  max-width: 240px;
}

.upload-result {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.upload-result .url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.upload-result .url-box {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Shared Tab ───────────────────────────────────────────── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(255,255,255,0.04);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.doc-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.doc-icon {
  width: 40px;
  height: 40px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-url {
  font-size: 0.75rem;
  color: var(--accent);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-stats {
  display: flex;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.doc-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-date {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.doc-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-dim);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.85rem;
  max-width: 360px;
  margin: 0 auto;
}

/* ── Settings ─────────────────────────────────────────────── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(255,255,255,0.03);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.api-key-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-all;
}

.api-key-display .key-text {
  flex: 1;
}

.credits-bar {
  margin-top: 12px;
}

.credits-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.credits-bar-header .plan {
  color: #a78bfa;
  font-weight: 500;
}

.credits-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.credits-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width var(--transition-slow);
}

.credits-bar-fill.warning {
  background: var(--yellow);
}

.credits-bar-fill.danger {
  background: var(--red);
}

/* ── Status Bar ────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.status-bar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.status-plan {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  min-width: 80px;
  white-space: nowrap;
}

.status-credits {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap;
  margin-left: 0.5rem;
}

.status-bar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.status-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.status-stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.status-bar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-xl);
}

.modal h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.modal p {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  animation: fadeInUp 0.2s ease;
}

/* ── Auth gate ────────────────────────────────────────────── */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-card p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.auth-card .field-group {
  text-align: left;
}

.auth-card .field-input {
  font-size: 0.95rem;
  padding: 12px 14px;
}

.auth-card .btn-primary {
  width: 100%;
  justify-content: center;
  margin-top: 16px;
  padding: 12px;
}

.auth-error {
  padding: 10px 14px;
  background: var(--red-bg);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: auto;
    background: var(--sidebar-bg);
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
  }

  .sidebar-brand {
    padding: 12px 16px;
    border-bottom: none;
  }

  .sidebar-brand h1 {
    font-size: 1rem;
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding: 0 8px 8px;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar-nav-item {
    padding: 10px 14px;
    white-space: nowrap;
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm);
    min-width: 0;
  }

  .sidebar-nav-item:hover {
    background: var(--surface2);
  }

  .sidebar-nav-item.active {
    border-left: none;
    border-bottom: 2px solid var(--accent);
    background: var(--accent-glow);
  }

  .sidebar-nav-desc {
    display: none;
  }

  .sidebar-bottom {
    display: none;
  }

  .main-area {
    margin-left: 0;
    padding-top: 100px;
  }

  .content {
    padding: 24px 16px;
  }

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

  .template-form-area {
    flex-direction: column;
  }

  .doc-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Misc ─────────────────────────────────────────────────── */
.generate-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.share-result {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--green-bg);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--green);
}

.share-result a {
  color: var(--green);
  font-family: var(--mono);
}

.download-result {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-result a {
  color: var(--accent);
  font-size: 0.85rem;
}

.job-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ══════════════════════════════════════════════════════════════
   TEMPLATES TAB REDESIGN — Preview-First Layout
   Top selector bar + Left preview (65%) + Right variables sidebar (35%)
   ══════════════════════════════════════════════════════════════ */

/* ── Main Layout Grid ────────────────────────────────────── */
.templates-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: auto auto auto 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

/* ── Template Selector Bar (Top) ─────────────────────────── */
.template-selector {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: block;
}

.template-selector-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  margin-right: 4px;
}

.template-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
}

.template-chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface2);
}

.template-chip.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: #a78bfa;
}

.template-chip .chip-icon {
  font-size: 1rem;
}

/* ── Template Search ─────────────────────────────────────── */
.template-search-wrap {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
}

.template-search {
  width: 100%;
  height: 36px;
  padding: 0 16px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 99px;
  font-size: 0.8rem;
  color: var(--text);
  min-width: 240px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.template-search::placeholder {
  color: var(--text-faint);
}

.template-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Template Section (Collapsible) ──────────────────────── */
.template-section {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 0;
}

.template-section:last-child {
  margin-bottom: 0;
}

.template-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.template-section-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-section-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.template-section-count {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.template-section-chevron {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: transform 0.2s;
}

.template-section-chevron.expanded {
  transform: rotate(180deg);
}

.template-section.collapsed .template-section-body {
  display: none;
}

.template-section-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* ── Template Chip Wrapper & Menu ────────────────────────── */
.template-chip-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 99px;
  transition: all 0.15s;
}

.template-chip-wrapper:hover {
  border-color: var(--accent);
}

.template-chip-wrapper.active {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.template-chip-wrapper.active .template-chip {
  color: #a78bfa;
}

.template-chip-wrapper .template-chip {
  border: none;
  background: transparent;
  padding-right: 4px;
}

.template-menu-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 99px;
  color: var(--text-dim);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.template-menu-btn:hover {
  background: var(--surface2);
  color: var(--text);
}

/* ── Template Dropdown ───────────────────────────────────── */
.template-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
}

.template-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
}

.template-dropdown button:hover {
  background: var(--surface2);
}

.template-dropdown .danger {
  color: var(--red);
}

/* ── Preview Area (Left) ─────────────────────────────────── */
.template-preview-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

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

.preview-toolbar-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface2, #f3f4f6);
  border-radius: var(--radius-sm, 6px);
  padding: 2px;
}

.preview-tab-btn {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  border: none;
  border-radius: calc(var(--radius-sm, 6px) - 2px);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.preview-tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

.preview-tab-btn.active {
  color: var(--text);
  background: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  font-weight: 600;
}

body.dark .preview-tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.dark .preview-tab-btn.active {
  background: var(--surface3, rgba(255, 255, 255, 0.12));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.template-preview-area .preview-frame {
  flex: 1;
  background: white;
  min-height: 300px;
  position: relative;
  overflow-y: auto;
}

.template-preview-area .preview-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  min-height: 300px;
}

.template-preview-area .empty-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  gap: 8px;
  padding: 40px;
}

.template-preview-area .empty-preview svg {
  width: 48px;
  height: 48px;
  opacity: 0.3;
}

/* ── Variables Sidebar (Right) ───────────────────────────── */
.template-variables-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
  border-bottom: none;
}

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

.sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
}

.sidebar-section-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 8px;
  border-radius: 99px;
}

/* ── Variable Chips (Interactive) ────────────────────────── */
.variable-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 120px;
  overflow-y: auto;
}

.variable-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 99px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.variable-chip:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: #a78bfa;
  transform: translateY(-1px);
}

.variable-chip.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: #a78bfa;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.variable-chip.invalid {
  border-color: rgba(239,68,68,0.3);
  background: var(--red-bg);
  color: var(--red);
}

/* ── Input Fields in Sidebar ─────────────────────────────── */
.sidebar-inputs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.sidebar-input-group {
  margin-bottom: 14px;
}

.sidebar-input-group:last-child {
  margin-bottom: 0;
}

.sidebar-input-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sidebar-input-label .var-type-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--surface2);
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: normal;
}

.sidebar-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  outline: none;
  transition: all 0.15s;
}

.sidebar-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.sidebar-input::placeholder {
  color: var(--text-faint);
}

/* ── Array/Loop Items in Sidebar ─────────────────────────── */
.sidebar-array-group {
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 10px;
  background: var(--bg);
}

.sidebar-array-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sidebar-array-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sidebar-array-remove {
  padding: 2px 6px;
  background: none;
  border: none;
  color: var(--red);
  font-size: 0.7rem;
  cursor: pointer;
}

.sidebar-array-remove:hover {
  text-decoration: underline;
}

.sidebar-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: none;
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 8px;
}

.sidebar-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Generate Button in Sidebar ──────────────────────────── */
.sidebar-actions {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-generate-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.sidebar-generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sidebar-share-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.sidebar-share-row input[type="checkbox"] {
  accent-color: var(--accent);
}

/* ── Preview Highlight Effect (injected via JS into iframe) ──── */
.preview-var-highlight {
  background: rgba(99,102,241,0.3) !important;
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
  border-radius: 2px;
  transition: all 0.2s ease;
}

/* ══════════════════════════════════════════════════════════════
   DOCX TEMPLATE UPLOAD
   ══════════════════════════════════════════════════════════════ */

.docx-upload-chip {
  border-style: dashed;
  color: var(--accent);
  margin-left: auto;
}

.docx-upload-chip:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.docx-upload-chip svg {
  flex-shrink: 0;
}

.docx-upload-modal {
  max-width: 480px;
}

.docx-drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-sm);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.docx-drop-zone:hover,
.docx-drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.docx-drop-zone svg {
  width: 36px;
  height: 36px;
  color: var(--text-dim);
}

.docx-drop-zone.dragover svg {
  color: var(--accent);
}

.docx-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.docx-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.docx-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.docx-progress-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--mono);
  min-width: 36px;
  text-align: right;
}

.docx-success {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--green-bg);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: var(--radius-sm);
  color: var(--green);
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 12px;
}

body.light .docx-drop-zone {
  background: var(--bg);
  border-color: var(--border2);
}

body.light .docx-drop-zone:hover,
body.light .docx-drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

body.light .docx-progress-bar {
  background: var(--surface2);
}

/* ══════════════════════════════════════════════════════════════
   BATCH GENERATE — Wizard styles
   ══════════════════════════════════════════════════════════════ */

.batch-container {
  max-width: none;
}

/* ── Step Container ────────────────────────────────────────── */
.batch-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-lg);
  overflow: visible;
  padding: 3%;
}

.batch-step-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: none;
}

.batch-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.batch-step-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.batch-step-content {
  padding: var(--space-lg) var(--space-xl);
}

/* ── Variables Display ─────────────────────────────────────── */
.batch-variables {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--surface2);
  border-radius: var(--radius-sm);
}

.batch-variables-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: var(--space-sm);
}

.batch-variables-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* ── Column Mapper ─────────────────────────────────────────── */
.batch-mapper {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.batch-mapper-header {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--surface3);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.batch-mapper-row {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  align-items: center;
  border-bottom: 1px solid var(--border);
}

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

.batch-mapper-csv {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.batch-mapper-arrow {
  text-align: center;
  color: var(--text-dim);
  font-size: 1.2rem;
}

.batch-mapper-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--mono);
}

.batch-mapper-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Preview ────────────────────────────────────────────────── */
.batch-preview-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-md);
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
  color: var(--text);
}

.batch-preview-frame {
  margin-bottom: var(--space-md);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.batch-data-preview {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.batch-data-header {
  padding: var(--space-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.batch-data-table-wrapper {
  overflow-x: auto;
}

.batch-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.batch-data-table th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface3);
  border-bottom: 1px solid var(--border);
}

.batch-data-table td {
  padding: var(--space-sm) var(--space-md);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

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

.batch-data-table tr.active-row {
  background: var(--accent-glow);
}

/* ── Summary ────────────────────────────────────────────────── */
.batch-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.batch-summary-item {
  background: var(--surface2);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  text-align: center;
}

.batch-summary-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: var(--space-xs);
}

.batch-summary-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.batch-share-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  font-size: 0.9rem;
  color: var(--text);
}

.batch-share-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ── Progress Bar ──────────────────────────────────────────── */
.batch-progress {
  margin-bottom: var(--space-lg);
}

.batch-progress-bar {
  height: 12px;
  background: var(--surface2);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.batch-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.batch-progress-text {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* ── Results Table ─────────────────────────────────────────── */
.batch-results-table-wrapper {
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}

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

.batch-results-table th {
  padding: var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.batch-results-table td {
  padding: var(--space-md);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

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

/* ── Status Badges ─────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.status-completed {
  background: var(--green-bg);
  color: var(--green);
}

.status-processing {
  background: var(--accent-glow);
  color: var(--accent);
}

.status-queued {
  background: rgba(234,179,8,0.1);
  color: var(--yellow);
}

.status-failed {
  background: var(--red-bg);
  color: var(--red);
}

/* ── Navigation Buttons ────────────────────────────────────── */
.batch-nav-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

body.light .batch-nav-buttons {
  border-color: var(--border2);
}

/* ── Warning ────────────────────────────────────────────────── */
.batch-warning {
  padding: var(--space-md);
  background: rgba(234,179,8,0.1);
  border: 1px solid rgba(234,179,8,0.3);
  border-radius: var(--radius-sm);
  color: var(--yellow);
  font-size: 0.9rem;
  margin-top: var(--space-md);
}

.error-tooltip {
  font-size: 0.8rem;
  color: var(--red);
  cursor: help;
}

/* ── Light Mode ─────────────────────────────────────────────── */
body.light .batch-step {
  border-color: var(--border2);
}

body.light .batch-step-header {
  background: transparent;
  border-color: var(--border2);
}

body.light .batch-mapper-header {
  background: var(--bg);
  border-color: var(--border2);
}

body.light .batch-mapper-select {
  background: var(--bg);
  border-color: var(--border2);
}

body.light .batch-mapper-select:focus {
  border-color: var(--accent);
}

body.light .batch-data-table th {
  background: var(--bg);
  border-color: var(--border2);
}

body.light .batch-data-table td {
  border-color: var(--border2);
}

body.light .batch-summary-item {
  background: var(--bg);
}

body.light .batch-progress-bar {
  background: var(--bg);
}

body.light .batch-results-table th {
  background: var(--bg);
  border-color: var(--border2);
}

body.light .batch-results-table td {
  border-color: var(--border2);
}

/* ── Batch Template Preview ────────────────────────────────── */
.batch-template-select-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.batch-template-select-row .field-input {
  flex: 1;
}

.batch-template-badge .badge {
  font-size: 0.75rem;
}

.batch-template-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 280px;
  overflow-y: auto;
  z-index: var(--z-sidebar);
}

.batch-template-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-dim);
}

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

.batch-template-option:hover {
  background: var(--accent-glow);
  color: var(--text);
}

.batch-template-preview {
  margin-top: var(--space-lg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.batch-template-preview-header {
  padding: var(--space-sm) var(--space-md);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

body.light .batch-template-preview {
  border-color: var(--border2);
}

body.light .batch-template-preview-header {
  background: var(--bg);
  border-color: var(--border2);
}

/* ── Batch Info (non-blocking notice) ─────────────────────── */
.batch-info {
  padding: var(--space-md);
  background: var(--accent-glow);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: var(--space-md);
}

body.light .batch-info {
  background: rgba(99,102,241,0.05);
  border-color: rgba(99,102,241,0.2);
}

/* ── Batch Loop Chips ─────────────────────────────────────── */
.batch-loop-chip {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-xs);
}

.loop-chip {
  background: rgba(168,139,250,0.15);
  color: #a78bfa;
  font-weight: 600;
}

.batch-loop-fields {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.field-chip {
  background: var(--surface2);
  font-size: 0.7rem;
  color: var(--text-dim);
}

body.light .field-chip {
  background: var(--bg);
}

/* ── Mapper optgroup styling ──────────────────────────────── */
.batch-mapper-select optgroup {
  font-weight: 600;
  font-style: normal;
  color: var(--text-dim);
  background: var(--surface2);
}

.batch-mapper-select option {
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
}

body.light .batch-mapper-select optgroup {
  background: var(--bg);
}

body.light .batch-mapper-select option {
  background: var(--bg);
}
