/* ==========================================================================
   DOCPACK — Layout & components
   ========================================================================== */

:root {
  --bg: #0c1017;
  --bg-elevated: #111827;
  --surface: #151d2b;
  --surface-2: #1c2738;
  --surface-3: #243044;
  --text: #eef2f8;
  --text-muted: #8fa3bf;
  --text-dim: #5c6f8a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --danger: #f87171;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.22);
  --sidebar-w: 260px;
  --header-h: 64px;
  --footer-h: 46px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --transition: 0.22s ease;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(20, 184, 166, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(59, 130, 246, 0.07), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 10000;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.18s ease;
}

.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page-content:focus {
  outline: none;
}

.page-content:focus-visible {
  outline: none;
}

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  width: calc(100% - var(--sidebar-w));
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #14b8a6 0%, #0d9488 45%, #0f766e 100%);
  border-radius: 11px;
  color: #ecfdf5;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.28);
}

.brand-mark {
  width: 26px;
  height: 26px;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.brand-accent {
  color: #2dd4bf;
  font-weight: 800;
}

.brand-tag {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px 16px;
  overflow-y: auto;
}

.nav-group + .nav-group {
  margin-top: 8px;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.nav-group-toggle:hover {
  background: var(--surface-2);
}

.nav-group.is-expanded .nav-group-toggle {
  color: #cbd5e1;
}

.nav-group-label {
  flex: 1;
  text-align: left;
}

.nav-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-dim);
  transition: transform var(--transition);
}

.nav-group.is-expanded .nav-chevron {
  transform: rotate(180deg);
  color: var(--text-muted);
}

/* Sin animación al aplicar estado guardado en la carga inicial */
html.nav-init .nav-group-panel,
html.nav-init .nav-group-panel-inner,
html.nav-init .nav-chevron {
  transition: none !important;
}

/* Evitar parpadeo de contenido antes de que el router termine el arranque.
   No ocultar .sidebar-nav: con hard-refresh (Ctrl+Shift+R) el CSS llega tarde,
   se aplica visibility:hidden y luego se quita → los grupos Documentos/Herramientas parpadean. */
html.app-boot .page-content,
html.app-boot .header-titles {
  opacity: 0;
  pointer-events: none;
}

html:not(.app-boot) .page-content,
html:not(.app-boot) .header-titles {
  transition: opacity 0.28s ease;
}

.nav-group-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}

.nav-group.is-expanded .nav-group-panel {
  grid-template-rows: 1fr;
}

.nav-group-panel-inner {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

.nav-group.is-expanded .nav-group-panel-inner {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 0.2s ease 0.05s,
    visibility 0.2s ease 0.05s;
}

.nav-group-list {
  list-style: none;
  margin: 0;
  padding: 4px 0 8px 4px;
}

.nav-group-list li {
  margin: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px 9px 14px;
  margin: 0 0 2px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: #93c5fd;
  border-left-color: var(--accent);
}

.nav-item--soon .nav-label {
  color: var(--text-dim);
}

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

.nav-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 18px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.sidebar-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sidebar-meta__name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-meta__version {
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #93c5fd;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: 999px;
  padding: 2px 7px;
  line-height: 1.3;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

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

.status-dot.is-ok { background: var(--success); box-shadow: 0 0 8px rgba(34, 197, 94, 0.5); }
.status-dot.is-error { background: var(--danger); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--transition);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: rgba(12, 16, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  justify-self: start;
}

.header-titles { min-width: 0; }

.header-eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}

.header-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 100%;
  justify-self: center;
}

.header-right {
  min-width: 0;
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.header-user {
  position: relative;
  flex-shrink: 0;
}

.header-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 11rem;
  height: 40px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.header-user-trigger:hover,
.header-user.is-open .header-user-trigger {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.header-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.16);
  color: #5eead4;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.header-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
}

.header-user-caret {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform var(--transition);
}

.header-user.is-open .header-user-caret {
  transform: rotate(180deg);
}

.header-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 160px;
  padding: 6px;
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.header-user-menu[hidden] {
  display: none;
}

.header-user-menu-item {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.header-user-menu-item:hover {
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
}

.edo-header-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  max-height: calc(var(--header-h) - 16px);
  flex-wrap: wrap;
}

.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.health-badge.is-ok {
  background: var(--success-soft);
  border-color: rgba(34, 197, 94, 0.25);
  color: #86efac;
}

.health-badge.is-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.25);
  color: #fca5a5;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-btn:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
}

.icon-btn svg { width: 16px; height: 16px; }

.sidebar-toggle {
  position: relative;
}

.sidebar-toggle__icon {
  display: none;
}

.sidebar-toggle__icon--panel {
  display: block;
}

.sidebar-toggle__icon--menu {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-toggle,
html.sidebar-pref-collapsed .sidebar-toggle {
  color: #93c5fd;
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.28);
}

.app-shell.sidebar-collapsed .sidebar-toggle:hover,
html.sidebar-pref-collapsed .sidebar-toggle:hover {
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
}

/* Desktop: colapsar / expandir sidebar */
@media (min-width: 769px) {
  .app-shell.sidebar-collapsed .sidebar,
  html.sidebar-pref-collapsed .sidebar {
    transform: translateX(-100%);
    pointer-events: none;
  }

  .app-shell.sidebar-collapsed .main-wrapper,
  html.sidebar-pref-collapsed .main-wrapper {
    margin-left: 0;
    width: 100%;
  }

  .app-shell.sidebar-collapsed .page-footer,
  html.sidebar-pref-collapsed .page-footer {
    left: 0;
  }
}

/* --------------------------------------------------------------------------
   Page content
   -------------------------------------------------------------------------- */

.page-content {
  flex: 1;
  width: 100%;
  max-width: none;
  padding: 24px;
  padding-bottom: calc(24px + var(--footer-h));
}

.page-footer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 90;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  height: var(--footer-h);
  padding: 0 24px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(12, 16, 23, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  transition: left var(--transition);
}

.footer-sep { opacity: 0.4; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: start;
}

.form-card {
  min-width: 0;
}

.preview-card {
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card-header {
  margin-bottom: 14px;
}

.card-header h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 700;
}

.card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Form
   -------------------------------------------------------------------------- */

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0 0 14px;
  padding: 12px 14px 6px;
  background: rgba(0, 0, 0, 0.12);
}

legend {
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.field-grid {
  display: grid;
  gap: 12px;
}

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

.field-grid--dense {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.span-12 { grid-column: span 12; }
.span-10 { grid-column: span 10; }
.span-9 { grid-column: span 9; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.span-2 { grid-column: span 2; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.field.is-schema-hidden,
[data-form-field].is-schema-hidden,
[data-form-field][hidden] {
  display: none !important;
}

.field.is-optional {
  opacity: 0.92;
}

.field.field--error,
.select-control.field--error,
[data-form-field].field--error {
  position: relative;
  z-index: 2;
}

.field.field--error > input,
.field.field--error > select,
.field.field--error .input-select,
.select-control.field--error .input-select,
[data-form-field].field--error input,
[data-form-field].field--error select {
  border-color: #f87171 !important;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.28) !important;
}

.field-error-tip {
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 6px);
  bottom: auto;
  z-index: 30;
  max-width: min(280px, 90vw);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: #fff7f7;
  background: #b91c1c;
  border: 1px solid rgba(254, 202, 202, 0.35);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: normal;
}

.field-error-tip::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 16px;
  border: 6px solid transparent;
  border-bottom-color: #b91c1c;
}

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

.field input,
.field select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  margin: 0;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
  background-color: var(--surface-2);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

/* Desplegable nativo de Windows: texto claro + fondo blanco = opciones invisibles */
.field select,
select.input-select,
.input-select {
  color-scheme: dark;
}

.field select option,
select.input-select option,
.input-select option,
select option {
  color: #0f172a;
  background-color: #ffffff;
}

.field select option:checked,
select.input-select option:checked,
.input-select option:checked,
select option:checked {
  color: #0f172a;
  background-color: #e2e8f0;
}

.field select option:disabled,
select.input-select option:disabled,
.input-select option:disabled,
select option:disabled {
  color: #64748b;
  background-color: #f8fafc;
}

.field input.input--id {
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.field input.input--readonly {
  background: #0f1724;
  color: #93c5fd;
  cursor: default;
}

.field input.input--readonly:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: none;
}

.field input[name="employee_curp"] {
  min-width: 18ch;
  letter-spacing: 0.04em;
}

.field input[name="employee_rfc"] {
  min-width: 13ch;
}

.field input[name="employee_nss"] {
  min-width: 11ch;
}

.field input[name="employee_number"] {
  min-width: 8ch;
}

.field input[name="address_postal_code"] {
  min-width: 6ch;
}

.field input[name="address_number"] {
  min-width: 5ch;
}

.field input[type="date"] {
  min-width: 9.75rem;
  max-width: 100%;
}

.field input[type="number"] {
  min-width: 0;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder,
.field input[type="number"]::placeholder,
.field input[type="search"]::placeholder,
.input-text::placeholder { color: var(--text-dim); }

.field select:invalid,
select.input-select:invalid {
  color: var(--text-dim);
}

.field select:valid,
select.input-select:valid {
  color: var(--text);
}

.field select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color: var(--text);
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238fa3bf' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
  padding-right: 36px;
}

/* --------------------------------------------------------------------------
   Controles de formulario reutilizables (select, input)
   -------------------------------------------------------------------------- */

.input-text,
.input-select,
.field .input-select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  background: linear-gradient(180deg, var(--surface-3) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.input-select,
.field .input-select,
.field select.input-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color-scheme: dark;
  color: var(--text);
  background-color: var(--surface-2);
  padding-right: 42px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%232dd4bf' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--surface-3) 0%, var(--surface-2) 100%);
  background-repeat: no-repeat, no-repeat;
  background-position: right 14px center, 0 0;
  background-size: 14px 14px, auto;
}

.input-text:hover {
  border-color: rgba(45, 212, 191, 0.35);
}

.input-select:hover,
.field .input-select:hover,
.field select.input-select:hover {
  border-color: rgba(45, 212, 191, 0.35);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235eead4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(36, 48, 68, 0.95) 0%, var(--surface-2) 100%);
}

.input-text:focus,
.input-select:focus,
.field .input-select:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow:
    0 0 0 3px rgba(45, 212, 191, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.select-control {
  display: grid;
  gap: 8px;
  min-width: min(100%, 300px);
  flex: 1;
}

.select-control-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.select-control-icon {
  width: 15px;
  height: 15px;
  color: #2dd4bf;
  flex-shrink: 0;
}

.select-wrap {
  position: relative;
}

.select-wrap .input-select {
  padding-left: 16px;
}

/* --------------------------------------------------------------------------
   Barra de controles y segmented toggles
   -------------------------------------------------------------------------- */

.control-bar,
.templates-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 18px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: linear-gradient(145deg, rgba(28, 39, 56, 0.92) 0%, rgba(21, 29, 43, 0.88) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.segmented-control,
.templates-view-toggle,
.psd-source-mode,
.psd-compare-mode {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  background: rgba(12, 16, 23, 0.55);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22);
}

.segmented-control--wide {
  display: flex;
  width: 100%;
}

.segmented-control-btn,
.templates-view-btn,
.psd-source-mode-btn,
.psd-compare-mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--transition),
    color var(--transition),
    box-shadow var(--transition),
    transform 0.15s ease;
}

.segmented-control--wide .segmented-control-btn,
.segmented-control--wide .psd-source-mode-btn {
  flex: 1;
  justify-content: center;
  text-align: center;
}

.segmented-control--compact {
  display: flex;
  width: 100%;
  min-width: 220px;
}

.segmented-control--compact .segmented-control-btn,
.segmented-control--compact .templates-view-btn {
  flex: 1;
  text-align: center;
}

@media (max-width: 720px) {
  .control-bar,
  .templates-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .select-control {
    min-width: 100%;
  }

  .segmented-control-group {
    width: 100%;
  }
}

.segmented-control-btn:hover,
.templates-view-btn:hover,
.psd-source-mode-btn:hover,
.psd-compare-mode-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.segmented-control-btn.is-active,
.templates-view-btn.is-active,
.psd-source-mode-btn.is-active,
.psd-compare-mode-btn.is-active {
  color: #ecfdf5;
  background: linear-gradient(145deg, rgba(20, 184, 166, 0.38) 0%, rgba(13, 148, 136, 0.22) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(45, 212, 191, 0.42),
    0 4px 14px rgba(20, 184, 166, 0.18);
}

.segmented-control-btn:focus-visible,
.templates-view-btn:focus-visible,
.psd-source-mode-btn:focus-visible,
.psd-compare-mode-btn:focus-visible,
.input-select:focus-visible {
  outline: 2px solid rgba(45, 212, 191, 0.65);
  outline-offset: 2px;
}

.segmented-control-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}

.segmented-control-group {
  display: grid;
  gap: 8px;
}

.segmented-control-btn--grid::before,
.segmented-control-btn--list::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 7px;
  vertical-align: -2px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.85;
}

.segmented-control-btn--grid::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23eef2f8' stroke-width='2'%3E%3Crect x='3' y='3' width='7' height='7' rx='1'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1'/%3E%3Crect x='14' y='14' width='7' height='7' rx='1'/%3E%3C/svg%3E");
}

.segmented-control-btn--list::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23eef2f8' stroke-width='2'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E");
}

.templates-view-btn.is-active.segmented-control-btn--grid::before,
.templates-view-btn.is-active.segmented-control-btn--list::before {
  opacity: 1;
}

.field input.input--uppercase,
.input-text.input--uppercase {
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.field input.input--uppercase::placeholder {
  text-transform: none;
  letter-spacing: normal;
}

.employee-name-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.employee-name-fields .field {
  min-width: 0;
}

.employee-name-fields .field input {
  width: 100%;
  min-width: 0;
}

@media (max-width: 768px) {
  .employee-name-fields {
    grid-template-columns: 1fr;
  }
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0 0 10px;
  line-height: 1.45;
}

.hint--inline {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.hint--error {
  color: #fca5a5;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

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

.generate-progress {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(12, 16, 23, 0.45);
}

.generate-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.generate-progress-head span:last-child {
  font-weight: 700;
  color: #5eead4;
  font-variant-numeric: tabular-nums;
}

.generate-progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  border: 1px solid var(--border);
}

.generate-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d9488 0%, #2dd4bf 55%, #5eead4 100%);
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.35);
  transition: width 0.35s ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), transform 0.1s ease;
}

.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary { background: var(--accent); color: white; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn--secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn--secondary:hover:not(:disabled) { background: var(--surface-3); }

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--text);
}

.btn--success { background: var(--success); color: #052e16; }
.btn--success:hover:not(:disabled) { background: #16a34a; }

/* --------------------------------------------------------------------------
   Preview & table
   -------------------------------------------------------------------------- */

.summary {
  margin-bottom: 16px;
  line-height: 1.55;
  font-size: 14px;
}

.summary--empty { margin-bottom: 0; }

.summary--loading {
  margin-bottom: 0;
  min-height: 140px;
  display: grid;
  place-items: center;
}

.clients-loading-spinner {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  margin: 0;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-top-color: var(--accent);
  animation: docpack-spin 0.7s linear infinite;
}

.summary-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

.summary-placeholder svg {
  width: 40px;
  height: 40px;
  margin: 0;
  flex-shrink: 0;
  opacity: 0.45;
}

.summary-placeholder p { margin: 0; max-width: 280px; }

.muted { color: var(--text-muted); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}

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

.data-table th,
.data-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table td {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.data-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  background: var(--surface-2);
  position: sticky;
  top: 0;
}

.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr.preview-row { cursor: pointer; }
.data-table tbody tr.preview-row:hover { background: rgba(56, 189, 248, 0.08); }
.data-table .preview-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
}
.data-table .preview-link:hover { color: #7dd3fc; }

.doc-preview-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 12px;
  background: rgba(8, 13, 20, 0.72);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}
.doc-preview-loading.hidden { display: none !important; }

.doc-preview-loading::before {
  content: "";
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2.5px solid rgba(148, 163, 184, 0.25);
  border-top-color: #5eead4;
  animation: docpack-spin 0.7s linear infinite;
}

.doc-preview-panel { position: relative; display: flex; flex-direction: column; min-height: 0; }
.doc-preview-header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.doc-preview-subtitle {
  margin: 0;
  font-size: 12px;
}
.doc-preview-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.doc-preview-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.doc-preview-pager.hidden { display: none !important; }
.doc-preview-page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.doc-preview-page-jump input {
  width: 4.2rem;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

.doc-preview-zoombar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.doc-preview-zoom-label {
  min-width: 3.5rem;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.doc-preview-zoom-hint {
  margin: 0 0 0 auto;
}

.doc-preview-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(45deg, #dbe3ec 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #dbe3ec 25%, transparent 25%) 0 8px / 16px 16px,
    linear-gradient(45deg, transparent 75%, #dbe3ec 75%) 0 8px / 16px 16px,
    linear-gradient(-45deg, transparent 75%, #dbe3ec 75%) 0 0 / 16px 16px,
    #e8ecf1;
  display: grid;
  place-items: center;
  padding: 14px;
  cursor: grab;
  outline: none;
  touch-action: none;
}

.doc-preview-body.is-panning {
  cursor: grabbing;
  user-select: none;
}

.doc-preview-body:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.doc-preview-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
}

.doc-preview-image {
  display: block;
  width: var(--doc-preview-width, min(100%, 720px));
  max-width: none;
  height: auto !important;
  flex-shrink: 0;
  object-fit: contain;
  object-position: top center;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 2px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  background: #fff;
  pointer-events: none;
  user-select: none;
}
.doc-preview-image[hidden] { display: none !important; }

.doc-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  background: #fff;
  position: absolute;
  inset: 0;
}
.doc-preview-frame[hidden] { display: none !important; }

.doc-preview-body:has(.doc-preview-frame:not([hidden])) {
  padding: 0;
  display: block;
  cursor: default;
  touch-action: auto;
}

.preview-edos-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.preview-edos-section.hidden { display: none !important; }
#doc-preview-modal .pdf-modal-header {
  align-items: flex-start;
}

/* Modal de vista previa: fluido al viewport, con margen (no full-bleed) */
#doc-preview-modal.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  padding: max(1.5rem, env(safe-area-inset-top, 0px))
    max(1.5rem, env(safe-area-inset-right, 0px))
    max(1.5rem, env(safe-area-inset-bottom, 0px))
    max(1.5rem, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  overflow: hidden;
}

#doc-preview-modal .pdf-modal-panel,
#doc-preview-modal .doc-preview-panel {
  position: relative;
  z-index: 1;
  width: min(94vw, calc(100vw - 3rem));
  height: min(90dvh, calc(100dvh - 3rem));
  max-width: calc(100vw - 3rem);
  max-height: calc(100dvh - 3rem);
  margin: 0;
}

.log-box {
  margin-top: 16px;
  background: #080d14;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
  color: #a8b8d0;
}

.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   Herramientas — carga y catálogo de plantillas
   -------------------------------------------------------------------------- */

.upload-card {
  margin-bottom: 0;
  padding: 22px;
}

.herramientas-page {
  display: grid;
  gap: 20px;
}

.herramientas-split {
  display: grid;
  gap: 20px;
  align-items: start;
}

@media (min-width: 1100px) {
  .herramientas-split {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  }

  .herramientas-split--psd-workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.herramientas-side {
  position: sticky;
  top: 16px;
}

.herramientas-main {
  min-width: 0;
}

.template-filter-empty {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.template-tile-group-tag {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.template-groups.is-list-view .template-grid {
  grid-template-columns: 1fr;
  gap: 10px;
}

.template-groups.is-list-view .template-tile {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.template-groups.is-list-view .template-preview-wrap {
  aspect-ratio: auto;
  min-height: 0;
  height: 100%;
  max-height: 150px;
}

.template-groups.is-list-view .template-preview-hit,
.template-groups.is-list-view .template-preview-placeholder {
  min-height: 120px;
}

.template-groups.is-list-view .template-tile-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 4px;
}

.template-groups.is-list-view .template-tile-footer {
  margin-top: auto;
}

.template-groups.is-list-view .template-group-header {
  display: none;
}

.template-groups.is-list-view .template-group {
  gap: 0;
}

.upload-form {
  display: grid;
  gap: 16px;
  position: relative;
}

.upload-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 10px;
  margin: 0;
  background: rgba(0, 0, 0, 0.1);
}

.upload-fieldset legend {
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.upload-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.upload-option:last-child { margin-bottom: 0; }

.upload-option input { margin-top: 3px; flex-shrink: 0; }

.upload-option code {
  font-size: 11px;
  color: #cbd5e1;
}

.upload-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.upload-drop {
  cursor: pointer;
  display: block;
  padding: 28px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.upload-drop:hover,
.upload-drop.is-dragover {
  border-color: #2dd4bf;
  background: rgba(20, 184, 166, 0.08);
}

.upload-drop-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(45, 212, 191, 0.12);
  color: #2dd4bf;
}

.upload-drop-icon svg { width: 24px; height: 24px; }

.upload-drop-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.upload-drop-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.upload-feedback {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
}

.upload-feedback--ok {
  background: var(--success-soft);
  border: 1px solid rgba(34, 197, 94, 0.28);
  color: #86efac;
}

.upload-feedback--error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.28);
  color: #fca5a5;
}

.templates-card { padding: 22px; }

.templates-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.templates-card > .card-header.templates-header {
  margin-bottom: 12px;
}

.templates-card > .templates-toolbar {
  margin-bottom: 18px;
}

.templates-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.templates-pill--ok {
  background: var(--success-soft);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.templates-pill--warn {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.28);
  color: #fca5a5;
}

.templates-pill--info {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

.path-code {
  font-size: 12px;
  color: #a5b4fc;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
}

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

.herramientas-main .template-grid--group {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.template-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.template-groups.template-groups--flat {
  display: block;
}

.template-group {
  display: grid;
  gap: 12px;
  min-width: 0;
}

@media (max-width: 1100px) {
  .template-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .template-groups {
    grid-template-columns: 1fr;
  }
}

.template-group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.template-group-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.template-group-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.template-group-empty {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.upload-group-row.hidden {
  display: none;
}

.template-grid--group {
  margin-top: 4px;
}

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

.template-tile--ok { border-color: rgba(52, 211, 153, 0.35); }
.template-tile--missing { border-color: rgba(248, 113, 113, 0.45); }
.template-tile--info { border-color: rgba(129, 140, 248, 0.35); }

.template-preview-wrap {
  position: relative;
  aspect-ratio: 612 / 792;
  background: #e8ecf1;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}

.template-preview-wrap.is-loading::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 2px;
  background: linear-gradient(
    110deg,
    #e8ecf1 0%,
    #e8ecf1 35%,
    #f4f6f9 50%,
    #e8ecf1 65%,
    #e8ecf1 100%
  );
  background-size: 200% 100%;
  animation: template-preview-shimmer 1.1s ease-in-out infinite;
  z-index: 1;
  pointer-events: none;
}

.template-preview-wrap.is-loading .template-preview-img {
  opacity: 0;
}

.template-preview-wrap:not(.is-loading) .template-preview-img {
  opacity: 1;
  transition: opacity 0.18s ease;
}

@keyframes template-preview-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.template-preview-hit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  cursor: pointer;
  background: transparent;
  position: relative;
}

.template-preview-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  border-radius: 2px;
}

.template-preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, 0.55);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.template-preview-hit:hover .template-preview-overlay,
.template-preview-hit:focus-visible .template-preview-overlay {
  opacity: 1;
}

.template-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 8px;
  height: 100%;
  padding: 16px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}

.template-preview-placeholder svg {
  width: 28px;
  height: 28px;
  opacity: 0.55;
}

.template-tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(8, 12, 18, 0.78);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.template-tile-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
  flex: 1;
}

.template-tile-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.template-tile-name {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-tile-detail {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.template-actions-menu {
  position: relative;
  flex-shrink: 0;
}

.template-actions-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.template-actions-trigger:hover,
.template-actions-menu.is-open .template-actions-trigger {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--border);
}

.template-actions-trigger svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.template-actions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  min-width: 188px;
  padding: 6px;
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.template-actions-dropdown[hidden] {
  display: none !important;
}

.template-actions-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.template-actions-item:hover,
.template-actions-item:focus-visible {
  background: var(--surface-3);
  outline: none;
}

.template-actions-item--danger {
  color: var(--danger);
}

.template-actions-item--danger:hover,
.template-actions-item--danger:focus-visible {
  background: rgba(248, 113, 113, 0.12);
}

.template-tile.is-actions-open {
  overflow: visible;
  position: relative;
  z-index: 4;
}

.template-tile-size {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Legacy card styles (kept for older markup if any) */
.template-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.template-item--ok { border-left: 3px solid var(--success); }
.template-item--missing { border-left: 3px solid var(--danger); }
.template-item--info { border-left: 3px solid var(--accent); }

.template-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.template-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

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

.template-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.template-name {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  word-break: break-word;
}

.template-detail {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.template-meta {
  margin: 0;
  display: grid;
  gap: 8px;
}

.template-meta div {
  display: grid;
  gap: 2px;
}

.template-meta dt {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.template-meta dd {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.template-meta code {
  font-size: 11px;
  color: #cbd5e1;
}

.template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.btn--sm {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 32px;
}

.psd-layout {
  display: grid;
  gap: 20px;
}

.psd-page .templates-card {
  margin-top: 20px;
  padding: 22px;
}

.psd-variant-row {
  margin-top: 0;
}

.psd-convert-card {
  padding: 22px;
}

.psd-convert-flow {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.psd-convert-block {
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.08);
}

.psd-convert-block__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.psd-convert-block__num {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  color: #99f6e4;
  background: rgba(20, 184, 166, 0.14);
  border: 1px solid rgba(20, 184, 166, 0.28);
  flex-shrink: 0;
}

.psd-convert-block__title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.psd-convert-block__desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.psd-upload-drop {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 148px;
}

.psd-upload-drop .psd-pick-file {
  margin-top: 10px;
}

.psd-upload-drop.is-filled {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(20, 184, 166, 0.06);
}

.psd-upload-drop.is-filled .upload-drop-icon {
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
}

.psd-upload-drop.is-filled .upload-drop-title {
  color: #a7f3d0;
}

.psd-config-hint {
  margin: 10px 0 0;
}

.psd-convert-block--config .psd-variant-row {
  margin-top: 14px;
}

.psd-convert-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: linear-gradient(145deg, rgba(28, 39, 56, 0.92) 0%, rgba(21, 29, 43, 0.88) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.psd-convert-footer .upload-feedback {
  margin: 0;
  width: 100%;
}

.psd-convert-footer__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
}

@media (max-width: 639px) {
  .psd-convert-footer__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .psd-convert-footer__actions .btn {
    width: 100%;
  }
}

.psd-source-mode {
  margin-bottom: 16px;
}

.psd-results {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 16px;
}

.psd-results-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.psd-results-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #86efac;
}

.psd-results-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.psd-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.psd-template-preview {
  margin: 14px 0 4px;
  max-width: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.psd-template-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.psd-fields-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.psd-fields-form textarea {
  min-height: 88px;
  resize: vertical;
}

.template-grid--psd-preview {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.template-grid--psd-preview .template-preview-wrap {
  aspect-ratio: 612 / 792;
  min-height: 0;
  max-height: 240px;
  padding: 8px;
}

.template-grid--psd-preview.is-list-view .template-preview-wrap,
.template-groups.is-list-view .template-grid--psd-preview .template-preview-wrap {
  max-height: 150px;
}

.template-grid--psd-preview .template-preview-hit {
  display: block;
  width: 100%;
  height: 100%;
}

.template-grid--psd-preview .template-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
}

.pdf-modal,
.tcpdf-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top, 0px))
    max(1.5rem, env(safe-area-inset-right, 0px))
    max(1.5rem, env(safe-area-inset-bottom, 0px))
    max(1.5rem, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.26s ease,
    visibility 0.26s ease;
}

.tcpdf-modal {
  z-index: 210;
}

.pdf-modal.is-open,
.tcpdf-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pdf-modal.is-closing,
.tcpdf-modal.is-closing {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pdf-modal[hidden],
.pdf-modal.hidden,
.tcpdf-modal[hidden],
.tcpdf-modal.hidden {
  display: none !important;
  pointer-events: none !important;
}

.pdf-modal-backdrop,
.tcpdf-modal .pdf-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(4px);
}

.pdf-modal-panel,
.tcpdf-modal-panel,
#doc-preview-modal .doc-preview-panel {
  position: relative;
  z-index: 1;
  width: min(94vw, calc(100vw - 3rem));
  height: min(90dvh, calc(100dvh - 3rem));
  max-width: calc(100vw - 3rem);
  max-height: calc(100dvh - 3rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  transform: translateY(14px) scale(0.985);
  opacity: 0.92;
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.26s ease;
}

.pdf-modal.is-open .pdf-modal-panel,
.pdf-modal.is-open .doc-preview-panel,
.tcpdf-modal.is-open .tcpdf-modal-panel {
  transform: none;
  opacity: 1;
}

.pdf-modal.is-closing .pdf-modal-panel,
.pdf-modal.is-closing .doc-preview-panel,
.tcpdf-modal.is-closing .tcpdf-modal-panel {
  transform: translateY(10px) scale(0.99);
  opacity: 0.9;
}

.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pdf-modal-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.pdf-modal-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #1e293b;
  min-height: 0;
}

.tcpdf-modal .pdf-modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tcpdf-modal .pdf-modal-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.tcpdf-modal-eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.tcpdf-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tcpdf-tabs {
  display: flex;
  gap: 4px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.tcpdf-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tcpdf-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tcpdf-modal-body {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}

.tcpdf-modal-body:has(.tcpdf-tab-panel--preview:not([hidden])) {
  overflow: hidden;
  padding-bottom: 14px;
}

.tcpdf-tab-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.tcpdf-tab-panel[hidden] {
  display: none !important;
}

.tcpdf-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px 16px;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tcpdf-meta div {
  display: grid;
  gap: 2px;
}

.tcpdf-meta dt {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.tcpdf-meta dd {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.tcpdf-fields-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tcpdf-bindings-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.tcpdf-binding-select {
  min-width: 11rem;
  font-size: 0.85rem;
}

.tcpdf-fields-table {
  margin: 0;
  font-size: 12px;
}

.tcpdf-fields-table th,
.tcpdf-fields-table td {
  vertical-align: top;
  padding: 8px 10px;
}

.tcpdf-fields-table td:last-child {
  max-width: 280px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tcpdf-json {
  margin: 0;
  padding: 14px;
  background: #0f141c;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  flex: 1;
  min-height: 0;
  color: #cbd5e1;
}

.tcpdf-tab-panel--preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
  height: auto;
}

.tcpdf-tab-panel--preview[hidden] {
  display: none !important;
}

.tcpdf-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tcpdf-zoom-label {
  min-width: 3.5rem;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.tcpdf-zoom-hint {
  margin: 0 0 0 auto;
}

.tcpdf-preview-pager {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.tcpdf-preview-pager.hidden {
  display: none !important;
}

.tcpdf-preview-page-label {
  min-width: 8.5rem;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.tcpdf-pdf-preview {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 14px;
  background:
    linear-gradient(45deg, #dbe3ec 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #dbe3ec 25%, transparent 25%) 0 8px / 16px 16px,
    linear-gradient(45deg, transparent 75%, #dbe3ec 75%) 0 8px / 16px 16px,
    linear-gradient(-45deg, transparent 75%, #dbe3ec 75%) 0 0 / 16px 16px,
    #e8ecf1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: grab;
  outline: none;
  touch-action: none;
}

.tcpdf-pdf-preview:focus-visible {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.tcpdf-pdf-preview.is-panning {
  cursor: grabbing;
  user-select: none;
}

.tcpdf-pdf-preview-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: max-content;
  min-width: 100%;
  margin: 0 auto;
}

.tcpdf-pdf-preview img {
  display: block;
  width: var(--tcpdf-preview-width, min(100%, 720px));
  max-width: none;
  height: auto !important;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  border-radius: 2px;
  pointer-events: none;
  user-select: none;
}

.template-tile-footer--stack {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.html-template-editor {
  display: none;
}

.html-editor-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.html-editor-modal[hidden],
.html-editor-modal.hidden {
  display: none !important;
}

.html-editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
}

.html-editor-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  background: #0f172a;
  color: #e2e8f0;
}

.html-editor-topbar {
  display: grid;
  grid-template-columns: minmax(120px, 200px) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  background: #111827;
}

.html-editor-topbar-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.html-editor-eyebrow {
  margin: 0;
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.html-editor-topbar h2 {
  margin: 0;
  min-width: 0;
  font-size: 14px;
  font-weight: 650;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.html-editor-topbar-center,
.html-editor-topbar-right {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.html-editor-topbar-center {
  justify-content: flex-start;
}

.html-editor-topbar-right {
  justify-content: flex-end;
  gap: 8px;
}

.html-editor-toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 0;
}

.html-editor-topbar-sep {
  width: 1px;
  height: 22px;
  margin: 0 2px;
  background: rgba(148, 163, 184, 0.28);
  flex: 0 0 auto;
}

.html-editor-inline-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
}

.html-editor-name-input {
  width: 180px;
  max-width: 28vw;
  height: 28px;
  margin: 0;
  padding: 0 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 5px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1;
}

.html-editor-name-input:focus {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 1px;
  border-color: rgba(59, 130, 246, 0.55);
}

.html-editor-chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  margin: 0;
  padding: 0 6px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 5px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.html-editor-chip-btn:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.45);
}

.html-editor-chip-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.html-editor-chip-btn--text {
  font-size: 11px;
  font-weight: 600;
  padding: 0 8px;
}

.html-editor-chip-value {
  min-width: 52px;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: #cbd5e1;
  white-space: nowrap;
}

.html-editor-status {
  margin: 0;
  max-width: 180px;
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.html-editor-status.is-ok { color: var(--success, #22c55e); }
.html-editor-status.is-error { color: var(--danger, #ef4444); }

.html-editor-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
}

.html-editor-close-btn:hover {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.28);
  color: #f8fafc;
}

.html-editor-close-btn svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 900px) {
  .html-editor-topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "left right"
      "center center";
  }

  .html-editor-topbar-left { grid-area: left; }
  .html-editor-topbar-right { grid-area: right; }
  .html-editor-topbar-center {
    grid-area: center;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .html-editor-name-input {
    width: 140px;
    max-width: 40vw;
  }

  .html-editor-status {
    display: none;
  }
}

.html-editor-formatbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0;
  min-height: 0;
  padding: 4px 8px 2px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  background: #1e293b;
}

.html-ribbon-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 2px;
  padding: 2px 10px 3px;
  border-right: 1px solid rgba(148, 163, 184, 0.22);
}

.html-ribbon-section:last-of-type {
  border-right: 0;
}

.html-ribbon-section.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.html-ribbon-section-body {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
}

.html-ribbon-section-label {
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #94a3b8;
  user-select: none;
}

.html-ribbon-cluster {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.html-ribbon-cluster--icons {
  gap: 1px;
}

.html-ribbon-sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: rgba(148, 163, 184, 0.28);
  flex: 0 0 auto;
}

.html-ribbon-select,
.html-ribbon-input {
  height: 26px;
  margin: 0;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 4px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1;
  padding: 0 6px;
}

.html-ribbon-select:focus,
.html-ribbon-input:focus,
.html-ribbon-btn:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 1px;
}

.html-ribbon-select--font {
  width: 148px;
  max-width: 148px;
}

.html-ribbon-input--size {
  width: 52px;
  padding-right: 2px;
  text-align: center;
}

.html-ribbon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.html-ribbon-btn:hover {
  background: rgba(148, 163, 184, 0.16);
  border-color: rgba(148, 163, 184, 0.28);
}

.html-ribbon-btn--wide {
  width: auto;
  padding: 0 8px;
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.55);
  white-space: nowrap;
}

.html-visual-fmt[aria-pressed="true"],
.html-visual-align-btn.is-active {
  background: rgba(59, 130, 246, 0.28);
  color: #bfdbfe;
  border-color: rgba(59, 130, 246, 0.5);
}

.html-ribbon-color {
  position: relative;
  display: inline-flex;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: #0f172a;
}

.html-ribbon-color input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
}

.html-ribbon-color-swatch {
  pointer-events: none;
  display: block;
  width: 14px;
  height: 14px;
  margin: auto;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: var(--html-ribbon-color, #000);
}

.html-editor-body {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(260px, 300px);
  min-height: 0;
  height: 100%;
  background: #1a1a1a;
}

/* —— Photoshop moderno: barra 1 columna —— */
.ps-tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 42px;
  padding: 6px 0 8px;
  background: #383838;
  border-right: 1px solid #1f1f1f;
  overflow-x: hidden;
  overflow-y: auto;
  flex-shrink: 0;
}

.ps-tools-group {
  display: none;
}

.ps-tool {
  position: relative;
  width: 34px;
  height: 34px;
  min-height: 34px;
  flex: 0 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #e8e8e8;
  cursor: pointer;
  overflow: visible;
}

.ps-tool svg {
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

.ps-tool:hover {
  background: #4a4a4a;
}

.ps-tool.is-active {
  background: #2c2c2c;
  box-shadow: inset 0 0 0 1px #111;
  color: #fff;
}

.ps-tool.has-flyout .ps-flyout-tri {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 5px 5px;
  border-color: transparent transparent #cfcfcf transparent;
  pointer-events: none;
}

.ps-tools-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  width: 100%;
}

.ps-tool--dots {
  font-size: 14px;
  letter-spacing: 1px;
  color: #bbb;
  height: 26px;
  min-height: 26px;
}

.ps-swatches-wrap {
  position: relative;
  width: 34px;
  height: 34px;
  margin: 4px 0 2px;
}

.ps-swatch {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid #111;
  box-shadow: 0 0 0 1px #888;
  background: var(--sw, #000);
  cursor: pointer;
  padding: 0;
  border-radius: 1px;
}

.ps-swatch--fg { left: 4px; top: 4px; z-index: 2; }
.ps-swatch--bg { left: 12px; top: 12px; z-index: 1; }

.ps-swatch-reset {
  position: absolute;
  left: 1px;
  top: -2px;
  width: 10px;
  height: 10px;
  padding: 0;
  border: 1px solid #888;
  background: linear-gradient(135deg, #000 50%, #fff 50%);
  cursor: pointer;
  z-index: 3;
}

.ps-swatch-swap {
  position: absolute;
  right: 0;
  top: -4px;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #bbb;
  font-size: 10px;
  cursor: pointer;
  z-index: 3;
  line-height: 1;
}

.ps-flyout {
  position: fixed;
  z-index: 450;
  min-width: 160px;
  padding: 4px 0;
  background: #2f2f2f;
  border: 1px solid #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color: #eee;
}

.ps-flyout[hidden],
.ps-flyout.hidden {
  display: none !important;
}

.ps-flyout button {
  display: block;
  width: 100%;
  padding: 7px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
}

.ps-flyout button:hover {
  background: #46a0f5;
  color: #fff;
}

.ps-right-stack {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: #262626;
  border-left: 1px solid #1a1a1a;
  color: #ddd;
}

.ps-panel-tabs {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid #1a1a1a;
  background: #2b2b2b;
}

.ps-panel-tab {
  flex: 1;
  height: 28px;
  border: 0;
  background: transparent;
  color: #999;
  font-size: 11px;
  cursor: default;
}

.ps-panel-tab.is-active {
  color: #fff;
  background: #323232;
  box-shadow: inset 0 -2px 0 #46a0f5;
}

.ps-panel-tab:disabled {
  opacity: 0.45;
  cursor: default;
}

.ps-props {
  display: flex;
  flex-direction: column;
  flex: 0 0 42%;
  min-height: 140px;
  max-height: 48%;
  border-bottom: 1px solid #1a1a1a;
}

.ps-props-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 10px;
  font-size: 11px;
  display: grid;
  gap: 6px;
  align-content: start;
}

.ps-props-empty {
  margin: 8px 0;
  color: #999;
  line-height: 1.4;
}

.ps-props-section-title {
  margin: 4px 0 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9ab;
}

.ps-prop-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.ps-prop-row input,
.ps-prop-row select {
  height: 24px;
  width: 100%;
  border: 1px solid #555;
  border-radius: 2px;
  background: #1f1f1f;
  color: #eee;
  padding: 0 6px;
  font-size: 11px;
}

.ps-prop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.ps-prop-actions button {
  height: 24px;
  padding: 0 8px;
  border: 1px solid #555;
  border-radius: 2px;
  background: #3a3a3a;
  color: #eee;
  font-size: 10px;
  cursor: pointer;
}

.ps-prop-actions button:hover {
  background: #4a4a4a;
}

.ps-prop-actions button.is-danger {
  color: #fca5a5;
}

.ps-layers {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background: #262626;
  color: #ddd;
}

.ps-layers-tabs {
  display: none;
}

.ps-layers-filters {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 8px;
  flex-shrink: 0;
}

.ps-filter-ico {
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid #3a3a3a;
  border-radius: 2px;
  background: #1f1f1f;
  color: #bbb;
  font-size: 11px;
  cursor: pointer;
  line-height: 1;
}

.ps-filter-ico.is-active {
  background: #3a5f8a;
  color: #fff;
  border-color: #4a7aaa;
}

.ps-layers-search {
  flex: 1;
  min-width: 0;
  height: 22px;
  margin-left: 4px;
  border: 1px solid #444;
  border-radius: 2px;
  background: #1a1a1a;
  color: #ddd;
  padding: 0 6px;
  font-size: 11px;
}

.ps-layers-blend,
.ps-layers-locks {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 6px;
  font-size: 11px;
  color: #aaa;
  flex-shrink: 0;
}

.ps-layers-blend select {
  flex: 1;
  min-width: 0;
  height: 22px;
  border: 1px solid #444;
  background: #1f1f1f;
  color: #ddd;
  font-size: 11px;
}

.ps-opacity-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.ps-opacity-label input {
  width: 44px;
  height: 22px;
  border: 1px solid #444;
  background: #1f1f1f;
  color: #ddd;
  padding: 0 4px;
  font-size: 11px;
}

.ps-lock-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #444;
  border-radius: 2px;
  background: #1f1f1f;
  color: #bbb;
  cursor: pointer;
  font-size: 10px;
}

.ps-lock-btn.is-on {
  background: #3a5f8a;
  color: #fff;
}

.ps-chip {
  height: 22px;
  padding: 0 7px;
  border: 1px solid #3a3a3a;
  border-radius: 3px;
  background: #1f1f1f;
  color: #bbb;
  font-size: 10px;
  cursor: pointer;
}

.ps-chip.is-active {
  background: #3a3a3a;
  color: #fff;
  border-color: #555;
}

.ps-layers-opacity {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 6px;
  font-size: 11px;
  color: #aaa;
}

.ps-layers-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 0;
  background: #1e1e1e;
}

.ps-layer-row {
  display: grid;
  grid-template-columns: 22px 22px 34px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 3px 6px;
  border: 0;
  border-bottom: 1px solid #2a2a2a;
  background: transparent;
  color: #ddd;
  text-align: left;
  cursor: pointer;
}

.ps-layer-row:hover {
  background: #2c2c2c;
}

.ps-layer-row.is-selected {
  background: #3a5f8a;
  color: #fff;
}

.ps-layer-row.is-hidden {
  opacity: 0.45;
}

.ps-layer-eye,
.ps-layer-lock {
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.ps-layer-thumb {
  width: 32px;
  height: 28px;
  border: 1px solid #444;
  background:
    linear-gradient(45deg, #333 25%, transparent 25%),
    linear-gradient(-45deg, #333 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #333 75%),
    linear-gradient(-45deg, transparent 75%, #333 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  background-color: #222;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #9cf;
  overflow: hidden;
}

.ps-layer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ps-layer-meta {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.ps-layer-name {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ps-layer-type {
  font-size: 9px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ps-layers-footer {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-top: 1px solid #1a1a1a;
  background: #2b2b2b;
  flex-shrink: 0;
}

.ps-layers-foot-btn {
  flex: 1;
  height: 26px;
  border: 1px solid #3a3a3a;
  border-radius: 3px;
  background: #333;
  color: #ddd;
  font-size: 10px;
  cursor: pointer;
}

.ps-layers-foot-btn:hover {
  background: #404040;
}

.ps-context-menu {
  position: fixed;
  z-index: 400;
  min-width: 210px;
  padding: 4px 0;
  background: #2f2f2f;
  border: 1px solid #111;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  color: #eee;
}

.ps-context-menu[hidden],
.ps-context-menu.hidden {
  display: none !important;
}

.ps-context-menu button {
  display: block;
  width: 100%;
  padding: 7px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
}

.ps-context-menu button:hover {
  background: #46a0f5;
  color: #fff;
}

.ps-context-menu button.is-danger {
  color: #fca5a5;
}

.ps-context-menu hr {
  border: 0;
  border-top: 1px solid #444;
  margin: 4px 0;
}

.html-editor-canvas-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  background: #525252;
}

.ps-float-panel {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 20;
  width: 220px;
  background: rgba(40, 40, 40, 0.96);
  border: 1px solid #111;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  color: #eee;
}

.ps-float-panel[hidden],
.ps-float-panel.hidden {
  display: none !important;
}

.ps-float-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: #333;
  font-size: 11px;
  font-weight: 600;
}

.ps-float-close {
  border: 0;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.ps-float-panel-body {
  padding: 8px;
  display: grid;
  gap: 6px;
  font-size: 11px;
}

.ps-float-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 6px;
  align-items: center;
}

.ps-float-row input,
.ps-float-row select {
  height: 24px;
  border: 1px solid #555;
  border-radius: 3px;
  background: #1f1f1f;
  color: #eee;
  padding: 0 6px;
}

.ps-float-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ps-float-actions button {
  height: 24px;
  padding: 0 8px;
  border: 1px solid #555;
  border-radius: 3px;
  background: #3a3a3a;
  color: #eee;
  font-size: 10px;
  cursor: pointer;
}

@media (max-width: 960px) {
  .html-editor-body {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .ps-right-stack {
    display: none;
  }
}

.html-editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  background: #111827;
  border-color: rgba(148, 163, 184, 0.2);
  border-style: solid;
  border-width: 0;
}

.html-editor-sidebar--left {
  align-items: center;
  padding: 10px 8px;
  border-right-width: 1px;
}

.html-editor-sidebar--right {
  padding: 10px;
  border-left-width: 1px;
}

.html-editor-side-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #94a3b8;
}

.html-editor-side-hint {
  margin: 8px 0 0;
  font-size: 11px;
  text-align: center;
  color: #64748b;
}

.html-editor-tool {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  cursor: pointer;
}

.html-editor-tool.is-active,
.html-editor-tool:hover {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.16);
}

.html-editor-tool:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.html-editor-tool-sep {
  width: 28px;
  height: 1px;
  margin: 4px 0;
  background: rgba(148, 163, 184, 0.28);
}

.html-visual-canvas-wrap.is-guide-h,
.html-visual-canvas-wrap.is-guide-h * {
  cursor: crosshair !important;
}

.html-visual-canvas-wrap.is-guide-v,
.html-visual-canvas-wrap.is-guide-v * {
  cursor: crosshair !important;
}

.html-visual-guides {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}

.html-visual-guide {
  position: absolute;
  pointer-events: auto;
  background: rgba(56, 189, 248, 0.95);
  box-shadow: 0 0 0 0.5px rgba(14, 165, 233, 0.35);
}

.html-visual-guide.is-h {
  left: 0;
  right: 0;
  height: 1px;
  cursor: ns-resize;
  transform: translateY(-0.5px);
}

.html-visual-guide.is-v {
  top: 0;
  bottom: 0;
  width: 1px;
  cursor: ew-resize;
  transform: translateX(-0.5px);
}

.html-visual-guide.is-h::before,
.html-visual-guide.is-v::before {
  content: "";
  position: absolute;
  background: transparent;
}

.html-visual-guide.is-h::before {
  left: 0;
  right: 0;
  top: -4px;
  height: 9px;
}

.html-visual-guide.is-v::before {
  top: 0;
  bottom: 0;
  left: -4px;
  width: 9px;
}

.html-visual-guide.is-selected {
  background: #f472b6;
  box-shadow: 0 0 0 1px rgba(244, 114, 182, 0.45);
}

.html-visual-guide.is-h.is-selected {
  height: 2px;
}

.html-visual-guide.is-v.is-selected {
  width: 2px;
}

.html-editor-layers-head {
  display: grid;
  gap: 8px;
}

.html-editor-layer-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.html-editor-layer-filters .is-active {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.html-editor-layers-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  min-height: 0;
  flex: 1;
  padding-right: 2px;
}

.html-editor-layer-item {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  cursor: pointer;
}

.html-editor-layer-item:hover,
.html-editor-layer-item.is-selected {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(59, 130, 246, 0.14);
}

.html-editor-layer-item.kind-image.is-selected {
  border-color: rgba(52, 211, 153, 0.6);
  background: rgba(16, 185, 129, 0.14);
}

.html-editor-layer-item.kind-dynamic.is-selected {
  border-color: rgba(251, 191, 36, 0.65);
  background: rgba(245, 158, 11, 0.12);
}

.html-editor-layer-kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.html-editor-layer-name {
  font-size: 12px;
  line-height: 1.3;
  word-break: break-word;
}

.html-editor-canvas-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
}

.html-visual-canvas-wrap {
  position: relative;
  overflow: auto;
  flex: 1;
  min-height: 0;
  background:
    linear-gradient(45deg, rgba(148, 163, 184, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.08) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #0b1220;
  padding: 18px;
}

.html-visual-stage {
  position: relative;
  margin: 0 auto;
}

.html-visual-page {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  background: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.html-visual-page.is-chrome-selected {
  outline: 2px dashed #34d399;
  outline-offset: 3px;
}

.html-editor-layer-item.kind-chrome.is-selected {
  border-color: rgba(52, 211, 153, 0.7);
  background: rgba(16, 185, 129, 0.16);
}

.html-visual-item.is-hidden-layer {
  background: transparent !important;
  border: none;
  outline: 1px dashed rgba(99, 102, 241, 0.85);
  box-shadow: none;
  cursor: pointer;
  z-index: 8;
}

.html-visual-item.is-hidden-layer.is-selected {
  outline-color: var(--accent);
  outline-style: solid;
}

.html-visual-item.is-layer-cover {
  /* legacy: ya no se usa parche blanco al ocultar */
  display: none !important;
}

.html-visual-cover-label {
  display: none !important;
}

.html-visual-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

.html-visual-layer {
  position: absolute;
  inset: 0;
}

.html-visual-item {
  position: absolute;
  margin: 0;
  padding: 0;
  border: none;
  outline: 2px solid transparent;
  outline-offset: 0;
  background: transparent;
  cursor: move;
  overflow: visible;
  box-sizing: border-box;
  user-select: none;
}

.html-visual-item:hover {
  outline-color: rgba(96, 165, 250, 0.55);
  background: rgba(59, 130, 246, 0.08);
}

.html-visual-item.is-image:hover {
  outline-color: rgba(52, 211, 153, 0.65);
  background: rgba(16, 185, 129, 0.1);
}

.html-visual-item.is-dynamic:hover {
  outline-style: dashed;
  outline-color: rgba(251, 191, 36, 0.7);
  background: rgba(245, 158, 11, 0.1);
}

.html-visual-item.is-selected {
  outline-color: #60a5fa;
  outline-style: solid;
  background: rgba(59, 130, 246, 0.1);
  z-index: 6;
}

.html-visual-item.is-image.is-selected {
  outline-color: #34d399;
  background: rgba(16, 185, 129, 0.12);
}

.html-visual-item.is-logo-frame {
  outline: 2px dashed rgba(14, 165, 233, 0.95);
  background: rgba(14, 165, 233, 0.08);
  z-index: 7;
}

.html-visual-item.is-logo-frame.is-selected {
  outline-style: solid;
  outline-color: #0ea5e9;
  background: rgba(14, 165, 233, 0.14);
}

.html-visual-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  display: block;
}

.html-visual-logo-badge {
  position: absolute;
  top: -1px;
  left: -1px;
  z-index: 2;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: #0ea5e9;
  pointer-events: none;
}

.html-visual-item.is-dynamic.is-selected {
  outline-style: dashed;
  outline-color: #fbbf24;
}

.html-visual-item.is-editing {
  outline-color: #34d399;
  outline-style: solid;
  cursor: text;
  z-index: 8;
  background: #fff;
}

.html-visual-item-hit {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.html-visual-item-img {
  display: none;
}

/* Assets de plantilla (p.ej. ad_promo CFE): visibles con el tamaño del recuadro */
.html-visual-item.is-image:not(.is-chrome) .html-visual-item-img.html-visual-asset-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: left top;
  pointer-events: none;
  user-select: none;
}

.html-visual-item.is-image.is-logo-frame .html-visual-item-img.html-visual-logo-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  object-position: left top;
  pointer-events: none;
  user-select: none;
}

.html-visual-item.is-text .html-visual-item-hit,
.html-visual-item.is-dynamic .html-visual-item-hit {
  display: block;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.html-visual-item-text {
  width: 100%;
  height: 100%;
  overflow: auto;
  line-height: 1.2;
  padding: 2px 4px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
}

.html-visual-item.is-editing .html-visual-item-text {
  overflow: auto;
  background: #fff;
}

.html-visual-handle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: #3b82f6;
  border: 1px solid #fff;
  display: none;
  z-index: 9;
  box-shadow: 0 0 0 0.5px rgba(15, 23, 42, 0.35);
}

.html-visual-item.is-selected .html-visual-handle {
  display: block;
}

.html-visual-handle[data-resize="nw"] { left: -4px; top: -4px; cursor: nwse-resize; }
.html-visual-handle[data-resize="ne"] { right: -4px; top: -4px; cursor: nesw-resize; }
.html-visual-handle[data-resize="sw"] { left: -4px; bottom: -4px; cursor: nesw-resize; }
.html-visual-handle[data-resize="se"] { right: -4px; bottom: -4px; cursor: nwse-resize; }

.html-visual-item.is-shape {
  background: transparent;
}

.html-visual-canvas-wrap.is-hand,
.html-visual-canvas-wrap.is-hand * {
  cursor: grab !important;
}

.html-visual-canvas-wrap.is-hand.is-panning,
.html-visual-canvas-wrap.is-hand.is-panning * {
  cursor: grabbing !important;
}

.html-visual-canvas-wrap.is-eyedropper,
.html-visual-canvas-wrap.is-eyedropper * {
  cursor: crosshair !important;
}

.html-visual-canvas-wrap.is-place-tool,
.html-visual-canvas-wrap.is-place-tool * {
  cursor: crosshair !important;
}

.html-editor-layers-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.html-editor-layers-actions {
  display: inline-flex;
  gap: 4px;
}

.html-editor-layer-act {
  height: 22px;
  padding: 0 6px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 4px;
  background: #0f172a;
  color: #cbd5e1;
  font-size: 10px;
  cursor: pointer;
}

.html-editor-layer-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  background: #0f172a;
  color: #e2e8f0;
  cursor: pointer;
}

.html-editor-layer-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.12);
  font-size: 11px;
  color: #93c5fd;
}

.html-editor-layer-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.html-ribbon-prop {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #94a3b8;
}

.html-ribbon-input--coord {
  width: 58px;
}

.html-editor-layer-item.kind-shape.is-selected {
  border-color: rgba(167, 139, 250, 0.65);
  background: rgba(139, 92, 246, 0.14);
}

.html-editor-statusbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 6px 14px;
  font-size: 11px;
  color: #94a3b8;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  background: #111827;
}

#html-edit-status.is-ok { color: var(--success, #22c55e); }
#html-edit-status.is-error { color: var(--danger, #ef4444); }

@media (max-width: 960px) {
  .html-editor-topbar {
    grid-template-columns: 1fr;
  }

  .html-editor-body {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .ps-right-stack {
    display: none;
  }
}

.psd-compare-panel {
  width: min(1280px, 98vw);
  height: min(92vh, 960px);
}

.psd-compare-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.psd-compare-score {
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.psd-compare-score.is-good {
  color: #059669;
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.08);
}

.psd-compare-score.is-warn {
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.35);
  background: rgba(217, 119, 6, 0.08);
}

.psd-compare-score.is-bad {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.08);
}

.psd-compare-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

.psd-compare-form-toggle,
.psd-compare-slider-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.psd-compare-slider-label input[type="range"] {
  width: 140px;
}

.psd-compare-body {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 18px;
  background: #e8ecf1;
}

.psd-compare-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.psd-compare-pane {
  margin: 0;
  display: grid;
  gap: 8px;
}

.psd-compare-pane figcaption {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.psd-compare-pane img,
.psd-compare-overlay img {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.psd-compare-overlay {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}

.psd-compare-overlay img {
  width: 100%;
}

.psd-compare-overlay #psd-compare-overlay-top {
  position: absolute;
  inset: 0;
  object-fit: contain;
  object-position: top center;
}

@media (max-width: 860px) {
  .psd-compare-split {
    grid-template-columns: 1fr;
  }
}


/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1200px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

/* Formulario denso: compactar cuando el panel es angosto, sin forzar filas completas */
@media (max-width: 920px) {
  .field-grid--dense .span-10,
  .field-grid--dense .span-9,
  .field-grid--dense .span-8,
  .field-grid--dense .span-7 {
    grid-column: span 12;
  }

  .field-grid--dense .span-6,
  .field-grid--dense .span-5 {
    grid-column: span 6;
  }

  .field-grid--dense .span-4,
  .field-grid--dense .span-3 {
    grid-column: span 6;
  }

  .field-grid--dense .span-2 {
    grid-column: span 4;
  }
}

@media (max-width: 1024px) {
  .content-grid { grid-template-columns: 1fr; }
  .field-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field--wide { grid-column: span 2; }
}

@media (max-width: 768px) {
  :root { --header-h: 56px; --footer-h: 44px; }

  .main-wrapper { margin-left: 0; width: 100%; }

  .page-footer { left: 0; padding: 0 16px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
    pointer-events: auto;
  }

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

  .app-shell.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
  }

  /* En móvil: hamburguesa; ignora preferencia de colapso de escritorio */
  html.sidebar-pref-collapsed .sidebar,
  .app-shell.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  html.sidebar-pref-collapsed .app-shell.sidebar-open .sidebar,
  .app-shell.sidebar-collapsed.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle__icon--panel { display: none; }
  .sidebar-toggle__icon--menu { display: block; }

  .app-shell.sidebar-collapsed .sidebar-toggle,
  html.sidebar-pref-collapsed .sidebar-toggle {
    color: var(--text-muted);
    background: var(--surface-2);
    border-color: var(--border);
  }

  .app-shell.sidebar-open .sidebar-toggle {
    color: #93c5fd;
    background: var(--accent-soft);
    border-color: rgba(59, 130, 246, 0.28);
  }

  .top-header { padding: 0 16px; }

  .page-content { padding: 16px; padding-bottom: calc(16px + var(--footer-h)); }

  .field-grid--2,
  .field-grid--3,
  .field-grid--dense { grid-template-columns: 1fr; }

  .field-grid--dense > [class*="span-"] {
    grid-column: span 1;
  }

  .field--wide { grid-column: span 1; }

  .card { padding: 18px; }

  .actions .btn { flex: 1 1 calc(50% - 5px); min-width: 140px; }

  .header-title { font-size: 1rem; }
}

@media (max-width: 480px) {
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; flex: none; }

  .health-badge { font-size: 11px; padding: 5px 10px; }
}

@media (min-width: 769px) {
  .sidebar-backdrop { display: none !important; }
}

/* --------------------------------------------------------------------------
   Clientes
   -------------------------------------------------------------------------- */

.card-header--row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

.clients-lists {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.clients-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.85rem;
}

.clients-section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.clients-section-desc {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.clients-section-count {
  flex-shrink: 0;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.clients-section-empty {
  padding: 0.85rem 0.2rem 0.35rem;
  font-size: 0.92rem;
}

.clients-name {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.clients-meta-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.clients-meta-badge--web {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.28);
}

.clients-meta-badge--system {
  background: rgba(167, 139, 250, 0.12);
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.28);
}

.clients-meta-badge--ok {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.28);
}

.clients-meta-badge--pending {
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.28);
}

.clients-toast-host {
  position: fixed;
  top: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  width: min(420px, calc(100% - 1.5rem));
}

.clients-toast {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  background: rgba(15, 23, 32, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #e8eef7;
  font-size: 0.92rem;
  line-height: 1.35;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}

.clients-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.clients-toast--ok {
  border-color: rgba(16, 185, 129, 0.45);
}

.clients-toast--error {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.clients-code-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  letter-spacing: 0.06em;
}

.clients-code-td--copy {
  cursor: pointer;
}

.clients-code-cell--active {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm, 6px);
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.28);
  cursor: pointer;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  letter-spacing: 0.06em;
  user-select: none;
}

.clients-code-cell--active:hover {
  background: rgba(16, 185, 129, 0.2);
}

.clients-code-cell--active.is-copied {
  background: rgba(16, 185, 129, 0.28);
  border-color: rgba(16, 185, 129, 0.55);
  color: #a7f3d0;
}

.clients-code-cell--used {
  color: #fbbf24;
  letter-spacing: normal;
  font-family: inherit;
}

.clients-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.clients-action-wrap {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.clients-action-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  padding: 1px 6px;
  border-radius: 999px;
  background: #059669;
  color: #ecfdf5;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--surface, #121820);
}

.clients-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.clients-icon-btn.is-disabled,
.clients-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.clients-icon-btn svg {
  width: 18px;
  height: 18px;
}

.clients-icon-btn:hover {
  background: var(--surface-3);
}

.clients-icon-btn--success {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.1);
}

.clients-icon-btn--success:hover {
  background: rgba(34, 197, 94, 0.18);
}

.clients-icon-btn--danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.28);
  background: rgba(248, 113, 113, 0.1);
}

.clients-icon-btn--danger:hover {
  background: rgba(248, 113, 113, 0.18);
}

.clients-table td:last-child {
  white-space: nowrap;
}

.clients-table.data-table {
  table-layout: auto;
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
}

.clients-table.data-table th,
.clients-table.data-table td {
  box-sizing: border-box;
  vertical-align: middle;
  text-align: left;
  overflow-wrap: normal;
  word-break: normal;
  padding: 10px 14px;
  white-space: nowrap;
}

.clients-table .clients-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 16rem;
}

/* Formularios web: anchos equilibrados + separación, sin huecos enormes */
.clients-table--web.data-table {
  table-layout: fixed;
  width: 100%;
}

.clients-table--web.data-table th,
.clients-table--web.data-table td {
  padding: 8px 8px;
  overflow: visible;
  white-space: nowrap;
}

/* Reparto proporcional: se reajusta con el sidebar, sin sobrante solo en Acciones */
.clients-table--web col.col-cliente { width: 13%; }
.clients-table--web col.col-fecha { width: 11%; }
.clients-table--web col.col-visto { width: 10%; }
.clients-table--web col.col-cita { width: 12%; }
.clients-table--web col.col-codigo { width: 8%; }
.clients-table--web col.col-pdfs { width: 9%; }
.clients-table--web col.col-estado { width: 11%; }
.clients-table--web col.col-acciones { width: 26%; }

.clients-table--web.data-table th:first-child,
.clients-table--web.data-table td:first-child {
  overflow: visible;
}

.clients-table--web .clients-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clients-table--web td:first-child .muted {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clients-table--web.data-table th.clients-actions-col,
.clients-table--web.data-table td.clients-actions-cell {
  width: auto;
  overflow: visible;
  padding-left: 2px;
  padding-right: 8px;
}

.clients-table--web .clients-actions-cell .clients-actions {
  justify-content: flex-start;
  gap: 6px;
}

.clients-table--web.data-table td.clients-code-td,
.clients-table--web.data-table .clients-code-cell,
.clients-table--web.data-table .clients-code-cell--active {
  overflow: visible;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

/* Menos espacio entre Código y PDFs */
.clients-table--web.data-table th:nth-child(5),
.clients-table--web.data-table td:nth-child(5) {
  padding-right: 2px;
}

.clients-table--web.data-table th:nth-child(6),
.clients-table--web.data-table td:nth-child(6) {
  padding-left: 2px;
}

/* Menos espacio entre Estado y Acciones */
.clients-table--web.data-table th:nth-child(7),
.clients-table--web.data-table td:nth-child(7) {
  padding-right: 2px;
}

.clients-table--web.data-table th:nth-child(8),
.clients-table--web.data-table td:nth-child(8),
.clients-table--web.data-table th.clients-actions-col,
.clients-table--web.data-table td.clients-actions-cell {
  padding-left: 2px;
}

#clients-web-wrap.table-wrap {
  overflow-x: auto;
}

/* Clientes del sistema: layout que ya estaba bien (no tocar) */
.clients-table--system.data-table {
  table-layout: fixed;
}

.clients-table--system.data-table th,
.clients-table--system.data-table td {
  padding: 12px 18px;
}

.clients-table--system .clients-name {
  max-width: 100%;
}

.clients-table--system col.col-cliente { width: 20%; }
.clients-table--system col.col-fecha { width: 12%; }
.clients-table--system col.col-cita { width: 14%; }
.clients-table--system col.col-pdfs { width: 13%; }
.clients-table--system col.col-estado { width: 18%; }
.clients-table--system col.col-acciones { width: 23%; }

.clients-table--system td:nth-child(5) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.clients-table tbody tr.clients-row--visa-soon {
  background: rgba(248, 113, 113, 0.14);
}

.clients-table tbody tr.clients-row--visa-soon:hover {
  background: rgba(248, 113, 113, 0.2);
}

.clients-visa-date--soon {
  color: #f87171;
  font-weight: 600;
}

.clients-table th.clients-actions-col,
.clients-table td.clients-actions-cell {
  width: 1%;
  white-space: nowrap;
  text-align: left;
  /* Espacio vertical para badges Listo */
  padding-top: 1.05rem;
  padding-bottom: 0.55rem;
}

.clients-table--system th.clients-actions-col,
.clients-table--system td.clients-actions-cell {
  width: auto;
}

.clients-table thead th {
  padding-top: 10px;
  padding-bottom: 10px;
}

.clients-table thead th.clients-actions-col {
  padding-top: 10px;
  padding-bottom: 10px;
}

.clients-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.clients-actions-cell .clients-actions {
  margin: 0;
}

.clients-action-wrap {
  flex-shrink: 0;
}

/* Action sheet (móvil) */
.clients-sheet {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
}

.clients-sheet[hidden] {
  display: none !important;
}

.clients-sheet.is-open {
  pointer-events: auto;
}

.clients-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.62);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.clients-sheet.is-open .clients-sheet-backdrop {
  opacity: 1;
}

.clients-sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(78vh, 520px);
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.clients-sheet.is-open .clients-sheet-panel {
  transform: translateY(0);
}

.clients-sheet-handle {
  width: 36px;
  height: 4px;
  margin: 2px auto 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
}

.clients-sheet-header {
  padding: 0 4px 4px;
}

.clients-sheet-eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clients-sheet-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.clients-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clients-sheet-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.clients-sheet-btn:active {
  background: var(--surface-3);
}

.clients-sheet-btn-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.clients-sheet-btn-icon svg {
  width: 18px;
  height: 18px;
}

.clients-sheet-btn--success {
  color: #86efac;
}

.clients-sheet-btn--success .clients-sheet-btn-icon {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.1);
}

.clients-sheet-btn--danger {
  color: #fca5a5;
}

.clients-sheet-btn--danger .clients-sheet-btn-icon {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.28);
  background: rgba(248, 113, 113, 0.1);
}

.clients-sheet-cancel {
  width: 100%;
  margin-top: 2px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.clients-sheet-cancel:active {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.clients-sheet-btn-label {
  flex: 1;
  min-width: 0;
}

body.clients-sheet-open {
  overflow: hidden;
}

.clients-docs-modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: none;
  width: min(1120px, 96vw);
}

.clients-docs-modal::backdrop {
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(4px);
}

.clients-process-modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: none;
  width: min(560px, 94vw);
}

.clients-process-modal::backdrop {
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(4px);
}

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

.clients-process-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.clients-process-eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clients-process-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.clients-process-desc {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.clients-process-form {
  padding: 18px 20px 20px;
}

.clients-process-missing {
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem 0.7rem 1.4rem;
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.28);
  color: #fcd34d;
  font-size: 0.88rem;
}

.clients-process-missing li + li {
  margin-top: 0.25rem;
}

.clients-process-error {
  margin: 0.75rem 0 0;
  color: #fca5a5;
  font-size: 0.9rem;
}

.clients-process-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 1.1rem;
}

.clients-generate-modal {
  padding: 0;
  border: none;
  background: transparent;
  max-width: none;
  width: min(480px, 94vw);
}

.clients-generate-modal::backdrop {
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(4px);
}

.clients-generate-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 18px 20px 20px;
}

.clients-generate-header {
  margin-bottom: 14px;
}

.clients-generate-eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clients-generate-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.clients-generate-desc {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.clients-generate-panel .generate-progress {
  margin-top: 0;
}

.clients-generate-error {
  margin: 0.85rem 0 0;
  color: #fca5a5;
  font-size: 0.9rem;
}

.clients-generate-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 1.1rem;
}

.clients-confirm-modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: none;
  width: min(420px, 92vw);
}

.clients-confirm-modal::backdrop {
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(4px);
}

.clients-confirm-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 20px 22px 18px;
}

.clients-confirm-eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clients-confirm-header h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.clients-confirm-desc {
  margin: 0.55rem 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.clients-confirm-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 1.25rem;
}

.clients-dl-menu {
  position: fixed;
  z-index: 80;
  min-width: 200px;
  padding: 6px;
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.clients-dl-menu[hidden] {
  display: none;
}

.clients-dl-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.clients-dl-menu-item:hover {
  background: var(--surface-3);
}

.clients-dl-menu-item--danger {
  color: #fca5a5;
}

.clients-dl-menu-item--danger:hover {
  background: rgba(248, 113, 113, 0.12);
}

.clients-dl-menu-item--whatsapp {
  color: #86efac;
}

.clients-dl-menu-item--whatsapp:hover {
  background: rgba(34, 197, 94, 0.12);
}

.clients-dl-menu-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.clients-dl-menu-icon svg {
  width: 18px;
  height: 18px;
}

.clients-docs-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: min(88vh, 900px);
  max-height: min(88vh, 900px);
}

.clients-docs-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.clients-docs-eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.clients-docs-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.clients-docs-body {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.clients-docs-list-wrap {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
  background: var(--surface-2);
}

.clients-docs-list {
  list-style: none;
  margin: 0;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.clients-docs-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.clients-docs-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.clients-docs-group-toggle:hover {
  background: rgba(255, 255, 255, 0.04);
}

.clients-docs-group-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.clients-docs-group-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 7px;
  min-width: 20px;
  text-align: center;
}

.clients-docs-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.clients-docs-group.is-expanded .clients-docs-chevron {
  transform: rotate(180deg);
}

.clients-docs-group-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}

.clients-docs-group.is-expanded .clients-docs-group-panel {
  grid-template-rows: 1fr;
}

.clients-docs-group-panel-inner {
  overflow: hidden;
  min-height: 0;
}

.clients-docs-group-list {
  list-style: none;
  margin: 0;
  padding: 0 6px 6px;
  display: grid;
  gap: 4px;
}

.clients-doc-item {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
}

.clients-doc-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.clients-doc-item.is-active {
  border-color: var(--border);
  background: var(--surface-2);
}

.clients-doc-label {
  font-size: 13px;
  line-height: 1.35;
}

.clients-docs-viewer {
  position: relative;
  background: #0b1220;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.clients-docs-viewer iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #111;
}

.clients-docs-viewer-empty,
.clients-docs-empty-item {
  color: var(--text-muted);
  font-size: 14px;
}

.clients-docs-viewer-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.clients-docs-viewer-empty.hidden {
  display: none;
}

@media (max-width: 800px) {
  .clients-docs-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .clients-docs-list-wrap {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 180px;
    flex-shrink: 0;
  }
}

@media (max-width: 768px) {
  .clients-table.data-table {
    min-width: 0;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0 8px;
  }

  .clients-table th:first-child,
  .clients-table td:first-child,
  .clients-table th:not(:first-child),
  .clients-table td:not(:first-child),
  .clients-table th.clients-actions-col,
  .clients-table td.clients-actions-cell {
    width: auto;
    max-width: none;
    text-align: left;
    white-space: normal;
    padding-top: 14px;
    padding-bottom: 14px;
  }

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

  .clients-table thead {
    display: none;
  }

  .clients-table thead th:nth-child(4),
  .clients-table--system .clients-actions-cell,
  .clients-table--system tbody td:last-child {
    display: none;
  }

  .clients-table--web .clients-actions-cell,
  .clients-table--web tbody td:last-child {
    display: table-cell;
  }

  .clients-table tbody tr.clients-row {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: background var(--transition), border-color var(--transition);
  }

  .clients-table tbody tr.clients-row--visa-soon {
    background: rgba(248, 113, 113, 0.16);
    border-color: rgba(248, 113, 113, 0.38);
  }

  .clients-table tbody tr.clients-row:active {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.28);
  }

  .clients-table tbody tr.clients-row--visa-soon:active {
    background: rgba(248, 113, 113, 0.24);
    border-color: rgba(248, 113, 113, 0.45);
  }

  .clients-table tbody tr.clients-row td {
    border-bottom: none;
  }

  .clients-table tbody tr.clients-row td:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  }

  .clients-table--system tbody tr.clients-row td:nth-last-child(2) {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  }

  .clients-table--web tbody tr.clients-row td:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  }

  .clients-table th,
  .clients-table td {
    padding: 14px 12px;
    vertical-align: middle;
  }

  .clients-table td:nth-child(2),
  .clients-table td:nth-child(3) {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
  }

  #clients-web-wrap.table-wrap,
  #clients-system-wrap.table-wrap {
    border: none;
    background: transparent;
  }
}

.edo-header-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  max-height: calc(var(--header-h) - 16px);
}

.edo-header-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 58px;
  height: 44px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  line-height: 1.1;
}

.edo-header-stat-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.edo-header-stat-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.edo-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edo-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  max-height: calc(var(--header-h) - 16px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.edo-refresh-btn svg {
  width: 20px;
  height: 20px;
}

.edo-refresh-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
  color: var(--accent);
}

.edo-import-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  max-height: calc(var(--header-h) - 16px);
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.edo-import-btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}

.edo-import-btn:disabled {
  cursor: wait;
  opacity: 0.85;
}

.edo-import-btn__media {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: #e8ecf1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.edo-import-btn__media svg {
  width: 18px;
  height: 18px;
  color: #64748b;
}

.edo-import-btn__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.edo-import-btn__cover.hidden,
.edo-import-btn__icon.hidden,
.edo-import-btn__spinner.hidden {
  display: none !important;
}

.edo-import-btn__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(100, 116, 139, 0.25);
  border-top-color: #0d9488;
  border-radius: 50%;
  animation: edo-spin 0.7s linear infinite;
}

.edo-import-btn__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  text-align: left;
  line-height: 1.15;
}

.edo-import-btn__text strong {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.edo-import-btn__text small {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edo-import-btn.is-loading .edo-import-btn__text small,
.edo-import-btn.is-importing .edo-import-btn__text small {
  color: #5eead4;
}

.edo-import-btn.is-ready {
  border-color: rgba(45, 212, 191, 0.35);
}

.edo-import-btn.is-done .edo-import-btn__text small {
  color: #86efac;
}

.edo-import-btn__ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(#2dd4bf calc(var(--edo-progress, 0) * 1%), rgba(15, 23, 42, 0.15) 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  pointer-events: none;
  opacity: 0;
}

.edo-import-btn.is-loading .edo-import-btn__ring,
.edo-import-btn.is-importing .edo-import-btn__ring {
  opacity: 1;
}

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

.page-content:has(.edo-page) {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h));
  max-height: calc(100vh - var(--header-h));
  overflow: hidden;
  padding-top: 12px;
  padding-bottom: calc(12px + var(--footer-h));
}

#view-root:has(.edo-page) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.edo-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.edo-conceptos-table-card {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.edo-conceptos-table-card > .edo-concepts-filters,
.edo-conceptos-table-card > .edo-concepts-pagination,
.edo-conceptos-table-card > #edo-upload-result {
  flex: 0 0 auto;
}

.edo-concepts-table-viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.edo-concepts-table-viewport .table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
}

.edo-sources-card {
  flex: 0 0 auto;
  height: min(280px, 34vh);
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.edo-sources-card > .card-header {
  flex: 0 0 auto;
  padding-bottom: 8px;
}

.edo-sources-card .card-desc {
  margin-bottom: 0;
}

.edo-sources-card > .edo-concepts-pagination {
  flex: 0 0 auto;
  margin-top: 8px;
  padding-top: 8px;
}

.edo-sources-table-viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.edo-sources-table-viewport .table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
}

.edo-movements-table {
  min-width: 1080px;
  font-size: 12px;
}

.edo-amt-cell {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.edo-ref-cell {
  max-width: 240px;
  color: var(--text-muted);
  font-size: 12px;
}

.preview-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.preview-pagination.hidden {
  display: none !important;
}

.preview-pagination-count {
  margin: 0;
  font-size: 12px;
}

.preview-pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.preview-pagination-info {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 110px;
  text-align: center;
}

.preview-nominas-section .preview-edos-title {
  margin-top: 0;
}

.edo-concepts-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.edo-concepts-count {
  margin: 0;
}

.edo-pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.edo-pagination-info {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 120px;
  text-align: center;
}

.edo-concepts-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.edo-filter-search {
  flex: 1;
  min-width: 220px;
}

@media (max-width: 900px) {
  .edo-header-toolbar {
    gap: 8px;
  }

  .edo-header-stats {
    gap: 6px;
  }

  .edo-header-stat {
    min-width: 48px;
    height: 40px;
    padding: 3px 6px;
  }

  .edo-header-stat-value {
    font-size: 0.85rem;
  }

  .edo-header-stat-label {
    font-size: 8px;
  }

  .edo-import-btn__text small {
    max-width: 110px;
  }

  .header-user-name {
    display: none;
  }

  .header-user-trigger {
    padding-right: 8px;
  }
}


/* ==========================================================================
   Redesign v0.3 — Layout de flujo y paneles
   ========================================================================== */

.page-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 22px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(ellipse 80% 120% at 100% 0%, rgba(20, 184, 166, 0.08) 0%, transparent 55%),
    linear-gradient(165deg, var(--surface) 0%, var(--bg-elevated) 100%);
  box-shadow: var(--shadow-sm);
}

.page-hero__main {
  flex: 1 1 280px;
  min-width: 0;
}

.page-hero__title {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-hero__desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
  max-width: 56ch;
}

.page-hero__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.hero-chip svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.doc-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.95fr);
  gap: 20px;
  align-items: stretch;
}

/* Formulario: la página no hace scroll; cada columna scrollea por dentro */
.main-wrapper:has(.doc-workspace) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.page-content:has(.doc-workspace) {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(16px + var(--footer-h));
}

#view-root:has(.doc-workspace) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#view-root:has(.doc-workspace) > .doc-workspace {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.doc-workspace .form-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  height: 100%;
  overflow: hidden;
}

.doc-workspace .gen-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.doc-workspace .form-scroll-area {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.doc-workspace .form-actions-bar {
  position: static;
  flex-shrink: 0;
  margin-top: 12px;
  bottom: auto;
}

.doc-workspace .generate-progress {
  flex-shrink: 0;
}

.doc-workspace .preview-card {
  position: relative; /* necesario para que el overlay absolute cubra este panel */
  min-height: 0;
  max-height: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}

.doc-workspace .preview-card.is-loading {
  overflow: hidden;
}

.setup-panel {
  margin-bottom: 18px;
  padding: 18px 18px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(20, 184, 166, 0.28);
  background:
    linear-gradient(135deg, rgba(20, 184, 166, 0.07) 0%, rgba(0, 0, 0, 0.15) 100%),
    var(--surface-2);
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.06) inset;
}

.setup-panel__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.setup-panel__icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #14b8a6, #0f766e);
  color: #ecfdf5;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.setup-panel__icon svg {
  width: 20px;
  height: 20px;
}

.setup-panel__title {
  margin: 0 0 2px;
  font-size: 1rem;
  font-weight: 700;
}

.setup-panel__desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.template-picks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.template-picks .field {
  margin: 0;
}

.template-picks label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.form-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.form-section[open]:has(.field--error),
.form-section[open]:has(.field-error-tip) {
  overflow: visible;
}

.form-section > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.form-section > summary::-webkit-details-marker {
  display: none;
}

.form-section > summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.form-section[open] > summary {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.form-section__step {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  color: #5eead4;
  background: var(--accent-soft);
  border: 1px solid rgba(20, 184, 166, 0.25);
  flex-shrink: 0;
}

.form-section__titles {
  flex: 1;
  min-width: 0;
}

.form-section__title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.form-section__subtitle {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 1px;
}

.form-section__chevron {
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.form-section[open] .form-section__chevron {
  transform: rotate(180deg);
}

.form-section--locked {
  opacity: 0.55;
}

.form-section--locked > summary {
  cursor: not-allowed;
  pointer-events: none;
}

.form-section--locked .form-section__step {
  color: var(--text-dim);
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.2);
}

.form-section--unlocked .form-section__step {
  color: #5eead4;
}

.form-section__body {
  padding: 14px 16px 16px;
}

.input--money {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  text-align: right;
}

.form-section--always-open {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.1);
}

.form-section--always-open .form-section__body {
  padding: 14px 16px 16px;
}

.form-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky;
  bottom: calc(var(--footer-h) + 8px);
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

.form-actions-bar .actions {
  margin: 0;
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-card .card-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.preview-card .summary {
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: rgba(0, 0, 0, 0.15);
}

/* PSD workflow */
.psd-page .page-hero {
  margin-bottom: 18px;
}

.workflow-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.workflow-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.workflow-step__num {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  background: var(--surface-3);
  color: var(--text-muted);
}

.workflow-step.is-active {
  color: #99f6e4;
  border-color: rgba(20, 184, 166, 0.35);
  background: var(--accent-soft);
}

.workflow-step.is-active .workflow-step__num {
  background: var(--accent);
  color: #042f2e;
}

.workflow-step.is-done {
  color: #86efac;
  border-color: rgba(52, 211, 153, 0.32);
  background: rgba(34, 197, 94, 0.08);
}

.workflow-step.is-done .workflow-step__num {
  background: rgba(52, 211, 153, 0.22);
  color: #6ee7b7;
}

.psd-config-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin-bottom: 0;
}

.psd-config-strip .select-control {
  margin: 0;
}

.herramientas-split--psd-workflow {
  gap: 20px;
}

#psd-convert-card .psd-upload-drop {
  border-style: dashed;
  border-width: 2px;
  transition: border-color var(--transition), background var(--transition);
}

#psd-convert-card .psd-upload-drop.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.card-header h2 {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

@media (max-width: 1100px) {
  .main-wrapper:has(.doc-workspace) {
    height: auto;
    overflow: visible;
  }

  .page-content:has(.doc-workspace) {
    overflow: visible;
    display: block;
    min-height: 0;
    height: auto;
  }

  #view-root:has(.doc-workspace) {
    display: block;
    overflow: visible;
    height: auto;
    min-height: 0;
  }

  #view-root:has(.doc-workspace) > .doc-workspace {
    height: auto;
    overflow: visible;
  }

  .doc-workspace {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .doc-workspace .form-card,
  .doc-workspace .preview-card {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .doc-workspace .gen-form {
    overflow: visible;
  }

  .doc-workspace .form-scroll-area {
    overflow: visible;
  }

  .doc-workspace .preview-card {
    position: relative;
  }

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

  .form-actions-bar {
    position: static;
  }
}

@media (max-width: 720px) {
  .page-hero {
    padding: 16px;
  }

  .psd-config-strip {
    grid-template-columns: 1fr;
  }

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


.psd-flow-callout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(20, 184, 166, 0.22);
  background: var(--accent-soft);
}

.psd-flow-callout__icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(20, 184, 166, 0.18);
  color: #5eead4;
  flex-shrink: 0;
}

.psd-flow-callout__icon svg {
  width: 18px;
  height: 18px;
}

.psd-flow-callout__title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #99f6e4;
}

.psd-flow-callout__text {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}

.psd-page .herramientas-split--psd-workflow {
  display: block;
}

.template-tile-file {
  font-size: 0.82rem;
  opacity: 0.75;
}

.company-templates-summary {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  background: var(--surface-2, rgba(255, 255, 255, 0.03));
}

.company-templates-summary__title {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

.company-templates-summary__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.company-templates-summary__list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
}

.company-templates-summary__list span {
  opacity: 0.75;
}

.company-templates-summary__list strong.is-missing {
  color: #fca5a5;
}

.company-templates-summary__list strong.is-muted {
  opacity: 0.65;
  font-weight: 500;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, #2dd4bf);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.link-btn:hover {
  opacity: 0.85;
}


.psd-new-company-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: 10px;
  border: 1px dashed var(--accent, #2dd4bf);
  background: rgba(45, 212, 191, 0.05);
}

.psd-new-company-panel__head h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.field-optional {
  font-size: 0.82rem;
  font-weight: 400;
  opacity: 0.7;
}

/* Empresas */
.empresas-page .card-header--row {
  flex-wrap: wrap;
}

.empresas-layout {
  display: grid;
  gap: 20px;
  align-items: start;
}

@media (min-width: 960px) {
  .empresas-layout {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }
}

.empresas-list-wrap {
  min-width: 0;
}

.empresas-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.empresas-list-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.empresas-list-item:hover,
.empresas-list-item.is-active {
  border-color: rgba(20, 184, 166, 0.35);
  background: var(--accent-soft);
}

.empresas-list-item__label {
  display: block;
  font-weight: 600;
}

.empresas-list-item__meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.empresas-editor {
  min-width: 0;
}

.empresa-form__title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
}

.empresa-logo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.empresa-logo-preview {
  width: 220px;
  height: 100px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(45deg, #dbe3ec 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(-45deg, #dbe3ec 25%, transparent 25%) 0 6px / 12px 12px,
    linear-gradient(45deg, transparent 75%, #dbe3ec 75%) 0 6px / 12px 12px,
    linear-gradient(-45deg, transparent 75%, #dbe3ec 75%) 0 0 / 12px 12px,
    #f3f4f6;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.empresa-logo-preview:hover:not(:disabled),
.empresa-logo-preview:focus-visible {
  border-color: var(--accent, #38bdf8);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
  outline: none;
}

.empresa-logo-preview:disabled {
  cursor: default;
}

.empresa-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.empresa-logo-preview span {
  font-size: 12px;
  color: var(--text-muted);
}

.empresa-logo-actions {
  display: grid;
  gap: 8px;
  align-content: start;
}

.empresa-logo-modal-panel {
  width: min(92vw, 42rem);
  height: auto;
  max-height: min(90dvh, 40rem);
}

.empresa-logo-modal .pdf-modal-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.empresa-logo-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 18px 16px;
  min-height: 0;
}

.empresa-logo-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.empresa-logo-editor__zoom {
  min-width: 3.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  font-weight: 600;
}

.empresa-logo-editor__hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.empresa-logo-editor__stage-wrap {
  display: grid;
  place-items: center;
  padding: 18px;
  background: #e8ecf1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.empresa-logo-editor__stage {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 245 / 72;
  overflow: hidden;
  background:
    linear-gradient(45deg, #dbe3ec 25%, transparent 25%) 0 0 / 14px 14px,
    linear-gradient(-45deg, #dbe3ec 25%, transparent 25%) 0 7px / 14px 14px,
    linear-gradient(45deg, transparent 75%, #dbe3ec 75%) 0 7px / 14px 14px,
    linear-gradient(-45deg, transparent 75%, #dbe3ec 75%) 0 0 / 14px 14px,
    #fff;
  border: 2px solid #0f172a;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.empresa-logo-editor__stage.is-panning {
  cursor: grabbing;
}

.empresa-logo-editor__stage img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
}

.empresa-logo-modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.empresa-logo-modal-footer .hint {
  margin: 0;
  margin-right: auto;
}

.upload-actions--split {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.btn--danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}

.btn--danger:hover:not(:disabled) {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.5);
}

.btn--danger:disabled,
.btn--danger.is-disabled,
.btn--danger[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

#html-template-modal .html-template-modal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

#html-template-modal .html-template-delete-hint {
  margin: 0;
  margin-right: auto;
  max-width: min(420px, 55%);
}

#html-template-modal .html-template-delete-hint.hidden {
  display: none;
}

#html-template-modal-delete {
  flex-shrink: 0;
  min-width: 9.5rem;
}

.template-tile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.clients-sheet-btn-label {
  flex: 1;
  min-width: 0;
}

.preview-edos-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
}

.preview-carta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.html-templates-page .html-create {
  display: grid;
  gap: 16px;
}

.html-create-fields {
  margin: 0;
}

.html-assign {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.html-templates-page .upload-drop {
  padding: 22px 16px;
}

.html-templates-page .actions {
  justify-content: flex-end;
}

.html-templates-page .templates-header {
  margin-bottom: 0;
}

.html-templates-page .templates-card .templates-toolbar {
  margin-top: 4px;
  margin-bottom: 16px;
}

.html-templates-page .templates-toolbar--view-only {
  justify-content: flex-end;
}

.html-templates-page .templates-card .card-header + .templates-toolbar {
  margin-top: 0;
}

@media (min-width: 720px) {
  .html-templates-page .templates-toolbar.control-bar {
    align-items: flex-end;
  }

  .html-templates-page .templates-toolbar .segmented-control-group {
    flex: 0 0 auto;
    min-width: 240px;
  }
}

/* ==========================================================================
   UX — page loader, transitions, lazy / soft loads
   ========================================================================== */

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 18, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.36s ease;
}

.page-loader.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.page-loader__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 14px;
  padding: 22px 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: rgba(17, 24, 39, 0.92);
  box-shadow: var(--shadow);
}

.page-loader__spinner,
.preview-card-loading__spinner,
.ui-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid rgba(148, 163, 184, 0.25);
  border-top-color: #5eead4;
  animation: docpack-spin 0.7s linear infinite;
}

.page-loader__text {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

#view-root {
  transition: opacity 0.2s ease;
}

#view-root.is-leaving {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.22s ease;
}

#view-root.is-loading {
  opacity: 0.35;
  pointer-events: none;
}

#view-root.is-entering {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.22s ease;
}

#view-root.is-ready {
  opacity: 1;
  transform: none;
}

.generate-progress {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.generate-progress:not(.hidden) {
  animation: docpack-fade-up 0.28s ease both;
}

.generate-progress.is-indeterminate .generate-progress-bar {
  width: 38% !important;
  animation: docpack-indet 1.1s ease-in-out infinite;
}

.generate-progress.is-indeterminate .generate-progress-pct {
  min-width: 1.5ch;
}

.btn.is-busy {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-busy > * {
  opacity: 0;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  animation: docpack-spin 0.65s linear infinite;
}

.preview-card {
  position: relative;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.preview-card.is-loading {
  min-height: 220px;
}

.preview-card-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 10px;
  box-sizing: border-box;
  border-radius: inherit;
  background: rgba(12, 16, 23, 0.82);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.36s ease;
}

.preview-card.is-loading > :not(.preview-card-loading) {
  pointer-events: none;
}

.preview-card-loading.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.preview-card-loading.hidden {
  display: none !important;
}

.preview-card-loading__text {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.preview-card-loading__hint {
  margin: 0;
  font-size: 12px;
}

.preview-card.is-revealed .summary,
.preview-card.is-revealed .table-wrap,
.preview-card.is-revealed .preview-nominas-section,
.preview-card.is-revealed .preview-edos-section {
  animation: docpack-fade-up 0.35s ease both;
}

.preview-card.is-revealed .preview-row {
  animation: docpack-fade-up 0.32s ease both;
}

.preview-card.is-revealed .preview-row:nth-child(1) { animation-delay: 0.02s; }
.preview-card.is-revealed .preview-row:nth-child(2) { animation-delay: 0.05s; }
.preview-card.is-revealed .preview-row:nth-child(3) { animation-delay: 0.08s; }
.preview-card.is-revealed .preview-row:nth-child(4) { animation-delay: 0.11s; }
.preview-card.is-revealed .preview-row:nth-child(5) { animation-delay: 0.14s; }
.preview-card.is-revealed .preview-row:nth-child(n+6) { animation-delay: 0.17s; }

.media-fade {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.media-fade.is-loaded {
  opacity: 1;
}

.list-soft-enter > * {
  animation: docpack-fade-up 0.28s ease both;
}

.list-soft-enter > *:nth-child(1) { animation-delay: 0.02s; }
.list-soft-enter > *:nth-child(2) { animation-delay: 0.05s; }
.list-soft-enter > *:nth-child(3) { animation-delay: 0.08s; }
.list-soft-enter > *:nth-child(4) { animation-delay: 0.11s; }
.list-soft-enter > *:nth-child(5) { animation-delay: 0.14s; }
.list-soft-enter > *:nth-child(n+6) { animation-delay: 0.17s; }

.panel-loading {
  position: relative;
  min-height: 120px;
  pointer-events: none;
}

.panel-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background: rgba(8, 12, 18, 0.35);
}

.panel-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 2.5px solid rgba(148, 163, 184, 0.25);
  border-top-color: #5eead4;
  animation: docpack-spin 0.7s linear infinite;
}

.empresas-list-wrap.is-loading,
.clients-table-wrap.is-loading,
#clients-web-wrap.is-loading,
#clients-system-wrap.is-loading,
#clients-lists.is-loading,
#edo-concepts-table-wrap.is-loading,
#edo-sources-wrap.is-loading,
#edo-page.is-loading,
#html-template-grid.is-loading {
  opacity: 0.72;
  transition: opacity 0.2s ease;
}

/* Evitar texto suelto “Cargando…” lejos del spinner del panel */
.empresas-list.is-loading::before,
.clients-table.is-loading tbody::before {
  content: none;
  display: none;
}

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

@keyframes docpack-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes docpack-indet {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

@media (max-width: 720px) {
  .pdf-modal,
  .tcpdf-modal,
  #doc-preview-modal.pdf-modal {
    padding: max(0.75rem, env(safe-area-inset-top, 0px))
      max(0.75rem, env(safe-area-inset-right, 0px))
      max(0.75rem, env(safe-area-inset-bottom, 0px))
      max(0.75rem, env(safe-area-inset-left, 0px));
  }

  .pdf-modal-panel,
  .tcpdf-modal-panel,
  #doc-preview-modal .pdf-modal-panel,
  #doc-preview-modal .doc-preview-panel {
    width: calc(100vw - 1.5rem);
    height: calc(100dvh - 1.5rem);
    max-width: calc(100vw - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    border-radius: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  #view-root.is-leaving,
  #view-root.is-entering {
    transform: none;
  }

  .page-loader {
    backdrop-filter: none;
  }
}

