/* ══════════════════════════════════════════════════════════════════
   DESIGN TOKENS — Fidex Brand Palette
══════════════════════════════════════════════════════════════════ */
:root {
  /* Fidex brand */
  --brand-dark:    #002e5b;
  --brand-mid:     #0a3d70;
  --brand-accent:  #42499c;
  --brand-teal:    #24a599;
  --brand-glow:    rgba(66,73,156,.18);
  --teal-glow:     rgba(36,165,153,.18);

  /* Functional palette */
  --indigo:        #42499c;
  --indigo-dark:   #333a87;
  --indigo-light:  #eef0fb;
  --teal:          #24a599;
  --teal-dark:     #1a8a80;
  --teal-light:    #e6f8f7;
  --violet:        #5b4fc8;
  --violet-light:  #f0effe;
  --orange:        #d97706;
  --orange-light:  #fffbeb;
  --green:         #18a058;
  --green-light:   #edfbf3;
  --red:           #dc2626;
  --red-light:     #fef2f2;

  /* Neutrals */
  --bg:            #e8edf5;
  --surface:       #ffffff;
  --border:        #cdd5e3;
  --border-focus:  #24a599;
  --text:          #0d1b2e;
  --text-2:        #1e3452;
  --text-muted:    #4e5f78;
  --text-faint:    #8a9ab5;

  /* Radii */
  --r-sm:   5px;
  --r-md:   9px;
  --r-lg:   13px;
  --r-xl:   18px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,46,91,.05);
  --shadow-sm: 0 1px 4px rgba(0,46,91,.07), 0 1px 2px rgba(0,46,91,.04);
  --shadow-md: 0 4px 12px rgba(0,46,91,.09), 0 2px 4px rgba(0,46,91,.05);
  --shadow-lg: 0 10px 32px rgba(0,46,91,.11), 0 4px 8px rgba(0,46,91,.06);
  --shadow-xl: 0 20px 60px rgba(0,46,91,.15);

  /* Font */
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ══════════════════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    linear-gradient(160deg, rgba(0,46,91,.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 5%, rgba(36,165,153,.09) 0%, transparent 55%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, select, textarea { font-family: var(--font); }

code {
  background: var(--indigo-light);
  color: var(--indigo-dark);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .82em;
  font-family: var(--mono);
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════════════════════════ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: 54px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 16px;
  box-shadow: 0 1px 8px rgba(0,46,91,.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  height: 30px;
  width: auto;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}
.brand-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
}
.brand-sub {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Badge SMTP */
.smtp-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.smtp-status-badge:hover { border-color: var(--brand-accent); color: var(--brand-accent); background: var(--indigo-light); }
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background .3s;
}
.badge-dot.ok    { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.2); }
.badge-dot.error { background: var(--red); }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-light); color: var(--red); }

.btn-icon-trash {
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  transition: background .2s, color .2s;
  margin-left: auto;
  flex-shrink: 0;
}
.btn-icon-trash:hover { background: var(--red-light); color: var(--red); }

/* ══════════════════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: calc(100vh - 54px);
}

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 54px;
  height: calc(100vh - 54px);
  overflow: hidden;
  transition: width .3s cubic-bezier(.4,0,.2,1);
  box-shadow: 2px 0 8px rgba(0,46,91,.05);
  z-index: 90;
}
.sidebar.collapsed { width: 62px; }

.sidebar-inner {
  width: 100%;
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
}

/* ── Step items in sidebar ────── */
.track-step {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  padding: 8px 8px;
  border-radius: var(--r-md);
  transition: background .18s;
}
.track-step:hover { background: var(--bg); }

.track-node {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  position: relative;
  flex-shrink: 0;
}
.node-num   { font-size: .8rem; font-weight: 600; color: var(--text-muted); transition: opacity .2s; }
.node-check { position: absolute; opacity: 0; transition: opacity .2s; color: #fff; }

.track-label {
  font-size: .83rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color .2s, opacity .2s;
  white-space: nowrap;
  overflow: hidden;
}

/* Active */
.track-step.active {
  background: var(--teal-light);
}
.track-step.active .track-node {
  background: var(--brand-teal);
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 4px rgba(36,165,153,.15), 0 2px 8px rgba(36,165,153,.25);
}
.track-step.active .node-num   { color: #fff; }
.track-step.active .track-label { color: var(--teal-dark); font-weight: 600; }

/* Done */
.track-step.done .track-node {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
  box-shadow: 0 2px 6px rgba(66,73,156,.2);
}
.track-step.done .node-num  { opacity: 0; }
.track-step.done .node-check { opacity: 1; }
.track-step.done .track-label { color: var(--brand-accent); }

/* Vertical connector */
.track-connector {
  width: 2px;
  height: 18px;
  background: var(--border);
  margin: 2px 0 2px 24px;
  transition: background .4s;
  border-radius: 2px;
  flex-shrink: 0;
}
.track-connector.done { background: var(--brand-accent); }

/* Collapsed — hide labels, center nodes */
.sidebar.collapsed .track-label    { opacity: 0; pointer-events: none; width: 0; }
.sidebar.collapsed .track-step     { padding: 8px 0; justify-content: center; gap: 0; }
.sidebar.collapsed .track-connector { margin-left: 0; align-self: center; }

/* ══════════════════════════════════════════════════════════════════
   PANELS
══════════════════════════════════════════════════════════════════ */
.panels-wrap {
  flex: 1;
  min-width: 0;
  max-width: 1104px;
  margin: 36px auto 80px;
  padding: 0 24px;
}

.panel-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 32px;
  box-shadow: 0 2px 10px rgba(0,46,91,.07), 0 8px 32px rgba(0,46,91,.05);
  border: 1px solid #d5dded;
  border-top: 3px solid var(--brand-teal);
}

.panel {
  display: none;
  animation: panelIn .28s cubic-bezier(.4,0,.2,1);
}
.panel.active { display: block; }

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

/* Panel intro */
.panel-intro {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}
.panel-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

/* Fidex panel icon variants — solid, no gradient */
.panel-icon.fidex-1 {
  background: #24a599;
  box-shadow: 0 4px 14px rgba(36,165,153,.3);
}
.panel-icon.fidex-2 {
  background: #42499c;
  box-shadow: 0 4px 14px rgba(66,73,156,.3);
}
.panel-icon.fidex-3 {
  background: #24a599;
  box-shadow: 0 4px 14px rgba(36,165,153,.25);
}
.panel-icon.fidex-4 {
  background: #42499c;
  box-shadow: 0 4px 14px rgba(66,73,156,.22);
}
.panel-icon.fidex-5 {
  background: #002e5b;
  box-shadow: 0 4px 14px rgba(0,46,91,.25);
}

/* Legacy classes kept for summary tiles */
.st-icon.teal   { background: var(--teal-light);   color: var(--teal); }
.st-icon.violet { background: var(--violet-light);  color: var(--violet); }
.st-icon.orange { background: var(--orange-light);  color: var(--orange); }
.st-icon.green  { background: var(--green-light);   color: var(--green); }
.st-icon.red    { background: var(--red-light);     color: var(--red); }

.panel-intro h2 {
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
  margin-bottom: 2px;
}
.panel-intro p { font-size: .875rem; color: var(--text-muted); line-height: 1.5; }

/* Panel nav */
.panel-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════════ */
.btn-next {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--brand-teal);
  color: #fff;
  border-radius: var(--r-md);
  font-size: .875rem;
  font-weight: 600;
  transition: background .2s, box-shadow .2s;
  box-shadow: 0 2px 10px var(--teal-glow);
}
.btn-next:hover:not(:disabled) {
  background: var(--teal-dark);
  box-shadow: 0 4px 18px rgba(36,165,153,.35);
}
.btn-next:disabled { background: #a8d5d1; color: #fff; cursor: not-allowed; box-shadow: none; }

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  color: var(--text-muted);
  border-radius: var(--r-md);
  font-size: .875rem;
  font-weight: 500;
  transition: background .2s, color .2s;
}
.btn-back:hover { background: var(--bg); color: var(--text); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--brand-accent);
  color: #fff;
  border-radius: var(--r-md);
  font-size: .875rem;
  font-weight: 600;
  transition: background .2s, box-shadow .2s;
  box-shadow: 0 2px 10px var(--brand-glow);
}
.btn-primary:hover { background: var(--indigo-dark); box-shadow: 0 4px 16px rgba(66,73,156,.3); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1.5px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-md);
  font-size: .875rem;
  font-weight: 500;
  transition: border-color .2s, color .2s, background .2s;
  background: var(--surface);
}
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }

.btn-sm { padding: 6px 14px; font-size: .8rem; }

.btn-launch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 36px;
  background: var(--brand-accent);
  color: #fff;
  border-radius: var(--r-lg);
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 18px rgba(66,73,156,.28);
  transition: background .2s, box-shadow .2s;
  letter-spacing: -.1px;
}
.btn-launch:hover:not(:disabled) {
  background: var(--indigo-dark);
  box-shadow: 0 6px 24px rgba(66,73,156,.32);
}
.btn-launch:disabled { opacity: .5; cursor: not-allowed; }

.link-btn {
  background: none;
  border: none;
  color: var(--teal);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
}
.link-btn:hover { text-decoration: underline; }
.link-text { color: var(--teal); font-weight: 500; }

/* ══════════════════════════════════════════════════════════════════
   FORM ELEMENTS
══════════════════════════════════════════════════════════════════ */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-group label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .1px;
}
.req { color: var(--red); }

.input-field {
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  width: 100%;
}
.input-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(36,165,153,.12);
}
.input-field::placeholder { color: var(--text-faint); }

.select-wrap { position: relative; }
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 36px 9px 12px;
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  outline: none;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.select-wrap::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}
.select-wrap select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(36,165,153,.12);
}

/* ══════════════════════════════════════════════════════════════════
   DROP ZONE
══════════════════════════════════════════════════════════════════ */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-xl);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s;
  background: #f5f8fc;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--brand-teal);
  background: var(--teal-light);
  box-shadow: inset 0 0 0 1px rgba(36,165,153,.3), 0 4px 16px rgba(36,165,153,.08);
}
.drop-zone-icon {
  width: 60px;
  height: 60px;
  background: var(--teal-light);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  transition: background .2s;
}
.drop-zone:hover .drop-zone-icon, .drop-zone.drag-over .drop-zone-icon {
  background: rgba(36,165,153,.15);
}
.drop-title { font-size: 1rem; font-weight: 600; color: var(--text-2); }
.drop-sub   { font-size: .85rem; color: var(--text-muted); }

.drop-zone.mini {
  padding: 16px;
  gap: 6px;
  border-radius: var(--r-lg);
  margin-bottom: 12px;
  flex-direction: row;
  justify-content: center;
}
.drop-zone.mini span { font-size: .82rem; color: var(--text-muted); }
.drop-zone.mini svg  { color: var(--text-faint); flex-shrink: 0; }
.drop-zone.mini:hover svg, .drop-zone.mini.drag-over svg { color: var(--teal); }

/* ZIP drop zone */
.drop-zone.mini.zip-zone {
  background: var(--indigo-light);
  border-color: rgba(66,73,156,.3);
  margin-bottom: 0;
}
.drop-zone.mini.zip-zone span { color: var(--indigo); }
.drop-zone.mini.zip-zone svg  { color: var(--indigo); opacity: .7; }
.drop-zone.mini.zip-zone:hover,
.drop-zone.mini.zip-zone.drag-over {
  background: rgba(66,73,156,.1);
  border-color: var(--indigo);
  box-shadow: inset 0 0 0 1px rgba(66,73,156,.25);
}
.drop-zone.mini.zip-zone:hover svg,
.drop-zone.mini.zip-zone.drag-over svg { color: var(--indigo); opacity: 1; }

/* ══════════════════════════════════════════════════════════════════
   PASO 1 — EXCEL
══════════════════════════════════════════════════════════════════ */
.file-success-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--teal-light) 0%, #f0fdf4 100%);
  border: 1px solid rgba(36,165,153,.25);
  border-left: 3px solid var(--brand-teal);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--brand-dark);
}
.file-success-icon {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--brand-teal) 0%, #1a8a80 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  box-shadow: 0 2px 6px rgba(36,165,153,.3);
}
.file-pills { display: flex; gap: 6px; margin-left: auto; }
.pill {
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: .75rem;
  font-weight: 600;
}
.pill.teal   { background: var(--teal-light);  color: var(--teal-dark); }
.pill.indigo { background: var(--indigo-light); color: var(--indigo-dark); }
.pill.violet { background: var(--violet-light); color: var(--violet); }

.columns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.preview-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: linear-gradient(90deg, #ecf0f8 0%, #f2f5fb 100%);
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 700;
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  background: var(--brand-dark);
  color: rgba(255,255,255,.92);
  font-weight: 600;
  white-space: nowrap;
  font-size: .78rem;
  letter-spacing: .3px;
}
.data-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f4f7fc; }

/* ══════════════════════════════════════════════════════════════════
   PASO 2 — ADJUNTOS
══════════════════════════════════════════════════════════════════ */
.attachments-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.attach-zone-card {
  display: flex;
  flex-direction: column;
  background: #f6f9fc;
  border: 1px solid var(--border);
  border-top: 3px solid transparent;
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-top-color .2s, box-shadow .2s, background .2s;
}
.attach-zone-card:has(.azc-badge.personal) { border-top-color: var(--brand-accent); }
.attach-zone-card:has(.azc-badge.global)   { border-top-color: var(--brand-teal); }
.attach-zone-card:hover { box-shadow: var(--shadow-md); background: var(--surface); }

.azc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  margin-bottom: 10px;
}
.azc-badge {
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.azc-badge.personal { background: var(--indigo-light); color: var(--indigo); }
.azc-badge.global   { background: var(--teal-light);   color: var(--teal-dark); }
.azc-count { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.azc-hint  { font-size: .8rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }

.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 12px;
  flex: 1;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg);
  border-radius: var(--r-md);
  font-size: .8rem;
  color: var(--text-2);
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.file-item:hover { border-color: var(--border); background: var(--surface); }
.file-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item button {
  color: var(--text-faint);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  transition: color .15s;
  flex-shrink: 0;
}
.file-item button:hover { color: var(--red); }

.coverage-chip {
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: .8rem;
  line-height: 1.5;
  margin-top: 8px;
  font-weight: 500;
}
.coverage-chip.ok   { background: var(--green-light); color: var(--green); border: 1px solid rgba(24,160,88,.2); }
.coverage-chip.warn { background: #fffbeb;             color: #92400e;      border: 1px solid #fde68a; }

/* ══════════════════════════════════════════════════════════════════
   PASO 3 — EDITOR
══════════════════════════════════════════════════════════════════ */
.editor-shell {
  display: grid;
  grid-template-columns: 200px 1fr 240px;
  gap: 18px;
  align-items: start;
}

.editor-sidebar-left,
.editor-sidebar-right {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.sidebar-block {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-block:last-child { border-bottom: none; }
.sidebar-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: .7px;
  opacity: .75;
}

.logo-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-thumb {
  width: 72px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  flex-shrink: 0;
}
.logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
#logo-empty-text { font-size: .7rem; color: var(--text-faint); }

/* Variables */
.vars-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 32px;
}
.var-chip {
  padding: 4px 10px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px solid rgba(36,165,153,.25);
  border-radius: var(--r-full);
  font-size: .72rem;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.var-chip:hover { background: rgba(36,165,153,.2); border-color: var(--teal); }
.vars-empty { font-size: .78rem; color: var(--text-faint); font-style: italic; }

.subject-vars-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  min-height: 0;
}
.subject-vars-list .var-chip {
  font-size: .68rem;
  padding: 2px 7px;
}

/* Format bar */
.fmt-bar { display: flex; flex-wrap: wrap; gap: 4px; }
.fmt-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: .82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
}
.fmt-btn:hover { background: var(--teal-light); border-color: var(--teal); color: var(--teal-dark); }

/* Templates */
.tpl-list { display: flex; flex-direction: column; gap: 3px; }
.tpl-btn {
  padding: 8px 10px;
  border-radius: var(--r-md);
  text-align: left;
  font-size: .82rem;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.tpl-btn:hover { background: var(--indigo-light); color: var(--indigo); }

/* Main editor */
.editor-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.editor-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #f4f7fb;
  padding: 0 4px;
  gap: 2px;
}
.etab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.etab:hover { color: var(--text); }
.etab.active { color: var(--brand-teal); border-bottom-color: var(--brand-teal); background: var(--surface); font-weight: 600; }

.etab-panel { display: none; }
.etab-panel.active { display: block; }

/* WYSIWYG visual editor */
.wysiwyg-editor {
  width: 100%;
  min-height: 380px;
  padding: 24px 28px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: .9rem;
  line-height: 1.9;
  color: var(--text);
  outline: none;
  background: #fff;
  cursor: text;
  border: none;
}
.wysiwyg-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
  font-family: var(--font);
  font-size: .875rem;
  line-height: 1.7;
  font-style: italic;
}
.wysiwyg-editor .var-tag {
  display: inline-block;
  padding: 1px 8px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px solid rgba(36,165,153,.3);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .75em;
  font-weight: 600;
  cursor: default;
  user-select: all;
  white-space: nowrap;
  vertical-align: baseline;
  line-height: 1.5;
}

/* HTML textarea */
#email-body {
  width: 100%;
  min-height: 380px;
  border: none;
  padding: 16px;
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.7;
  color: var(--text);
  resize: vertical;
  outline: none;
  background: var(--surface);
}
#email-preview-frame, #test-preview-frame {
  width: 100%;
  height: 420px;
  border: none;
  display: block;
}

/* ══════════════════════════════════════════════════════════════════
   PASO 4 — PRUEBA
══════════════════════════════════════════════════════════════════ */
.test-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}
.test-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.input-with-btn {
  display: flex;
  gap: 8px;
}
.input-with-btn .input-field { flex: 1; }

.btn-send-test {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--brand-teal);
  color: #fff;
  border-radius: var(--r-md);
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background .2s, box-shadow .2s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--teal-glow);
}
.btn-send-test:hover { background: var(--teal-dark); box-shadow: 0 4px 14px rgba(36,165,153,.35); }
.btn-send-test:disabled { background: #a8d5d1; cursor: not-allowed; box-shadow: none; }

.test-info-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--teal-light);
  border: 1px solid rgba(36,165,153,.2);
  border-radius: var(--r-md);
  font-size: .8rem;
  color: var(--teal-dark);
  line-height: 1.5;
}
.test-info-box svg { flex-shrink: 0; margin-top: 1px; }

.test-preview-wrap { display: flex; flex-direction: column; gap: 8px; }
.preview-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.test-preview-wrap iframe {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  height: 400px;
}

.feedback-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: .82rem;
  font-weight: 500;
}
.feedback-bar.success { background: var(--green-light); color: var(--green); border: 1px solid rgba(24,160,88,.2); }
.feedback-bar.error   { background: var(--red-light);   color: var(--red);   border: 1px solid rgba(220,38,38,.2); }
.feedback-bar.info    { background: var(--teal-light);  color: var(--teal-dark); border: 1px solid rgba(36,165,153,.2); }
.feedback-bar.loading { background: var(--bg);          color: var(--text-muted); border: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════════════
   PASO 5 — ENVÍO
══════════════════════════════════════════════════════════════════ */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.summary-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s;
}
.summary-tile:hover { box-shadow: var(--shadow-md); }
.st-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.st-value { font-size: 1.3rem; font-weight: 700; color: var(--text); letter-spacing: -.5px; }
.st-value.st-subject { font-size: .82rem; font-weight: 500; letter-spacing: 0; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px; }
.st-label { font-size: .72rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

.send-config {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  font-size: .85rem;
  color: var(--text-muted);
}
.range-input {
  -webkit-appearance: none;
  width: 180px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand-teal);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(36,165,153,.15);
}

#send-action { margin-bottom: 28px; }

/* Progress */
.send-progress { display: flex; flex-direction: column; gap: 16px; }

.prog-stats {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.prog-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.prog-num {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.5px;
}
.prog-lbl { font-size: .72rem; font-weight: 500; color: var(--text-muted); }
.prog-stat.sent   .prog-num { color: var(--teal); }
.prog-stat.failed .prog-num { color: var(--red); }
.prog-stat.total  .prog-num { color: var(--text-muted); }

.prog-pct-wrap {
  position: relative;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
}
.prog-ring { transform: rotate(-90deg); }
.ring-bg   { stroke: var(--border); }
.ring-fill {
  stroke: var(--brand-teal);
  transition: stroke-dashoffset .4s ease;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 163.36;
}
#prog-pct {
  position: absolute;
  font-size: .78rem;
  font-weight: 700;
  color: var(--brand-teal);
}

.prog-bar-wrap { background: #edf1f8; border-radius: var(--r-full); overflow: hidden; height: 6px; border: 1px solid var(--border); }
.prog-bar { height: 100%; background: transparent; }
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-dark) 0%, var(--brand-teal) 100%);
  width: 0%;
  transition: width .4s ease;
  border-radius: var(--r-full);
}

/* Done card */
.done-card {
  background: linear-gradient(135deg, var(--teal-light) 0%, #d4f3f0 100%);
  border: 1px solid rgba(36,165,153,.2);
  border-radius: var(--r-xl);
  padding: 40px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 24px rgba(36,165,153,.1);
}
.done-animation svg { animation: popIn .4s cubic-bezier(.34,1.56,.64,1); }
@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.done-card h3 { font-size: 1.15rem; font-weight: 700; color: var(--teal-dark); }
.done-card p  { font-size: .875rem; color: var(--text-muted); max-width: 360px; }

/* ══════════════════════════════════════════════════════════════════
   MODAL ADMIN SMTP
══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,20,50,.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeOverlay .2s ease;
}
@keyframes fadeOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-overlay.hidden { display: none !important; }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-xl);
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}
@keyframes modalIn {
  from { transform: scale(.94) translateY(12px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: var(--brand-dark);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.55) !important;
  transition: background .15s, color .15s !important;
}
.modal-close:hover { background: rgba(255,255,255,.12) !important; color: #fff !important; }
.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.modal-form-grid .field-group { grid-column: span 1; }
.modal-form-grid .span-2 { grid-column: span 2; }
.modal-form-grid .span-3 { grid-column: span 3; }

.field-hint {
  font-size: .72rem;
  color: var(--text-faint);
  margin-top: -2px;
}
.field-code {
  display: inline-block;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
  vertical-align: middle;
}

.pass-wrap { position: relative; }
.pass-wrap .input-field { padding-right: 40px; }
.pass-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
}
.pass-toggle:hover { color: var(--text-muted); }

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

/* ══════════════════════════════════════════════════════════════════
   TOASTS
══════════════════════════════════════════════════════════════════ */
#toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-lg);
  font-size: .85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .22s cubic-bezier(.4,0,.2,1);
  max-width: 320px;
  pointer-events: all;
  border: 1px solid transparent;
}
.toast.success { background: var(--green-light); color: var(--green); border-color: rgba(24,160,88,.2); }
.toast.error   { background: var(--red-light);   color: var(--red);   border-color: rgba(220,38,38,.2); }
.toast.warning { background: #fffbeb;             color: #92400e;      border-color: #fde68a; }
.toast.info    { background: var(--teal-light);  color: var(--teal-dark); border-color: rgba(36,165,153,.2); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ══════════════════════════════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

.spin {
  display: inline-block;
  animation: spinning .65s linear infinite;
}
@keyframes spinning { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .editor-shell { grid-template-columns: 1fr; }
  .editor-sidebar-right { order: -1; }
}
@media (max-width: 768px) {
  .attachments-layout { grid-template-columns: 1fr; }
  .columns-grid   { grid-template-columns: 1fr; }
  .summary-grid   { grid-template-columns: repeat(2, 1fr); }
  .test-layout    { grid-template-columns: 1fr; }
  .track-label    { display: none; }
  .track-step     { min-width: unset; }
  .prog-stats     { flex-wrap: wrap; gap: 12px; }
  .panel-card     { padding: 20px; }
}
@media (max-width: 480px) {
  .summary-grid   { grid-template-columns: 1fr; }
  .modal-form-grid { grid-template-columns: 1fr; }
  .modal-form-grid .span-2,
  .modal-form-grid .span-3 { grid-column: span 1; }
}
