/* ═══════════════════════════════════════════════════════════
   1600. — Admin Back Office — Premium Dark Mode v2
   ═══════════════════════════════════════════════════════════ */

/* ─── Design tokens ──────────────────────────────────────── */
:root {
  --bg-primary:    #09090b;
  --bg-secondary:  rgba(255,255,255,0.03);
  --bg-card:       rgba(255,255,255,0.03);
  --bg-input:      rgba(255,255,255,0.04);
  --border:        rgba(255,255,255,0.06);
  --border-focus:  #ff652d;
  --text-primary:  #fafafa;
  --text-secondary:#a1a1aa;
  --text-muted:    #52525b;
  --accent:        #ff652d;
  --accent-secondary: #ff8a5c;
  --error:         #ef4444;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --radius:        16px;
  --radius-sm:     10px;
  --transition:    0.2s ease;
}

/* ─── Light mode ────────────────────────────────────────── */
[data-theme="light"] {
  --bg-primary:    #f8f8fa;
  --bg-secondary:  rgba(0,0,0,0.02);
  --bg-card:       #ffffff;
  --bg-input:      #f1f1f4;
  --border:        #e4e4e7;
  --border-focus:  #ff652d;
  --text-primary:  #18181b;
  --text-secondary:#52525b;
  --text-muted:    #a1a1aa;
  --accent:        #ff652d;
  --accent-secondary: #e8501a;
  --error:         #dc2626;
  --success:       #16a34a;
  --warning:       #d97706;
}

[data-theme="light"] body {
  background-image: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255,101,45,0.06), transparent);
}

[data-theme="light"] .sidebar {
  background: #ffffff;
  border-right-color: #e4e4e7;
}

[data-theme="light"] .sidebar-link.active {
  background: rgba(255,101,45,0.08);
}

[data-theme="light"] .modal {
  background: rgba(0,0,0,0.3);
}

[data-theme="light"] .modal-content {
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(0,0,0,0.15);
}

[data-theme="light"] .scriptgen-actions {
  background: rgba(248,248,250,0.95);
}

[data-theme="light"] .toast {
  background: #ffffff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

[data-theme="light"] .badge::before { opacity: 0.8; }

[data-theme="light"] .script-preview-text,
[data-theme="light"] .block-content,
[data-theme="light"] .streaming-output {
  color: #27272a;
}

[data-theme="light"] .prompt-preview {
  background: #f1f1f4;
  color: #52525b;
}

[data-theme="light"] ::-webkit-scrollbar-track { background: #f8f8fa; }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d4d4d8; }

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(255,101,45,0.12), transparent),
    radial-gradient(ellipse 50% 80% at 80% 100%, rgba(59,130,246,0.06), transparent);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Utility ─────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ─── Login View ─────────────────────────────────────────── */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 60% 40% at 50% 40%, rgba(255,101,45,0.15), transparent),
    radial-gradient(ellipse 50% 80% at 80% 100%, rgba(59,130,246,0.06), transparent);
}

.login-container {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 0 120px rgba(255,101,45,0.15), 0 32px 64px rgba(0,0,0,0.5);
  animation: loginFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-container .logo {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-align: center;
}

.login-container h2 {
  text-align: center;
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 1rem;
  margin-top: -1rem;
}

.login-container form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.error-msg {
  color: var(--error);
  font-size: 0.875rem;
  text-align: center;
  padding: 0.5rem;
  background: rgba(239, 68, 68, 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: rgba(9, 9, 11, 0.95);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  z-index: 100;
  padding: 1.5rem 0;
}

.sidebar-logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  padding: 0 1.5rem;
  margin-bottom: 2rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.625rem 0.875rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
}

.sidebar-link svg {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition);
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.sidebar-link:hover svg {
  opacity: 1;
}

.sidebar-link.active {
  color: var(--accent);
  background: rgba(255,101,45,0.1);
}

.sidebar-link.active svg {
  opacity: 1;
  color: var(--accent);
}

.sidebar-bottom {
  padding: 0 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

/* ─── Main Content (offset by sidebar) ────────────────────── */
.main-content {
  margin-left: 240px;
  min-height: 100vh;
}

.logo {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1;
}

/* ─── Main Layout ─────────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 2.5rem;
}

/* ─── AI Settings Grid ────────────────────────────────────── */
.ai-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 0;
}

.ai-settings-left {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.ai-settings-right {
  display: flex;
  flex-direction: column;
}

.prompt-preview-section {
  height: 100%;
}

.prompt-preview {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 420px;
}

.prompt-variables {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.prompt-var {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  background: rgba(255,101,45,0.1);
  color: var(--accent);
  border: 1px dashed rgba(255,101,45,0.3);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', monospace;
  cursor: grab;
  transition: all var(--transition);
  user-select: none;
}

.prompt-var:hover {
  background: rgba(255,101,45,0.18);
  border-color: var(--accent);
}

.prompt-var:active { cursor: grabbing; }

[data-theme="light"] .prompt-var { background: rgba(255,101,45,0.08); }

.prompt-editor-textarea {
  font-family: 'SF Mono', 'Fira Code', monospace !important;
  font-size: 0.8rem !important;
  line-height: 1.7 !important;
  min-height: 350px !important;
  white-space: pre-wrap;
}

.prompt-editor-section { height: 100%; display: flex; flex-direction: column; }
.prompt-editor-section .prompt-editor-textarea { flex: 1; }

#ai-settings-view code {
  background: rgba(255,101,45,0.12);
  color: var(--accent);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* ─── Views ──────────────────────────────────────────────── */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* Login view always uses flex */
#login-view {
  display: flex;
}

#login-view.hidden {
  display: none !important;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

/* ─── Stats Grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid transparent;
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 60px rgba(255,101,45,0.06);
}

.stat-pending  { border-image: linear-gradient(90deg, #f59e0b, #fb923c) 1; border-image-slice: 1; border-top-width: 3px; border-top-style: solid; }
.stat-completed { border-image: linear-gradient(90deg, #22c55e, #4ade80) 1; border-image-slice: 1; border-top-width: 3px; border-top-style: solid; }
.stat-scripted  { border-image: linear-gradient(90deg, #ff652d, #ff8a5c) 1; border-image-slice: 1; border-top-width: 3px; border-top-style: solid; }

.stat-value {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.5rem;
}

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

.stat-pending .stat-value  { color: var(--warning); }
.stat-completed .stat-value { color: var(--success); }
.stat-scripted .stat-value  { color: var(--accent); }

/* ─── View Header ─────────────────────────────────────────── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.view-header h1 {
  margin-bottom: 0;
}

/* ─── Search Bar ─────────────────────────────────────────── */
.search-bar {
  margin-bottom: 1rem;
}

.search-bar input {
  width: 100%;
  max-width: 400px;
}

/* ─── Data Table ─────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table thead {
  background: rgba(255,255,255,0.02);
}

.data-table th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.data-table tbody tr {
  transition: background var(--transition);
  cursor: default;
}

.data-table tbody tr:hover {
  background: rgba(167, 139, 250, 0.04);
}

.actions {
  display: flex;
  gap: 0.5rem;
}

/* ─── Status Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: none;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

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

.badge-accent {
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, #ff652d, #ff8a5c);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(255,101,45,0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

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

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.btn-secondary:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.04);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}

.btn-sm:hover {
  border-color: rgba(255,255,255,0.15);
  color: var(--text-primary);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  cursor: pointer;
  transition: color var(--transition);
  margin-bottom: 1.5rem;
}

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

.btn-generate {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.btn-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}

.btn-close:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

/* ─── Form Elements ──────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2352525b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: rgba(255,101,45,0.04);
  box-shadow: 0 0 0 3px rgba(255,101,45,0.15), 0 0 20px rgba(255,101,45,0.08);
}

input[readonly] {
  color: var(--text-secondary);
  cursor: default;
}

/* ─── Radio Group ─────────────────────────────────────────── */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: border-color var(--transition), background var(--transition);
}

.radio-option:hover {
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
}

.radio-option input[type="radio"] {
  width: auto;
  padding: 0;
  accent-color: var(--accent);
}

.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: rgba(255,101,45,0.08);
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  box-shadow: 0 0 80px rgba(255,101,45,0.12), 0 24px 80px rgba(0, 0, 0, 0.5);
}

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

.modal-large {
  max-width: 720px;
}

.modal-content h2 {
  color: var(--text-primary);
  margin-bottom: 0;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ─── Copy Link ──────────────────────────────────────────── */
.copy-link {
  display: flex;
  gap: 0.5rem;
}

.copy-link input {
  flex: 1;
  font-size: 0.8rem;
}

.copy-link button {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}

.copy-link button:hover {
  background: rgba(255,255,255,0.1);
}

#form-link-result {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(34, 197, 94, 0.05);
  border: 1px solid rgba(34, 197, 94, 0.15);
  border-radius: var(--radius-sm);
}

#form-link-result label {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
}

/* ─── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  margin-bottom: 0;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}

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

.tab.active {
  color: var(--text-primary);
  border-image: linear-gradient(90deg, var(--accent), var(--accent-secondary)) 1;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1rem;
}

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

/* ─── AI Output ──────────────────────────────────────────── */
.ai-output {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  min-height: 80px;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

/* ─── Streaming cursor ───────────────────────────────────── */
.streaming-output.is-streaming::after {
  content: '▋';
  display: inline-block;
  animation: cursorBlink 0.8s step-end infinite;
  color: var(--accent);
  margin-left: 1px;
}

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

/* ─── Script Generator v2 ─────────────────────────────────── */
.scriptgen-header {
  margin-bottom: 1.5rem;
}

.scriptgen-header h1 {
  margin-bottom: 0;
}

/* Controls bar (horizontal) */
.scriptgen-controls {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.scriptgen-control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.scriptgen-control-group label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.scriptgen-instructions-group {
  flex: 1;
  min-width: 180px;
}

.scriptgen-instructions-group input {
  font-size: 0.8rem;
}

/* Duration pills */
.scriptgen-duration-pills {
  display: flex;
  gap: 0.25rem;
}

.pill-option {
  cursor: pointer;
  display: block;
}

.pill-option input { display: none; }

.pill-option span {
  display: block;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.pill-option span:hover {
  color: var(--text-secondary);
  border-color: rgba(255,255,255,0.12);
}

.pill-option input:checked + span {
  color: var(--accent);
  background: rgba(255,101,45,0.12);
  border-color: rgba(255,101,45,0.3);
}

/* Toolbar (versions dropdown + stats) */
.scriptgen-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.scriptgen-toolbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.scriptgen-toolbar-right {
  display: flex;
  gap: 0.5rem;
}

.scriptgen-version-select select {
  width: auto;
  min-width: 280px;
  font-size: 0.8rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
}

.scriptgen-stats {
  display: flex;
  gap: 0.5rem;
}

.stat-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

/* Script body (full width, supports compare side-by-side) */
.scriptgen-body {
  display: flex;
  gap: 1rem;
  margin-bottom: 5rem;
}

.scriptgen-body .script-content {
  flex: 1;
}

.scriptgen-body.compare-mode .script-content {
  flex: 1;
}

.script-compare {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.compare-header + .script-content {
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.compare-block {
  opacity: 0.7;
}

.compare-block .block-content {
  font-size: 0.85rem;
}

/* Block feedback buttons (+/-) */
.block-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.block-feedback-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--transition);
}

.script-block:hover .block-feedback-btn {
  opacity: 1;
}

.block-feedback-btn:hover {
  color: #fff;
  border-color: var(--accent);
  background: rgba(255,101,45,0.2);
  transform: scale(1.1);
}

/* Fixed bottom actions bar */
.scriptgen-actions {
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  background: rgba(9, 9, 11, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 50;
}

.scriptgen-actions-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2.5rem;
}

.scriptgen-actions-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.actions-separator {
  color: var(--border);
}

.scriptgen-actions-right {
  display: flex;
  gap: 0.5rem;
}

.block-header-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Legacy compat */
.script-gen-layout { display: none; }

/* ─── Script Content ─────────────────────────────────────── */
.script-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 3rem 1rem;
  font-size: 0.9rem;
}

.streaming-output {
  white-space: pre-wrap;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-secondary);
  font-family: Georgia, 'Times New Roman', serif;
  overflow-y: auto;
  max-height: 500px;
}

/* ─── Script Blocks ──────────────────────────────────────── */
.script-block {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(255,101,45,0.2);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  cursor: default;
  transition: border-color var(--transition), background var(--transition);
}

.script-block:hover {
  border-color: rgba(255,255,255,0.1);
  border-left-color: rgba(255,101,45,0.5);
  background: rgba(255,255,255,0.03);
}

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.block-header h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.btn-edit-block {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition);
}

.script-block:hover .btn-edit-block {
  opacity: 1;
}

.btn-edit-block:hover {
  background: rgba(255,101,45,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.block-content {
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--text-primary);
  font-family: Georgia, 'Times New Roman', serif;
}

/* ─── Script Actions ─────────────────────────────────────── */
.script-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ─── Client Detail v2 ───────────────────────────────────── */
.client-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.client-name { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.35rem; letter-spacing: -0.02em; }

.client-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.client-meta-item {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.client-meta-item:first-of-type { border: none; padding-left: 0; }

.client-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.btn-danger { color: var(--error) !important; border-color: rgba(239,68,68,0.3) !important; }
.btn-danger:hover { background: rgba(239,68,68,0.08) !important; }

.btn-accent { background: rgba(255,101,45,0.12); color: var(--accent); border-color: rgba(255,101,45,0.3); }

/* Status cards */
.client-status-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.status-done .status-dot { background: var(--success); box-shadow: 0 0 8px rgba(34,197,94,0.3); }
.status-progress .status-dot { background: var(--warning); box-shadow: 0 0 8px rgba(245,158,11,0.3); }
.status-empty .status-dot { background: var(--text-muted); opacity: 0.4; }

.status-card-value { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.status-card-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Brief sections */
.brief-section {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.brief-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

.brief-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.brief-body { padding: 1rem 1.25rem; }

.brief-row {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

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

.brief-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 120px;
  flex-shrink: 0;
  padding-top: 0.2rem;
}

.brief-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.5;
  flex: 1;
}

.brief-chip {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.brief-chip:last-child { margin-bottom: 0; }

.brief-chip-num {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.5;
  padding-top: 0.1rem;
}

.brief-chip-content { flex: 1; }

.brief-chip-line {
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.1rem 0;
}

.brief-chip-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  min-width: 70px;
  flex-shrink: 0;
  padding-top: 0.15rem;
}

.brief-tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0.15rem 0.25rem 0.15rem 0;
}

/* Brief sub-tabs */
.brief-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-bottom: 0;
  padding-bottom: 0;
}

.brief-tab {
  background: transparent;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.brief-tab:hover {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
}

.brief-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}

[data-theme="light"] .brief-tab.active {
  background: #ffffff;
}

.brief-panel {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
  margin-bottom: 0;
}

.brief-panel.active {
  display: block;
}

.brief-value-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.brief-value-wrap .brief-value { flex: 1; }

.brief-edit-btn {
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
  font-size: 0.7rem !important;
  padding: 0.2rem 0.5rem !important;
}

.brief-row:hover .brief-edit-btn {
  opacity: 1;
}

.brief-videos {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* Video ref rows */
.video-ref-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  flex-wrap: wrap;
}

.video-ref-link {
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
  word-break: break-all;
  flex: 1;
  min-width: 200px;
}

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

.video-ref-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.video-ref-status.done { color: var(--success); background: rgba(34,197,94,0.08); }
.video-ref-status.failed { color: var(--error); background: rgba(239,68,68,0.08); }
.video-ref-status.pending { color: var(--text-muted); }

.video-transcript-expanded {
  width: 100%;
  margin-top: 0.5rem;
  padding: 1rem;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
  font-family: Georgia, serif;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Analyse tab */
.analyse-url-bar {
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.analyse-url-bar a { color: var(--accent); font-size: 0.85rem; text-decoration: none; }
.analyse-url-bar a:hover { text-decoration: underline; }

.analyse-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.analyse-highlight {
  padding: 1rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.analyse-highlight-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.analyse-highlight-value { font-size: 0.9rem; color: var(--text-primary); line-height: 1.4; }

.analyse-section {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.analyse-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.analyse-section-content { font-size: 0.875rem; color: var(--text-primary); line-height: 1.5; }

/* Script preview cards */
.script-preview-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}

.script-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.script-preview-meta { font-size: 0.85rem; color: var(--text-secondary); }
.script-preview-actions { display: flex; gap: 0.5rem; }

.script-preview-body { padding: 1.25rem; }

.script-preview-block { margin-bottom: 1rem; }
.script-preview-block:last-child { margin-bottom: 0; }

.script-preview-label {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  opacity: 0.6;
  margin-bottom: 0.25rem;
}

.script-preview-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-primary);
  font-family: Georgia, serif;
  margin: 0;
}

/* Legacy compat */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 2rem; gap: 1rem; }
.detail-header h1 { margin-bottom: 0.5rem; }
.detail-actions { display: flex; gap: 0.75rem; flex-shrink: 0; }

.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.detail-section h2 {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.info-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

/* ─── Analysis Grid ──────────────────────────────────────── */
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.75rem;
}

.analysis-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.analysis-item span:last-child {
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* ─── Response Cards ─────────────────────────────────────── */
.response-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.response-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.response-card h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.response-card pre {
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  line-height: 1.6;
}

/* ─── Response Content (clean key-value) ─────────────────── */
.response-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.response-row {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

.response-key {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 110px;
  flex-shrink: 0;
  padding-top: 0.15rem;
}

.response-val {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.response-val ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.response-val ul li {
  padding: 0.2rem 0 0.2rem 0.875rem;
  position: relative;
}

.response-val ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

.nested-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.nested-card:last-child {
  margin-bottom: 0;
}

.nested-line {
  display: flex;
  gap: 0.75rem;
  padding: 0.15rem 0;
  font-size: 0.85rem;
}

.nested-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  min-width: 80px;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

/* ─── Detail Tabs spacing ────────────────────────────────── */
.detail-tabs {
  margin-bottom: 0;
  margin-top: 1.5rem;
}

.detail-tabs + .tab-content {
  padding-top: 1.5rem;
}

/* ─── Video Refs ─────────────────────────────────────────── */
.video-refs {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.video-refs h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.video-refs a {
  display: block;
  color: var(--accent);
  font-size: 0.8rem;
  text-decoration: none;
  transition: color var(--transition);
}

.video-refs a:hover {
  color: var(--accent-secondary);
  text-decoration: underline;
}

/* ─── Uploads Grid ───────────────────────────────────────── */
.uploads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.upload-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.upload-item img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
}

.upload-item span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.file-icon {
  font-size: 2rem;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Script Cards (version list in detail) ──────────────── */
.script-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.script-card:hover {
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,101,45,0.04);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.script-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
}

.script-card-header span:first-child {
  font-weight: 500;
}

.script-card-header span:last-child {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ─── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.toast-success {
  border-color: rgba(34, 197, 94, 0.2);
  background: rgba(34, 197, 94, 0.06);
}

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

.toast-error {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.06);
}

.toast-error::before {
  background: var(--error);
}

.toast-info {
  border-color: rgba(255, 255, 255, 0.1);
}

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

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

/* ─── Footer ─────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

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

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

/* ─── Responsive ─────────────────────────────────────────── */

/* Below 1024px: script layout + AI settings stack vertically */
@media (max-width: 1024px) {
  .scriptgen-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .scriptgen-body {
    flex-direction: column;
  }

  .scriptgen-version-select select {
    min-width: auto;
    width: 100%;
  }

  .ai-settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Below 768px: sidebar collapses, stats stack */
@media (max-width: 768px) {
  .sidebar {
    width: 64px;
    padding: 1rem 0;
  }

  .sidebar-logo {
    font-size: 1.2rem;
    text-align: center;
    padding: 0;
    margin-bottom: 1.5rem;
  }

  .sidebar-link {
    justify-content: center;
    padding: 0.75rem;
    font-size: 0;
  }

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

  .main-content {
    margin-left: 64px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .scriptgen-actions {
    left: 64px;
  }
}

@media (max-width: 640px) {
  main {
    padding: 1rem;
  }

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

  .detail-header {
    flex-direction: column;
  }

  .detail-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .data-table {
    font-size: 0.8rem;
    min-width: 560px; /* enforce scroll on narrow viewports */
  }

  .data-table th,
  .data-table td {
    padding: 0.625rem 0.75rem;
  }

  .modal-content {
    padding: 1.25rem;
    max-width: 90vw;
  }

  nav {
    gap: 0;
  }

  .nav-link {
    padding: 0.5rem 0.625rem;
    font-size: 0.8rem;
  }
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(255,101,45,0.3);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255,101,45,0.5);
}

/* ─── Focus-visible ─────────────────────────────────────── */
:focus-visible {
  outline: 2px solid rgba(255,101,45,0.5);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255,101,45,0.15);
}

button:focus-visible {
  outline: 2px solid rgba(255,101,45,0.5);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255,101,45,0.15);
}

/* ─── Hover lift on interactive cards ────────────────────── */
.detail-section {
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.detail-section:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 40px rgba(255,101,45,0.04);
}

.script-card {
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.script-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ─── Button unification ────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-sm {
  border-radius: var(--radius-sm);
}

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

/* ─── Skeleton loading ──────────────────────────────────── */
.skeleton {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,101,45,0.04), transparent);
  animation: shimmer 1.5s ease infinite;
}

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

.skeleton-stat {
  height: 100px;
}

.skeleton-row {
  height: 56px;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

/* ─── Key-value grid (client detail responses) ──────────── */
.kv-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  align-items: baseline;
}

.kv-key {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.kv-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.kv-value ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.kv-value ul li {
  padding: 0.15rem 0;
  position: relative;
  padding-left: 0.875rem;
}

.kv-value ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* ─── AI Settings ───────────────────────────────────────── */
#ai-settings-view textarea {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  min-height: 120px;
  background: rgba(255,255,255,0.03);
}

#ai-settings-view code {
  background: rgba(255,255,255,0.06);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--accent);
}

/* ─── Reference Script Cards ────────────────────────────── */
.ref-script-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition), border-left-color var(--transition);
}

.ref-script-card:hover {
  border-color: rgba(255,255,255,0.1);
  border-left-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.ref-script-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ref-script-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.ref-script-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.ref-script-card-preview {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-muted);
  font-family: Georgia, 'Times New Roman', serif;
  margin-bottom: 0.75rem;
  max-height: 3.2em;
  overflow: hidden;
}

.ref-script-card-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

#ref-script-modal textarea {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.875rem;
  line-height: 1.7;
}

/* ─── Print (PDF export) ─────────────────────────────────── */
@media print {
  header, nav, .sidebar, .controls, .block-actions, footer,
  .script-controls, .script-versions, .script-actions,
  .btn-back, .btn-edit-block, #toast-container { display: none !important; }
  .script-content { color: #000; background: #fff; padding: 2rem; }
  .script-block { border: none; margin-bottom: 1rem; background: #fff; }
  .block-header h3 { color: #000; }
  .block-content { color: #333; }
  body { background: #fff; }
}
