/* ============================================================
   ZFlow Design System — Inter + blue palette
   ============================================================ */

:root {
  /* Superficie */
  --bg: #f8faff;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --panel-3: #f1f5f9;

  /* Bordes */
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* Texto */
  --text: #0f172a;
  --muted: #475569;
  --soft: #94a3b8;

  /* Color primario: azul profundo */
  --primary: #1e40af;
  --primary-2: #1e3a8a;
  --primary-light: #eff6ff;
  --primary-mid: #dbeafe;

  /* Semánticos */
  --success: #059669;
  --success-dim: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.1);
  --warning: #d97706;
  --warning-dim: rgba(217, 119, 6, 0.12);
  --accent: #3b82f6;
  --accent-dim: rgba(59, 130, 246, 0.12);

  /* Layout */
  --radius: 8px;
  --radius-sm: 5px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.1), 0 4px 8px rgba(15, 23, 42, 0.06);

  /* Tipografía */
  --ff: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --ff-display: "Space Grotesk", "Inter", ui-sans-serif, system-ui, sans-serif;
  --ff-mono: "DM Mono", ui-monospace, monospace;
  --ff-cond: "Space Grotesk", "Inter", sans-serif;

  /* Aliases legacy (compatibilidad con código existente) */
  --paper: var(--bg);
  --paper2: var(--bg-soft);
  --paper3: var(--panel-3);
  --ink: var(--text);
  --ink2: #1e293b;
  --ink3: var(--muted);
  --ink4: var(--soft);
  --rule: var(--line);
  --rule2: var(--line-strong);
  --press: var(--primary);
  --press-dim: var(--primary-light);
  --green: var(--success);
  --green-dim: var(--success-dim);
  --amber: var(--warning);
  --amber-dim: var(--warning-dim);
  --blue: #1e40af;
  --blue-dim: rgba(30, 64, 175, 0.1);

  font-family: var(--ff);
  font-size: 13px;
}

/* ============================================================
   Reset & base
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff);
  font-size: 13px;
  line-height: 1.5;
  animation: zfFadeIn 0.2s ease both;
}

body[data-route="landing"],
body[data-route="login"] {
  background: #ffffff;
}

@keyframes zfFadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

button,
input,
select,
textarea {
  font: inherit;
}

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

h1 {
  font-family: var(--ff-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

h2 {
  font-family: var(--ff-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

h3 {
  font-family: var(--ff-display);
  font-size: 13px;
  font-weight: 600;
}

/* ============================================================
   Typography utilities
   ============================================================ */

.eyebrow {
  color: var(--muted);
  font-family: var(--ff-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0;
}

/* ============================================================
   Page routing
   ============================================================ */

.page {
  display: none;
  min-height: 100vh;
}

.page.active {
  display: block;
}

body[data-route='landing'] .page-landing,
body[data-route='login'] .page-login,
body[data-route='app'] .page-app {
  display: block;
}

body[data-route='landing'] .page-login,
body[data-route='landing'] .page-app,
body[data-route='login'] .page-landing,
body[data-route='login'] .page-app,
body[data-route='app'] .page-landing,
body[data-route='app'] .page-login {
  display: none;
}

/* ============================================================
   Buttons
   ============================================================ */

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--ff);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}

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

.button.primary:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.3);
}

.button.secondary {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--text);
}

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

.button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.button.ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

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

/* ============================================================
   App shell layout
   ============================================================ */

.shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 200px minmax(0, 1fr);
}

.page-app .shell {
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  width: 200px;
  min-width: 200px;
  background: linear-gradient(180deg, #0f172a 0%, #131d33 100%);
  border-right: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-app {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  text-decoration: none;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 8px;
}

.brand-mark {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Fallback si se usara como texto en lugar de <img> */
div.brand-mark {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0891b2 0%, #6366f1 100%);
  color: #ffffff;
  font-family: var(--ff);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand strong {
  font-family: var(--ff-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
}

.brand span {
  font-size: 11px;
  color: var(--muted);
  display: block;
  margin-top: 1px;
}

/* Sidebar oscura: marca y textos en claro */
.sidebar .brand strong {
  color: #f1f5f9;
}

.sidebar .brand span,
.sidebar-panel p:last-child {
  color: #94a3b8;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px 0;
}

.nav-group-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #64748b;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 16px);
  margin: 1px 8px;
  padding: 7px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #cbd5e1;
  font-family: var(--ff);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: rgba(148, 163, 184, 0.12);
  color: #ffffff;
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.25), rgba(99, 102, 241, 0.25));
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}

.nav-item i {
  font-size: 15px;
  opacity: 0.7;
}

.nav-item.active i {
  opacity: 1;
  color: #22d3ee;
}

.sidebar-panel {
  margin: auto 14px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-3);
  padding: 10px;
}

.sidebar-panel p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ============================================================
   Main content area
   ============================================================ */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  margin-bottom: 20px;
}

.topbar-copy {
  display: grid;
  gap: 4px;
}

.topbar-copy h1 {
  font-family: var(--ff-display);
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 0;
  letter-spacing: -0.4px;
}

.topbar-copy-text {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
  max-width: 760px;
  line-height: 1.5;
}

.topbar-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ============================================================
   Auth
   ============================================================ */

.auth-status {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
}

.auth-panel {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  margin-bottom: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.auth-panel.active {
  display: flex;
}

#auth-panel {
  display: none;
}

#auth-panel.active {
  display: flex;
}

/* ============================================================
   Metrics
   ============================================================ */

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  margin-bottom: 5px;
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
  color: var(--text);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.metric small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

/* ============================================================
   Views
   ============================================================ */

.view {
  display: none;
}

.view.active {
  display: block;
  animation: zfFadeIn 0.18s ease both;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 18px;
  align-items: start;
}

/* View tabs (Runtime y otras vistas con sub-secciones) */
.view-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.view-tab {
  appearance: none;
  border: none;
  background: transparent;
  padding: 9px 16px;
  margin-bottom: -1px;
  font-family: var(--ff-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}

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

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

.tabpanel[hidden] {
  display: none;
}

/* ============================================================
   Conversaciones (bandeja + transcript)
   ============================================================ */

.conversations-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  height: calc(100vh - 150px);
}

.conversations-list-panel,
.conversations-detail-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.conversations-search {
  width: 160px;
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

#conversations-list {
  overflow-y: auto;
  flex: 1;
}

.conv-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  transition: background 0.12s;
}

.conv-row:hover {
  background: var(--panel-3);
}

.conv-row.active {
  background: var(--primary-light);
  box-shadow: inset 3px 0 0 var(--primary);
}

.conv-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.conv-row-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-row-time {
  font-size: 11px;
  color: var(--soft);
  flex-shrink: 0;
}

.conv-row-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.conv-row-meta .conv-agent {
  font-size: 10px;
  padding: 1px 7px;
}

.conv-channel {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--soft);
}

.conv-tenant {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 7px;
  border-radius: 20px;
  margin-left: auto;
}

.conversations-detail-panel {
  padding: 0;
  overflow: hidden;
}

#conversations-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.conv-placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 200px;
  padding: 40px;
  color: var(--soft);
  font-size: 13px;
  text-align: center;
}

.conv-detail-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.conv-detail-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.conv-detail-sub code {
  font-family: var(--ff-mono);
  font-size: 11px;
}

.conv-detail-contact {
  margin-top: 4px;
  font-size: 13px;
}

.conv-phone {
  color: var(--success);
  font-weight: 600;
  text-decoration: none;
}

.conv-phone:hover {
  text-decoration: underline;
}

.conv-row-phone {
  font-size: 11px;
  font-family: var(--ff-mono);
  color: var(--muted);
}

.conv-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(8, 145, 178, 0.02), transparent 120px);
}

.conv-bubble {
  max-width: 70%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.conv-bubble-meta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  opacity: 0.7;
  margin-bottom: 3px;
}

.conv-bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Mensaje del usuario (entrante) — izquierda, claro */
.conv-bubble-in {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

/* Respuesta del agente (saliente) — derecha, color marca */
.conv-bubble-out {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  border-bottom-right-radius: 4px;
  color: #ffffff;
}

.conv-bubble-out .conv-bubble-meta {
  opacity: 0.85;
}

.conv-tools {
  border-top: 1px solid var(--line);
  padding: 12px 20px;
}

.conv-tools-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ============================================================
   Panels and cards
   ============================================================ */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.wizard-panel {
  overflow: hidden;
}

.wizard-panel,
.side-summary {
  background: var(--panel);
}

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

.panel-head h2 {
  margin: 0;
}

.panel-head.compact {
  border-bottom: 0;
  padding: 0;
}

.panel-lead,
.login-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ============================================================
   Stepper / Builder
   ============================================================ */

.stepper {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
  overflow-x: auto;
}

.step {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border-bottom: 2px solid transparent;
  border-right: 1px solid var(--line);
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
  background: var(--panel-2);
  min-height: 56px;
  text-align: left;
}

.step:last-child {
  border-right: 0;
}

.step.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
  background: var(--primary-light);
}

.step small,
.step .step-number {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.6;
  margin-bottom: 3px;
}

.step span,
.step .step-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}

.wizard-body {
  padding: 18px;
}

.section-intro {
  margin-bottom: 16px;
}

.section-intro p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.wizard-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 18px;
}

.side-summary {
  position: sticky;
  top: 18px;
}

.summary-block {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.summary-block:last-child {
  border-bottom: 0;
}

.summary-block p,
.empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ============================================================
   Form fields
   ============================================================ */

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label,
.field > span,
.login-form .field span {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.field input,
.field select,
.field textarea,
.note-box input,
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  font-family: var(--ff);
  font-size: 13px;
  padding: 8px 12px;
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus,
.note-box input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

.option {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  cursor: pointer;
  padding: 13px;
  text-align: left;
}

.option:hover {
  border-color: var(--line-strong);
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option strong {
  display: block;
  font-size: 13px;
}

.option span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.credential-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 12px;
  padding: 14px;
}

.credential-card h3 {
  margin-bottom: 10px;
}

.form-card {
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.note-box {
  display: grid;
  gap: 6px;
}

.note-box input {
  min-width: 180px;
}

.agent-instruction-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

/* ============================================================
   Login form
   ============================================================ */

.login-form {
  display: grid;
  gap: 14px;
}

.auth-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ============================================================
   Status badges
   ============================================================ */

.status {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 20px;
  font-family: var(--ff-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  text-transform: uppercase;
}

.status.active,
.status.ACTIVE,
.status.published,
.status.completed,
.status.ready {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.2);
}

.status.revoked,
.status.REVOKED,
.status.archived,
.status.ARCHIVED,
.status.superseded,
.status.closed {
  background: #f1f5f9;
  color: var(--muted);
  border-color: var(--line);
}

.status.pending,
.status.PENDING,
.status.requires_credentials {
  background: var(--warning-dim);
  color: var(--warning);
  border-color: rgba(217, 119, 6, 0.2);
}

.status.waiting_human {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(99, 102, 241, 0.2);
}

/* ============================================================
   Pills / tags
   ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--panel-3);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* ============================================================
   Tables
   ============================================================ */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table.compact {
  font-size: 12px;
}

.table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: var(--panel-3);
}

.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  vertical-align: middle;
}

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

.table tr:hover td {
  background: var(--primary-light);
}

/* ============================================================
   Kanban
   ============================================================ */

.kanban {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.kanban-column {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px;
}

.kanban-column h3 {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  text-transform: capitalize;
}

.kanban-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  margin-bottom: 8px;
  padding: 9px;
}

.kanban-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

/* ============================================================
   Publication checklist
   ============================================================ */

.publication-checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.publication-check {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 12px;
}

.publication-check.ok {
  border-color: rgba(5, 150, 105, 0.3);
  background: var(--success-dim);
}

.publication-check.pending {
  border-color: rgba(217, 119, 6, 0.3);
  background: var(--warning-dim);
}

.publication-check strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
}

.publication-check span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

/* ============================================================
   Code blocks
   ============================================================ */

.code {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  font-family: var(--ff-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.run-result {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.next-step {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.next-step strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.next-step p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  border-radius: var(--radius);
  background: #0f172a;
  color: #ffffff;
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-size: 13px;
  line-height: 1.45;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Landing page
   ============================================================ */

/* Header */
.landing-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.landing-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 32px;
}

.brand-landing {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-landing strong {
  font-family: var(--ff-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.landing-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.landing-nav a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.12s, background 0.12s;
}

.landing-nav a:hover {
  color: var(--text);
  background: var(--panel-3);
}

.landing-actions {
  display: flex;
  gap: 8px;
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.85fr);
  gap: 48px;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 72px 32px 64px;
}

.hero-copy {
  display: grid;
  gap: 0;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  border: 1px solid var(--primary-mid);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  margin-bottom: 24px;
  width: fit-content;
}

.hero-badge-dot {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  animation: heroPulse 2s ease infinite;
}

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

.hero-copy h1 {
  font-family: var(--ff-display);
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.08;
  color: var(--text);
  margin-bottom: 20px;
}

.hero-lead {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
  max-width: 520px;
  margin-bottom: 0;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 28px;
}

/* Hero visual */
.hero-visual {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-pipeline {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

.pipeline-node {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.pipeline-node-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.pipeline-node-info strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.pipeline-node-info span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.pipeline-arrow {
  color: var(--primary-mid);
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.hero-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.hero-card-secondary {
  opacity: 0.7;
}

.hero-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

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

.hero-card-dot-green { background: var(--success); }
.hero-card-dot-blue  { background: var(--accent); }

.hero-card-time {
  margin-left: auto;
  font-size: 10px;
  color: var(--soft);
}

.hero-card p {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 10px;
}

.hero-card-tool {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-3);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
}

.hero-card-tool code {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
}

/* Stats bar */
.landing-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px 48px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.landing-stat {
  flex: 1;
  text-align: center;
  padding: 0 24px;
}

.landing-stat strong {
  display: block;
  font-family: var(--ff-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.landing-stat span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.landing-stat-div {
  width: 1px;
  height: 32px;
  background: var(--line);
  flex-shrink: 0;
}

/* Feature icons */
.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 14px;
}

.feature-icon-blue   { background: var(--primary); }
.feature-icon-indigo { background: #4f46e5; }
.feature-icon-cyan   { background: #0891b2; }

/* How it works section */
.content-band-dark {
  background: #0f172a;
  max-width: 100%;
  padding: 64px 32px;
  margin: 32px 0;
}

.content-band-dark .section-head {
  max-width: 1200px;
  margin: 0 auto 40px;
}

.how-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.how-step {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.how-step-num {
  font-family: var(--ff-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
}

.how-step-body strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 6px;
  line-height: 1.3;
}

.how-step-body p {
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.6;
  margin: 0;
}

/* Ops panel icon */
.ops-panel-icon {
  font-size: 20px;
  margin-bottom: 10px;
}

/* CTA final */
.landing-cta {
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
  margin: 48px 0 0;
}

.landing-cta-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.landing-cta h2 {
  font-size: 32px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.landing-cta p {
  color: rgba(255,255,255,0.75);
  font-size: 16px;
  line-height: 1.6;
  max-width: 480px;
}

.landing-cta .hero-actions {
  margin-top: 8px;
}

.landing-cta .button.primary {
  background: #ffffff;
  color: var(--primary);
  border-color: #ffffff;
}

.landing-cta .button.primary:hover {
  background: var(--primary-light);
}

.landing-cta .button.ghost {
  border-color: rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.9);
}

.landing-cta .button.ghost:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.7);
}

/* Footer */
.landing-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  background: #0f172a;
  color: #475569;
  font-size: 12px;
  margin-top: auto;
}

.landing-shell {
  min-height: 100vh;
  padding: 24px;
}

.landing-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  margin: 0 auto;
  max-width: 1200px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.brand-landing,
.brand-auth,
.brand-app {
  min-width: 0;
}

.landing-nav {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.landing-nav a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

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

.landing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 28px;
  align-items: start;
  margin: 0 auto;
  max-width: 1200px;
  padding: 88px 0 36px;
}

.hero-copy h1 {
  font-family: var(--ff-display);
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -2px;
  background: linear-gradient(135deg, #0891b2 0%, #6366f1 60%, #0f172a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  margin-bottom: 16px;
}

.hero-lead {
  max-width: 680px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.hero-metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.85);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.hero-metric strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.hero-metric span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.hero-rail {
  display: grid;
  gap: 14px;
}

.status-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 18px;
}

.status-card-main h2 {
  margin: 10px 0 8px;
  font-size: 18px;
}

.status-card-main p:last-child,
.status-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.content-band {
  margin: 0 auto;
  max-width: 1200px;
  padding: 42px 0 20px;
}

.content-band-alt {
  padding-top: 24px;
}

.section-head {
  display: grid;
  gap: 10px;
  max-width: 760px;
  margin-bottom: 22px;
}

.section-head h2 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.section-head p:last-child {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.feature-grid,
.module-grid,
.ops-grid,
.auth-points {
  display: grid;
  gap: 14px;
}

.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature,
.module-item,
.ops-panel,
.auth-points > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  padding: 18px;
  box-shadow: var(--shadow);
}

.feature h3,
.module-item strong,
.ops-panel strong,
.auth-points strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  margin: 8px 0 8px;
}

.feature p:last-child,
.module-item span,
.ops-panel span,
.auth-points span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.module-grid,
.ops-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ops-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ============================================================
   Auth / Login page
   ============================================================ */

.auth-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 0.7fr);
  gap: 32px;
  align-items: center;
  min-height: 100vh;
  margin: 0 auto;
  max-width: 1200px;
  padding: 28px 24px;
}

.auth-intro {
  display: grid;
  gap: 20px;
}

.auth-copy {
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  max-width: 560px;
}

.auth-points {
  grid-template-columns: 1fr;
}

.auth-panel.login-panel {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  padding: 22px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1100px) {
  .landing-header,
  .hero,
  .auth-shell,
  .page-app .shell,
  .shell,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .landing-header {
    align-items: start;
  }

  .landing-nav,
  .landing-actions {
    justify-content: flex-start;
  }

  .metrics,
  .feature-grid,
  .module-grid,
  .ops-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .side-summary {
    position: static;
  }
}

@media (max-width: 760px) {
  .landing-shell,
  .auth-shell {
    padding: 16px;
  }

  .hero {
    padding-top: 52px;
  }

  .hero-copy h1 {
    font-size: 36px;
  }

  .hero-metrics,
  .metrics,
  .feature-grid,
  .module-grid,
  .ops-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .auth-panel,
  .landing-header,
  .wizard-footer {
    flex-direction: column;
  }

  .landing-header {
    gap: 14px;
  }

  .landing-actions,
  .hero-actions,
  .auth-form-actions {
    width: 100%;
  }

  .landing-actions .button,
  .hero-actions .button,
  .auth-form-actions .button,
  .auth-form-actions a {
    width: 100%;
    justify-content: center;
  }

  .main {
    padding: 16px;
  }

  .metrics,
  .form-grid,
  .option-grid,
  .mode-row,
  .stepper,
  .kanban {
    grid-template-columns: 1fr;
  }

  .step {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
