* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f5f7fa; color: #222; line-height: 1.5; min-height: 100vh;
}
.container { max-width: 100%; margin: 0 auto; padding: 16px 24px; }
.auth-container { max-width: 420px; margin: 80px auto; padding: 32px; background: white; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
h1 { font-size: 22px; margin-bottom: 8px; }
h2 { font-size: 17px; margin-bottom: 12px; color: #333; }
h3 { font-size: 14px; margin-bottom: 10px; color: #555; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.subtitle { color: #666; margin-bottom: 24px; font-size: 14px; }
.form-group { margin-bottom: 14px; }
label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: #333; }
input, textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid #d0d5dd;
  border-radius: 8px; font-size: 14px; font-family: inherit; background: white;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }
.btn { display: inline-block; padding: 8px 16px; border: none; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-primary.full { width: 100%; padding: 10px 18px; font-size: 14px; }
.btn-secondary { background: #e5e7eb; color: #333; }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn + .btn { margin-left: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; display: none; }
.alert.show { display: block; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.link-row { text-align: center; margin-top: 16px; font-size: 14px; color: #666; }
.link-row a { color: #3b82f6; text-decoration: none; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: white; padding: 12px 24px; border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); flex-wrap: wrap; gap: 12px;
}
.topbar .brand { font-weight: 700; font-size: 18px; }
.topbar .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.topbar .user { color: #555; font-size: 14px; font-weight: 500; }
/* v2.32.47: botones del menú más grandes y profesionales */
.topbar a {
  color: #1f2937;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: white;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar a:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  text-decoration: none;
  color: #111827;
}
.topbar a.active,
.topbar a[aria-current="page"] {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}
.role-badge, .dept-badge {
  display: inline-block; padding: 4px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.role-admin { background: #fef3c7; color: #92400e; }
.role-user { background: #e0e7ff; color: #3730a3; }
.dept-badge { background: #dcfce7; color: #166534; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.toolbar-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab { padding: 7px 14px; border: none; background: transparent; cursor: pointer; border-radius: 6px; font-size: 13px; color: #666; }
.tab.active { background: white; color: #111; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 13px; }
th { background: #f9fafb; font-weight: 600; color: #444; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }
tbody tr:hover { background: #f9fafb; }
tbody tr.has-inventory { background: #d1fae5; }
tbody tr.has-inventory:hover { background: #a7f3d0; }
tbody tr:last-child td { border-bottom: none; }
.empty-state { text-align: center; padding: 48px; color: #666; background: white; border-radius: 8px; }
.card { background: white; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); margin-bottom: 16px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-inventory { background: #dcfce7; color: #166534; }
.muted { color: #888; font-size: 12px; }
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 10; align-items: flex-start; justify-content: center; padding-top: 30px; overflow-y: auto; }
.modal-backdrop.show { display: flex; }
.modal { background: white; border-radius: 10px; max-width: 620px; width: calc(100% - 24px); padding: 22px; margin-bottom: 40px; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #888; }
.modal-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid #e5e7eb; }
.preview-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.preview-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.preview-line .label { color: #666; }
.preview-line .value { font-weight: 600; }
.action-tag { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.action-inv { background: #dcfce7; color: #166534; }
.action-partial { background: #fef3c7; color: #92400e; }
.action-machine { background: #dbeafe; color: #1e40af; }
@media (max-width: 700px) {
  th, td { padding: 7px; font-size: 12px; }
  .container { padding: 10px; }
}

/* ============================================================
   v2.32.243 — MODO OSCURO. Overrides activados con [data-theme="dark"]
   en <html>. No modifica el CSS claro existente.
   ============================================================ */
[data-theme="dark"] body { background: #0f172a; color: #e2e8f0; }
[data-theme="dark"] .container { color: #e2e8f0; }
[data-theme="dark"] h1, [data-theme="dark"] h2 { color: #f1f5f9; }
[data-theme="dark"] h3 { color: #e2e8f0; }
[data-theme="dark"] .subtitle, [data-theme="dark"] .link-row { color: #cbd5e1; }
[data-theme="dark"] label { color: #f1f5f9; }
/* v2.32.244: labels específicos de pantallas (customers, complete-production, etc.) que
   tienen su propio color gris oscuro inline → forzar claro y con buen contraste en oscuro */
[data-theme="dark"] .nc-field label,
[data-theme="dark"] .cp-field label,
[data-theme="dark"] .form-row label,
[data-theme="dark"] .order-grid label,
[data-theme="dark"] .po-toolbar label,
[data-theme="dark"] .nc-check,
[data-theme="dark"] .form-group label { color: #f1f5f9 !important; }
/* títulos de sección de las cards (ej "BUSINESS INFORMATION") más brillantes */
[data-theme="dark"] .nc-card h3 { color: #93c5fd !important; border-bottom-color: #334155; }

/* inputs */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: #1e293b; color: #e2e8f0; border-color: #334155;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #64748b; }
[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
  border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}

/* cards / contenedores blancos comunes */
[data-theme="dark"] .auth-container,
[data-theme="dark"] .card,
[data-theme="dark"] .nc-card,
[data-theme="dark"] .cp-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .dist-card,
[data-theme="dark"] .info-card {
  background: #1e293b; color: #e2e8f0; border-color: #334155;
}

/* topbar */
[data-theme="dark"] .topbar { background: #1e293b; border-bottom-color: #334155; }
[data-theme="dark"] .topbar .brand { color: #f1f5f9; }
[data-theme="dark"] .topbar .user { color: #cbd5e1; }
[data-theme="dark"] .topbar a {
  color: #e2e8f0; background: #0f172a; border-color: #334155;
}
[data-theme="dark"] .topbar a:hover { background: #334155; }

/* tablas */
[data-theme="dark"] table { color: #f1f5f9; background: #1e293b !important; }
[data-theme="dark"] th {
  background: #0f172a !important; color: #cbd5e1 !important; border-color: #334155 !important;
}
[data-theme="dark"] td { border-color: #334155 !important; color: #f1f5f9 !important; background: #1e293b; }
[data-theme="dark"] td strong { color: #ffffff !important; }
[data-theme="dark"] tbody tr { background: #1e293b; }
[data-theme="dark"] tbody tr td { color: #f1f5f9 !important; }
[data-theme="dark"] tbody tr:hover { background: #243044; }
[data-theme="dark"] tbody tr:hover td { background: #243044; }
/* v2.32.246: filas con fondo claro (urgentes #fef9c3 inline / has-inventory #d1fae5) →
   en oscuro, tinte oscuro distintivo + texto claro. !important pisa clase y style inline. */
[data-theme="dark"] tbody tr.has-inventory,
[data-theme="dark"] tbody tr.has-inventory td { background: #0c2e1a !important; color: #bbf7d0 !important; }
[data-theme="dark"] tbody tr[style*="fef9c3"],
[data-theme="dark"] tbody tr[style*="fef9c3"] td { background: #3a3520 !important; color: #fde68a !important; }
[data-theme="dark"] tbody tr.has-inventory:hover td { background: #11402a !important; }

/* botón secundario (el primario y de colores se ven bien igual) */
[data-theme="dark"] .btn-secondary { background: #334155; color: #e2e8f0; }
[data-theme="dark"] .btn-secondary:hover { background: #475569; }

/* alerts: mantener legibles en oscuro */
[data-theme="dark"] .alert-error { background: #450a0a; color: #fecaca; border-color: #7f1d1d; }
[data-theme="dark"] .alert-success { background: #052e1a; color: #bbf7d0; border-color: #166534; }
[data-theme="dark"] .alert-info { background: #0c2a52; color: #bfdbfe; border-color: #1e40af; }
[data-theme="dark"] .alert-warning { background: #422006; color: #fde68a; border-color: #92400e; }

/* el botón de tema en el topbar */
.tb-theme-btn {
  cursor: pointer; border: 1px solid #e5e7eb; background: white;
  border-radius: 8px; padding: 8px 12px; font-size: 14px; line-height: 1;
}
[data-theme="dark"] .tb-theme-btn { background: #0f172a; border-color: #334155; }

/* v2.32.247: secciones de index.html (Pending Products) con fondo claro propio que faltaban
   en oscuro: barra "Distribución", sus tarjetas, y el banner PCSPER. */
[data-theme="dark"] .dist-totals-bar { background: #0f172a !important; border-color: #334155 !important; }
[data-theme="dark"] .dist-totals-header { color: #cbd5e1 !important; }
[data-theme="dark"] .dist-card { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .dist-card:hover { background: #243044 !important; border-color: #3b82f6 !important; }
[data-theme="dark"] .dist-card.active { background: #1e3a5f !important; border-color: #3b82f6 !important; }
[data-theme="dark"] .dist-card .dist-name { color: #f1f5f9 !important; }
[data-theme="dark"] .dist-card .dist-stats { color: #cbd5e1 !important; }
[data-theme="dark"] .dist-card .dist-total strong { color: #ffffff !important; }
/* banner PCSPER (fondo celeste inline #dbeafe) */
[data-theme="dark"] #pcsperSyncBar { background: #0c2a52 !important; border-color: #1e40af !important; }
[data-theme="dark"] #pcsperSyncBar div { color: #bfdbfe !important; }

/* ============================================================
   v2.32.248 — MODO OSCURO GENERAL: capturar fondos claros INLINE comunes
   (style="background:#xxx") en todas las pantallas y convertirlos a equivalentes
   oscuros legibles. Cubre cajas de resumen, banners y encabezados de grupo.
   ============================================================ */
/* blancos / grises muy claros → card oscura */
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#f9fafb"],
[data-theme="dark"] [style*="background:#f8fafc"],
[data-theme="dark"] [style*="background:#f3f4f6"],
[data-theme="dark"] [style*="background:#f1f5f9"] {
  background-color: #1e293b !important; color: #e2e8f0 !important;
}
/* amarillos / cremas (info, on-hold, "apply dates") → ámbar oscuro */
[data-theme="dark"] [style*="background:#fef3c7"],
[data-theme="dark"] [style*="background:#fef9c3"],
[data-theme="dark"] [style*="background:#fefce8"],
[data-theme="dark"] [style*="background:#fffbeb"],
[data-theme="dark"] [style*="background:#fdf6b2"],
[data-theme="dark"] [style*="background:#fef08a"] {
  background-color: #3a3520 !important; color: #fde68a !important;
}
/* azules claros (info banners) → azul oscuro */
[data-theme="dark"] [style*="background:#dbeafe"],
[data-theme="dark"] [style*="background:#eff6ff"],
[data-theme="dark"] [style*="background:#f0f9ff"] {
  background-color: #0c2a52 !important; color: #bfdbfe !important;
}
/* rojos claros (error/late) → rojo oscuro (pero #dc2626 sólido se deja, es badge) */
[data-theme="dark"] [style*="background:#fee2e2"],
[data-theme="dark"] [style*="background:#fef2f2"] {
  background-color: #450a0a !important; color: #fecaca !important;
}
/* verdes claros (success/inventory) → verde oscuro */
[data-theme="dark"] [style*="background:#d1fae5"],
[data-theme="dark"] [style*="background:#dcfce7"] {
  background-color: #0c2e1a !important; color: #bbf7d0 !important;
}

/* v2.32.248 (cont) — clases específicas con fondo claro en su propio <style> que el
   selector [style*] no captura. Planning Orders + Customer Dates + comunes. */
/* Planning Orders */
[data-theme="dark"] .po-totals-bar { background: #0c2a3a !important; color: #bae6fd !important; border-color: #155e75 !important; }
[data-theme="dark"] .po-totals-bar * { color: #bae6fd !important; }
[data-theme="dark"] .po-group-card { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .po-group-head { background: #0f172a !important; }
[data-theme="dark"] .po-group-head .gh-customer { color: #f1f5f9 !important; }
[data-theme="dark"] .po-pallets.muted { background: #334155 !important; color: #cbd5e1 !important; }
[data-theme="dark"] tr.po-row-urgent { background: #3a1f1f !important; }
[data-theme="dark"] tr.po-row-selected { background: #3a3520 !important; }
[data-theme="dark"] tr.po-row-urgent.po-row-selected { background: #4a3f1a !important; }
/* Customer Dates */
[data-theme="dark"] .update-bar { background: #3a3520 !important; border-color: #92400e !important; color: #fde68a !important; }
[data-theme="dark"] .update-bar * { color: #fde68a !important; }
[data-theme="dark"] .results-table tr.selected { background: #3a3520 !important; }
[data-theme="dark"] .results-table tr.selected td { color: #fde68a !important; }
/* selects/inputs claros que quedan blancos en algunas barras (ej filtros con fondo blanco) */
[data-theme="dark"] select, [data-theme="dark"] input[type="date"] { background: #1e293b !important; color: #e2e8f0 !important; }
