:root {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #171d25;
  --panel-border: #2a3441;
  --text: #edf2f7;
  --muted: #94a3b8;
  --accent: #d4a017;
  --accent-strong: #f0c040;
  --danger: #f87171;
  --success: #34d399;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top, #1b2430, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent-strong); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.success { color: var(--success); }

.integrity-warning {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fecaca;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.auth-page, .redirect-page {
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card, .panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 420px);
  padding: 2rem;
}

.brand .eyebrow, .brand-block .eyebrow {
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
  margin: 0 0 0.35rem;
}

.brand h1 { margin: 0; font-size: 2rem; }
.subtitle { color: var(--muted); }

.brand-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
}

.env-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.2;
  flex-shrink: 0;
}

.env-badge-staging {
  color: #D4AF37;
  background: rgba(212, 175, 55, 0.14);
  border: 1px solid rgba(212, 175, 55, 0.5);
}

.stack {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.stack.narrow {
  max-width: 28rem;
}

.profile-meta {
  display: grid;
  gap: 0.75rem;
  margin: 0.75rem 0 0;
}

.profile-meta div {
  display: grid;
  gap: 0.15rem;
}

.profile-meta dt {
  font-size: 0.82rem;
  color: var(--muted);
}

.profile-meta dd {
  margin: 0;
  font-weight: 600;
}

.audit-table td,
.audit-table th {
  vertical-align: top;
}

.taxonomy-fieldset {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
  margin: 1rem 0;
}

.taxonomy-summary {
  margin-bottom: 0.75rem;
}

label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.92rem;
}

input, select, button, textarea {
  font: inherit;
}

input, select {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: #10151c;
  color: var(--text);
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #111;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: 272px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--panel-border);
  background: rgba(10, 14, 20, 0.92);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.25rem;
  min-width: 0;
}

.brand-block {
  display: grid;
  gap: 0.65rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(42, 52, 65, 0.85);
}

.brand-logo {
  display: block;
  width: min(100%, 148px);
  height: auto;
  max-height: 42px;
  object-fit: contain;
  object-position: left center;
}

.nav {
  display: grid;
  gap: 0.2rem;
  align-content: start;
  overflow-y: auto;
  min-height: 0;
}

.nav a.nav-link,
.nav span.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.58rem 0.7rem;
  border-radius: 10px;
  color: var(--muted);
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav a.nav-link:hover {
  color: var(--text);
  background: rgba(212, 160, 23, 0.07);
}

.nav a.nav-link.active {
  color: var(--accent-strong);
  background: rgba(212, 175, 55, 0.12);
  border-color: rgba(212, 175, 55, 0.32);
  font-weight: 600;
}

.nav-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  opacity: 0.72;
}

.nav a.nav-link:hover .nav-icon {
  opacity: 0.9;
}

.nav a.nav-link.active .nav-icon {
  opacity: 1;
  color: var(--accent-strong);
}

.nav-label {
  line-height: 1.25;
  min-width: 0;
}

.sidebar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: auto;
  font-size: 0.88rem;
}

.sidebar-logout .nav-icon {
  width: 1rem;
  height: 1rem;
  opacity: 0.75;
}

.nav span.disabled {
  color: var(--muted);
  opacity: 0.7;
}

.content {
  padding: 2rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  padding: 1rem 1.2rem;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

.card strong {
  display: block;
  font-size: 1.8rem;
  margin-top: 0.35rem;
}

.panel {
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.module-card {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1rem;
  background: #111821;
}

.module-card .badge {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.module-card.available .badge {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--panel-border);
  vertical-align: top;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.actions button {
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.audit-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.audit-item {
  padding: 0.85rem 1rem;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #111821;
}

.audit-item time {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

dialog {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 1.25rem;
  width: min(92vw, 460px);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.action-with-help {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-primary-approve {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #111;
  font-weight: 700;
}

.action-help-icon {
  flex-shrink: 0;
}

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: #111821;
}

.thumb-loading,
.image-loading {
  opacity: 0.65;
}

.image-fallback {
  object-fit: contain;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.product-form .grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.product-form fieldset {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
}

.product-form .checks {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.product-form .legacy-categorias-fieldset .legacy-readonly {
  opacity: 0.85;
  cursor: default;
}

.product-form .legacy-categorias-fieldset input[disabled] {
  cursor: not-allowed;
}

.product-form .legacy-categorias-note {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

/* Fase 5B.3A — QW02 chips estado editorial */
.editorial-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  border: 1px solid transparent;
  white-space: nowrap;
}

.editorial-chip-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.editorial-chip--activo {
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.35);
}
.editorial-chip--activo .editorial-chip-dot { background: #34d399; }

.editorial-chip--agotado {
  background: rgba(251, 146, 60, 0.12);
  color: #fdba74;
  border-color: rgba(251, 146, 60, 0.35);
}
.editorial-chip--agotado .editorial-chip-dot { background: #fb923c; }

.editorial-chip--oculto {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.35);
}
.editorial-chip--oculto .editorial-chip-dot { background: #94a3b8; }

.editorial-chip--borrador {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.25);
}
.editorial-chip--borrador .editorial-chip-dot { background: #64748b; }

.editorial-chip--pendiente {
  background: rgba(96, 165, 250, 0.12);
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.35);
}
.editorial-chip--pendiente .editorial-chip-dot { background: #60a5fa; }

.editorial-chip--devuelto {
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}
.editorial-chip--devuelto .editorial-chip-dot { background: #f87171; }

.editorial-chip--aprobado {
  background: rgba(212, 160, 23, 0.15);
  color: var(--accent-strong);
  border-color: rgba(212, 160, 23, 0.4);
}
.editorial-chip--aprobado .editorial-chip-dot { background: var(--accent); }

.editorial-chip--eliminado,
.editorial-chip--default {
  background: rgba(100, 116, 139, 0.12);
  color: #94a3b8;
  border-color: rgba(100, 116, 139, 0.3);
}
.editorial-chip--eliminado .editorial-chip-dot,
.editorial-chip--default .editorial-chip-dot { background: #64748b; }

.editorial-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Fase 5B.3A — QW06 ayudas contextuales */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  margin-left: 0.25rem;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  flex-shrink: 0;
}

.field-help {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
}

/* Fase 5B.3A — QW10 Academia MVP */
.help-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.help-nav-link {
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  color: var(--text);
  background: #111821;
}

.help-nav-link:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.help-article h2 {
  margin-top: 0;
}

.help-list {
  padding-left: 1.25rem;
  line-height: 1.6;
}

.help-dl {
  display: grid;
  gap: 0.75rem;
}

.help-dl dt {
  margin: 0;
}

.help-dl dd {
  margin: 0.25rem 0 0;
  color: var(--muted);
  padding-left: 0.25rem;
}

.panel.nested {
  margin-top: 1rem;
  background: #111821;
}

.queue-list {
  display: grid;
  gap: 0.75rem;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #111821;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
    grid-template-rows: auto auto auto;
  }
  .brand-logo { max-height: 36px; width: min(100%, 132px); }
  .nav { max-height: none; }
}

.image-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.image-slot-card {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
  background: #111821;
  display: grid;
  gap: 0.75rem;
}

.image-slot-card.image-slot-pending {
  opacity: 0.72;
  border-style: dashed;
}

input[name="tallas"].tallas-not-required {
  opacity: 0.72;
  border-style: dashed;
  cursor: not-allowed;
}

.image-slot-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.image-preview img,
.image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #0b1016;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.image-meta {
  margin: 0;
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
}

.image-meta div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.image-meta dt { color: var(--muted); }
.image-meta dd { margin: 0; text-align: right; }

.image-quality--ready { color: #8fd48a; font-weight: 600; }
.image-quality--warn { color: #f0c040; }
.image-quality--error { color: #f87171; }
.image-quality--legacy { color: var(--muted); }
.image-quality--pending { color: var(--muted); }

.image-quality-hint dd {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: left;
}

.image-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.image-progress {
  width: 100%;
  height: 0.5rem;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.image-actions .btn,
.image-actions label.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
}

.image-actions label.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.staging-banner {
  background: #7c2d12;
  color: #fff7ed;
  text-align: center;
  padding: 0.65rem 1rem;
  font-weight: 600;
}

.sync-monitor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border, #e5e7eb);
  margin-bottom: 1.25rem;
}

.sync-monitor-body {
  display: grid;
  gap: 0.25rem;
}

.sync-monitor-headline {
  font-size: 1.05rem;
}

.sync-monitor-age {
  margin: 0;
  font-weight: 600;
}

.sync-monitor-detail {
  margin: 0;
}

.sync-monitor--normal {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.sync-monitor--advertencia {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.sync-monitor--critico {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.sync-monitor--sin_historial {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}

.sync-monitor-detail .sync-monitor-meta {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.sync-monitor-meta-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 0.75rem;
}

.sync-monitor-meta-row dt {
  margin: 0;
  font-weight: 600;
  color: var(--text-muted, #64748b);
}

.sync-monitor-meta-row dd {
  margin: 0;
}

.sync-monitor-detail-line {
  margin: 1rem 0 0;
}

.sync-monitor-actions {
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .sync-monitor {
    flex-direction: column;
    align-items: flex-start;
  }

  .sync-monitor-meta-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
