/* ========================================
   DOSSIERS — Design System
   ======================================== */

/* --- Tokens: Light --- */
:root {
  color-scheme: light;
  --bg: #f0f2f7;
  --bg-subtle: #e8ebf2;
  --panel: #ffffff;
  --panel-soft: #f6f8fc;
  --panel-hover: #f0f3fa;
  --text: #111827;
  --text-secondary: #4b5563;
  --muted: #6b7280;
  --line: #e2e5ee;
  --line-soft: #eef0f5;
  --button-bg: #ffffff;
  --input-bg: #ffffff;
  --input-border: #d1d5db;
  --input-focus: #7c5cfc;
  --status-bg: #eef2ff;
  --progress-bg: #e5e7eb;
  --pre-bg: #f8fafc;
  --pre-text: #1e293b;
  --error-bg: #fef2f2;
  --error-line: #fecaca;
  --success-bg: #ecfdf5;
  --success-line: #a7f3d0;
  --primary: #7c5cfc;
  --primary-hover: #6a4ce8;
  --primary-glow: rgba(124, 92, 252, 0.25);
  --primary-text: #ffffff;
  --accent: #4f8cff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --overlay: rgba(0,0,0,0.4);
}

/* --- Tokens: Dark --- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14;
  --bg-subtle: #111620;
  --panel: #151a25;
  --panel-soft: #1a2030;
  --panel-hover: #1e2538;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --muted: #7c8ca3;
  --line: #252d3d;
  --line-soft: #1e2636;
  --button-bg: #1a2030;
  --input-bg: #111620;
  --input-border: #2d3748;
  --input-focus: #7c5cfc;
  --status-bg: #1e1a3a;
  --progress-bg: #1e2636;
  --pre-bg: #0d1117;
  --pre-text: #e2e8f0;
  --error-bg: #2a1515;
  --error-line: #5c2020;
  --success-bg: #0f2419;
  --success-line: #1a5c38;
  --primary: #9b82fc;
  --primary-hover: #b09dff;
  --primary-glow: rgba(155, 130, 252, 0.2);
  --primary-text: #0b0e14;
  --accent: #6aa3ff;
  --danger: #f87171;
  --danger-soft: #2a1515;
  --ok: #34d399;
  --ok-soft: #0f2419;
  --warn: #fbbf24;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.2);
  --overlay: rgba(0,0,0,0.6);
}

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

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: row; /* changed from column */
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ========================================
   Responsive & Defaults
   ======================================== */
.default-template-row {
  background-color: var(--panel-hover);
  border-left: 4px solid var(--primary);
}



a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s;
}

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

h1, h2, h3, p {
  margin-top: 0;
}

h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; font-weight: 700; }

/* ========================================
   Sidebar & Mobile Header
   ======================================== */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem;
  line-height: 0;
  margin-left: -0.5rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 260px;
  min-width: 260px;
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 1.5rem 1rem;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  z-index: 95;
  opacity: 0;
  transition: opacity 0.3s;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 2rem;
  padding: 0 0.5rem;
}

.brand-icon {
  border-radius: 6px;
  flex-shrink: 0;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.actions, .form-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.actions-wrap {
  flex-wrap: wrap;
}

nav a, nav button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.15s;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

nav a:hover, nav button:hover {
  color: var(--text);
  background: var(--panel-hover);
}

nav .button-primary {
  margin-top: 1rem;
  color: var(--primary-text);
  justify-content: center;
}
nav .button-primary:hover {
  color: var(--primary-text);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ========================================
   Page Layout
   ======================================== */
.page {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2rem);
  animation: fadeIn 0.35s ease-out;
}

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

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin-bottom: 0.3rem;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.muted {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ========================================
   Buttons
   ======================================== */
.button, button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.button:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  color: var(--text);
}

.button-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-text);
}

.button-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px var(--primary-glow);
  color: var(--primary-text);
}

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

.button-danger:hover {
  background: var(--danger-soft);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.button-sm {
  min-height: 2rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
}

/* ========================================
   Theme Toggle
   ======================================== */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  min-width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.theme-icon { line-height: 0; }
.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }

/* ========================================
   Panels
   ======================================== */
.panel {
  margin-bottom: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s;
}

/* ========================================
   Cards (Dashboard)
   ======================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  animation: cardIn 0.4s ease-out both;
}

.card:hover {
  border-color: var(--primary);
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
  color: inherit;
}

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

.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.16s; }
.card:nth-child(6) { animation-delay: 0.20s; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.15rem 0 0;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.82rem;
  color: var(--muted);
}

.card-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* ========================================
   Status Badges
   ======================================== */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.6rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-uploaded,
.status-queued {
  background: var(--status-bg);
  color: var(--primary);
}

.status-extracting_audio,
.status-splitting_audio,
.status-transcribing,
.status-reviewing_transcript,
.status-importing_transcript,
.status-cleaning_transcript,
.status-summarizing,
.status-generating_dossier {
  background: var(--status-bg);
  color: var(--primary);
}

.status-completed {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Processing spinner dot */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.status-completed .status-dot { animation: none; }
.status-failed .status-dot { animation: none; }

/* ========================================
   Stepper (Process Steps)
   ======================================== */
.stepper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin: 1.25rem 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
}

.stepper-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 80px;
  text-align: center;
}

.stepper-step::before {
  content: "";
  position: absolute;
  top: 13px;
  left: -50%;
  right: 50%;
  height: 2px;
  background: var(--line);
  transition: background 0.3s;
}

.stepper-step:first-child::before {
  display: none;
}

.stepper-step.done::before { background: var(--ok); }
.stepper-step.active::before { background: var(--primary); }

.stepper-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transition: all 0.3s;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
}

.stepper-step.done .stepper-dot {
  border-color: var(--ok);
  background: var(--ok);
  color: white;
}

.stepper-step.active .stepper-dot {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 0 0 4px var(--primary-glow);
  animation: stepperPulse 2s ease-in-out infinite;
}

@keyframes stepperPulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--primary-glow); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

.stepper-step.failed .stepper-dot {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

.stepper-label {
  margin-top: 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.2;
}

.stepper-step.done .stepper-label { color: var(--ok); }
.stepper-step.active .stepper-label { color: var(--primary); font-weight: 700; }
.stepper-step.failed .stepper-label { color: var(--danger); }

/* ========================================
   Progress Bar
   ======================================== */
.progress {
  height: 6px;
  margin: 1rem 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--progress-bg);
}

.progress div {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Meta Grid
   ======================================== */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.meta-grid div {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
}

.meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.meta-grid strong {
  font-size: 0.92rem;
  font-weight: 600;
}

/* ========================================
   Status Header
   ======================================== */
.status-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

/* ========================================
   Logs
   ======================================== */
.logs-toggle summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  list-style: none;
}

.logs-toggle summary::-webkit-details-marker {
  display: none;
}

.logs-toggle summary::after {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.logs-toggle[open] summary::after {
  content: "-";
}

.logs-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 800;
}

.logs-summary {
  flex: 1;
  color: var(--muted);
  font-size: 0.86rem;
}

.logs-body {
  margin-top: 1rem;
}

.logs {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.logs li {
  display: grid;
  grid-template-columns: 5rem 4rem 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 0.88rem;
  transition: background 0.15s;
}

.logs li:hover {
  background: var(--panel-hover);
}

.logs p { margin: 0; }

.logs time, .logs > li > span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.log-error {
  border-color: var(--error-line) !important;
  background: var(--error-bg) !important;
}

.log-error span {
  color: var(--danger) !important;
  font-weight: 700 !important;
}

/* ========================================
   Forms
   ======================================== */
.form {
  display: grid;
  gap: 1.25rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

label span {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.source-mode-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.source-mode-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
}

.source-mode-option input {
  width: auto;
  min-height: auto;
}

.source-mode-option span {
  margin: 0;
}

.source-fields[hidden] {
  display: none;
}

.transcript-file-list {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.transcript-file-item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto auto auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.transcript-file-index {
  display: inline-grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  background: var(--status-bg);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
}

.transcript-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.transcript-file-size {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.icon-button-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.cost-estimate {
  display: grid;
  gap: 0.15rem;
  margin-top: 0.65rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.cost-estimate-label,
.cost-estimate-detail {
  color: var(--muted);
  font-size: 0.78rem;
}

.cost-estimate strong {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.3;
}

/* --- Drag & Drop Zone --- */
.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 160px;
  padding: 2rem;
  border: 2px dashed var(--input-border);
  border-radius: 12px;
  background: var(--panel-soft);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--status-bg);
}

.drop-zone.dragover {
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.drop-zone-icon {
  color: var(--muted);
  transition: color 0.2s, transform 0.2s;
}

.drop-zone:hover .drop-zone-icon,
.drop-zone.dragover .drop-zone-icon {
  color: var(--primary);
  transform: translateY(-2px);
}

.drop-zone-text {
  font-size: 0.92rem;
  color: var(--muted);
}

.drop-zone-text strong {
  color: var(--primary);
}

.drop-zone-hint {
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.7;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-preview {
  display: none;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  font-size: 0.88rem;
}

.file-preview.visible {
  display: flex;
}

.file-preview-name {
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-size {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.file-preview-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem;
  line-height: 0;
  transition: color 0.15s;
}

.file-preview-remove:hover {
  color: var(--danger);
}

/* --- Upload overlay --- */
.upload-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.upload-overlay.visible {
  display: flex;
}

.upload-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 3rem;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  text-align: center;
  width: min(460px, 90vw);
}

.upload-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.upload-progress-value {
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
}

.upload-progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--progress-bg);
}

.upload-progress div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.2s ease;
}

.upload-error-box {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--error-line);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 600;
}

.upload-error-box[hidden] {
  display: none;
}

/* ========================================
   Flash Messages
   ======================================== */
.flash {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideDown 0.3s ease-out;
}

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

.flash-error {
  border: 1px solid var(--error-line);
  background: var(--error-bg);
  color: var(--danger);
}

.flash-success {
  border: 1px solid var(--success-line);
  background: var(--success-bg);
  color: var(--ok);
}

/* ========================================
   Error Box
   ======================================== */
.error-box {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--error-line);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--danger);
  font-size: 0.88rem;
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 2rem;
  text-align: center;
}

.empty-state-icon {
  color: var(--muted);
  opacity: 0.4;
  margin-bottom: 1rem;
}

.empty-state h2 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
}

.empty-state p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
  max-width: 360px;
}

/* ========================================
   Output / Results
   ======================================== */
.result-grid {
  display: grid;
  gap: 1rem;
}

.result-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}

.result-tab {
  padding: 0.55rem 1rem;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

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

.result-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.result-content {
  display: none;
}

.result-content.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

.rendered-markdown {
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  line-height: 1.7;
}

.rendered-markdown h1 { font-size: 1.5rem; margin-top: 1.5rem; }
.rendered-markdown h2 { font-size: 1.2rem; margin-top: 1.25rem; border-bottom: 1px solid var(--line-soft); padding-bottom: 0.4rem; }
.rendered-markdown h3 { font-size: 1.05rem; margin-top: 1rem; }
.rendered-markdown h1:first-child,
.rendered-markdown h2:first-child,
.rendered-markdown h3:first-child { margin-top: 0; }
.rendered-markdown ul, .rendered-markdown ol { padding-left: 1.5rem; }
.rendered-markdown li { margin-bottom: 0.3rem; }
.rendered-markdown blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--primary);
  background: var(--bg-subtle);
  border-radius: 0 6px 6px 0;
}
.rendered-markdown strong { font-weight: 700; }

pre {
  overflow-x: auto;
  white-space: pre-wrap;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--pre-bg);
  color: var(--pre-text);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
}

.markdown-toggle {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.markdown-toggle button {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.markdown-toggle button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.result-help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.result-help-grid article {
  min-width: 0;
  padding: 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
}

.result-help-grid strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.88rem;
}

.result-help-grid p,
.regeneration-help p,
.tab-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.tab-help {
  margin-bottom: 0.85rem;
}

.regeneration-bar,
.download-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.25rem;
  padding: 0.85rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
}

.regeneration-help {
  flex: 1 1 260px;
  min-width: 220px;
}

.regeneration-help strong {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.9rem;
}

.download-strip > div:first-child {
  flex: 1;
  min-width: 220px;
}

.download-strip h3 {
  margin-bottom: 0.15rem;
  font-size: 0.95rem;
}

.download-strip p {
  margin: 0;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.inline-check input {
  width: auto;
  min-height: auto;
}

.review-form {
  display: grid;
  gap: 1rem;
}

.review-form textarea[name="reviewed_transcript"] {
  min-height: 420px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
}

.variant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.variant-block {
  min-width: 0;
}

.variant-block h3 {
  margin-bottom: 0.5rem;
}

.variant-block ol {
  margin: 0;
  padding-left: 1.25rem;
}

.variant-block li {
  margin-bottom: 0.65rem;
}

.linkedin-post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1rem;
}

.linkedin-post-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
}

.linkedin-post-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.85rem;
}

.linkedin-avatar {
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: #0a66c2;
  color: #ffffff;
  font-weight: 800;
  flex: 0 0 auto;
}

.linkedin-post-header strong,
.linkedin-post-header span {
  display: block;
}

.linkedin-post-header span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.linkedin-post-text {
  margin-bottom: 0.85rem;
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.6;
}

.linkedin-post-stats {
  padding: 0.55rem 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.78rem;
}

.linkedin-post-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.linkedin-post-actions span {
  padding: 0.4rem 0.25rem;
  border-radius: 6px;
}

.empty-state.compact {
  padding: 2rem 1rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
}

@media (max-width: 980px) {
  .result-help-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

.quality-grid {
  margin-bottom: 1rem;
}

.quality-sections {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.quality-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.quality-chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.quality-chip-missing {
  background: var(--danger-soft);
  color: var(--danger);
}

.quality-review {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.quality-review-aprobado {
  border-color: var(--success-line);
}

.quality-review-revisar,
.quality-review-critico {
  border-color: var(--error-line);
  background: var(--error-bg);
}

.quality-review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.quality-review-header h3 {
  margin-bottom: 0;
}

.quality-review-counts {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quality-review-counts span {
  display: inline-flex;
  min-height: 1.7rem;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.quality-review-summary {
  margin: 0;
}

.quality-issue-list {
  display: grid;
  gap: 0.65rem;
}

.quality-issue {
  display: grid;
  gap: 0.35rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.quality-issue strong {
  display: block;
}

.quality-issue span {
  justify-self: start;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--status-bg);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
}

.quality-issue p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

/* ========================================
   Table (fallback)
   ======================================== */
.table-wrap { overflow-x: auto; }

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

th, td {
  padding: 0.8rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ========================================
   Delete Confirmation
   ======================================== */
.confirm-dialog {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.confirm-dialog.visible {
  display: flex;
}

.confirm-dialog-content {
  padding: 2rem;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

#regenerate-dialog .confirm-dialog-content {
  max-width: 480px;
}

.confirm-dialog-content h3 {
  margin-bottom: 0.5rem;
}

.confirm-dialog-content p {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}

.confirm-dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* ========================================
   Footer
   ======================================== */
.site-footer {
  padding: 1.5rem clamp(1rem, 4vw, 2rem);
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 760px) {
  .page-header,
  .status-header,
  .topbar {
    flex-direction: column;
  }

  .form-grid,
  .source-mode-group,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .transcript-file-item {
    grid-template-columns: 2rem minmax(0, 1fr) auto auto auto;
  }

  .transcript-file-size {
    display: none;
  }

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

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

  .result-help-grid {
    grid-template-columns: 1fr;
  }

  .logs-toggle summary {
    align-items: flex-start;
  }

  .logs li {
    grid-template-columns: 1fr;
  }

  .stepper {
    gap: 0;
  }

  .stepper-step {
    min-width: 60px;
  }

  .stepper-label {
    font-size: 0.6rem;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column !important;
  }
  
  .sidebar {
    position: fixed !important;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--card-shadow-hover);
    height: 100vh !important;
    z-index: 1000 !important;
  }

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

  .sidebar-overlay.open {
    display: block !important;
    opacity: 1 !important;
  }
  
  .mobile-header {
    display: flex !important;
  }

  .page-header,
  .status-header {
    flex-direction: column;
  }

  .form-grid,
  .source-mode-group,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .transcript-file-item {
    grid-template-columns: 2rem minmax(0, 1fr) auto auto auto;
  }

  .transcript-file-size {
    display: none;
  }

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

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

  .result-help-grid {
    grid-template-columns: 1fr;
  }

  .logs-toggle summary {
    align-items: flex-start;
  }

  .logs li {
    grid-template-columns: 1fr;
  }

  .stepper {
    gap: 0;
  }

  .stepper-step {
    min-width: 60px;
  }

  .stepper-label {
    font-size: 0.6rem;
  }
}
