:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --line: #d8dee6;
  --text: #1f2a37;
  --muted: #687385;
  --nav: #111827;
  --nav-2: #1f2937;
  --nav-3: #0b1220;
  --nav-4: #162033;
  --accent: #1f6f8b;
  --accent-2: #155d75;
  --ok: #1f7a4d;
  --bad: #a23a3a;
  --shadow-soft: 0 10px 28px rgba(31, 42, 55, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: grid;
  grid-template-columns: 264px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

body.login-required {
  display: block;
  height: 100vh;
  overflow: hidden;
}

body.login-required .sidebar,
body.login-required .shell {
  display: none;
}

body.guia-publica {
  display: block;
  min-height: 100vh;
  height: auto;
  overflow: auto;
}

body.guia-publica .sidebar,
body.guia-publica .topbar,
body.guia-publica .context-warnings,
body.guia-publica .operativo-bar {
  display: none;
}

body.guia-publica .shell {
  display: block;
  height: auto;
  overflow: visible;
}

body.guia-publica .view {
  display: none;
}

body.guia-publica #view-guia_uso {
  display: block;
  margin: 0 auto;
  padding: 32px 24px;
}

.login-gate[hidden] {
  display: none;
}

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f3f5f7 0%, #e7eef2 100%);
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.login-card-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.login-card-brand small,
.login-card p,
.login-status {
  color: var(--muted);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.login-guide-link {
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.login-card p {
  margin: 0;
  line-height: 1.45;
}

.login-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-status,
.login-compat-warning {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.35;
}

.login-compat-warning {
  padding: 10px 12px;
  border: 1px solid #facc15;
  border-radius: var(--radius);
  background: #fefce8;
  color: #854d0e;
  font-weight: 700;
}

.sidebar {
  height: 100vh;
  min-height: 0;
  background: linear-gradient(180deg, var(--nav-3) 0%, var(--nav) 58%, var(--nav-4) 100%);
  transition: background 0.4s ease;
  color: #fff;
  padding: 16px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #e8f4f7;
  color: var(--accent-2);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.brand small {
  display: block;
  margin-top: 2px;
  color: #b9c4d2;
  font-size: 12px;
}

.sidebar-session {
  display: grid;
  gap: 6px;
  margin: 12px 2px 16px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-session span {
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.sidebar-session small {
  color: #b9c4d2;
  font-size: 11px;
  line-height: 1.35;
}

.sidebar-session button {
  width: 100%;
  min-height: 30px;
  padding: 0 10px;
}

.sidebar-nav {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.nav-group {
  display: grid;
  gap: 5px;
}

.nav-group + .nav-group {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.nav-group-label {
  padding: 0 10px 4px;
  color: #8391a7;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  border-color: var(--accent);
}

/* Acciones secundarias: consulta, recarga, bitacora, errores, detalle. Se ven
   discretas para no competir visualmente con la accion principal. */
.secondary {
  background: #f8fafc;
  border-color: var(--line);
  color: var(--muted);
  font-weight: 600;
}

.secondary:hover {
  background: #eef2f6;
  color: var(--text);
  border-color: var(--accent);
}

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 9px;
  text-align: left;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  min-height: 38px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.nav-item[hidden] {
  display: none;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #b7e3f0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: inset 3px 0 0 #4fb3cf;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  background: #e8f4f7;
  color: var(--accent-2);
}

.shell {
  min-width: 0;
  height: 100vh;
  min-height: 0;
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.topbar {
  min-height: 0;
  height: fit-content;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px;
  padding: 12px 18px 10px;
  position: relative;
  z-index: 5;
  box-shadow: 0 8px 18px rgba(31, 42, 55, 0.05);
}

.topbar-actions {
  display: flex;
  width: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  min-width: 0;
  row-gap: 10px;
}

.operacion-selector,
.comprador-selector,
.bodega-selector {
  flex: 0 1 224px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 3px 4px 3px 8px;
  border: 1px solid #e5eaf0;
  border-radius: var(--radius);
  background: #f8fafc;
}

.operacion-selector {
  margin-left: 0;
}

.operacion-selector label,
.comprador-selector label,
.bodega-selector label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.operacion-selector select,
.comprador-selector select,
.bodega-selector select {
  min-width: 0;
  flex: 1 1 auto;
  border-color: transparent;
  background: #fff;
}

.context-warnings {
  align-self: start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 4px 18px;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
}

.context-warnings[hidden] {
  display: none;
}

.context-warning {
  color: #9a3412;
  background: #ffedd5;
  border: 1px solid #fdba74;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  padding: 3px 6px;
}

.modo-solo-lectura .context-warning {
  color: #92400e;
  background: #fff7ed;
  border-color: #f59e0b;
}

.modo-solo-lectura button:disabled {
  cursor: not-allowed;
}

h1 {
  font-size: 19px;
  line-height: 1.2;
  margin: 0;
  letter-spacing: 0;
}

p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  align-self: center;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-pill.running {
  border-color: #f59e0b;
  background: #fff7ed;
  color: #9a3412;
  font-size: 14px;
  font-weight: 800;
  padding: 9px 16px;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}

.status-pill.warn {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
  font-weight: 700;
}

.topbar-titulo {
  min-width: 0;
  max-width: none;
}

.operacion-badge {
  display: inline-block;
  background: var(--operacion-color, #4b5563);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.operacion-cambio-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
}

.operacion-cambio-overlay[hidden] {
  display: none;
}

.operacion-cambio-caja {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 30px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.3);
}

.operacion-cambio-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid #dbeafe;
  border-top-color: var(--accent-2, #2563eb);
  animation: operacion-cambio-spin 0.8s linear infinite;
}

@keyframes operacion-cambio-spin {
  to { transform: rotate(360deg); }
}

.operacion-color-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.operacion-color-label input[type="color"] {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

/* Bloque compacto de rango de fechas, reubicado a la esquina superior
   izquierda de cada pantalla (fuera del toolbar de filtros) para que el
   resto de filtros y el contenido de abajo respiren mas. */
.view-fecha-esquina {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.view-fecha-esquina-campo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-fecha-esquina-campo label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.view-fecha-esquina input[type="date"] {
  min-height: 30px;
  padding: 0 6px;
}

.operacion-color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Rango de fecha del dashboard: se muestra al costado del titulo dentro del
   topbar (no dentro de la vista), solo visible cuando la vista activa es
   "dashboard" (toggle via [hidden] en switchView). */
.dashboard-rango-controls {
  flex: 0 1 294px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-height: 38px;
  padding: 3px 4px;
  border: 1px solid #e5eaf0;
  border-radius: var(--radius);
  background: #f8fafc;
}

.dashboard-rango-controls input[type="date"] {
  min-width: 0;
  width: 112px;
  padding: 5px 8px;
  font-size: 12px;
}

.dashboard-rango-separador {
  color: var(--muted);
  font-size: 12px;
}

.view {
  display: none;
  padding: 24px;
  min-width: 0;
}

.view.active {
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  row-gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(31, 42, 55, 0.04);
}

.subsection {
  margin-top: 24px;
}

.oc-historial-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.operacion-form {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(180px, 1fr) minmax(110px, 130px) minmax(220px, 1.4fr) auto;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

.operaciones-subpanel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(31, 42, 55, 0.05);
}

.usuario-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.15fr) minmax(190px, 0.7fr);
  gap: 12px;
  align-items: stretch;
  margin: 12px 0;
}

.usuario-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.usuario-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.usuario-card label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.usuario-card label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.usuario-card .filter-control {
  width: 100%;
  min-width: 0;
}

.bodega-form {
  display: grid;
  grid-template-columns: minmax(130px, 170px) minmax(180px, 1fr) minmax(180px, 1fr) minmax(110px, 130px) minmax(220px, 1.4fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.roles-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.roles-selector label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
}

.roles-selector input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.usuario-card-empresas {
  grid-column: 1 / -1;
}

.helper-text {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.usuario-permisos-grid {
  overflow-x: auto;
}

.usuario-permisos-table {
  min-width: 420px;
}

.usuario-permisos-table th,
.usuario-permisos-table td {
  text-align: left;
}

.usuario-permisos-table th:nth-child(2),
.usuario-permisos-table th:nth-child(3),
.usuario-permisos-table td:nth-child(2),
.usuario-permisos-table td:nth-child(3) {
  width: 110px;
  text-align: center;
}

.usuario-permisos-table input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.role-chip {
  display: inline-block;
  padding: 3px 7px;
  margin: 2px 3px 2px 0;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: #eff6ff;
  color: #20507f;
  font-size: 11px;
  font-weight: 700;
}

.usuarios-table {
  min-width: 860px;
}

.clientes-table {
  min-width: 1120px;
}

.cliente-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  align-items: center;
  margin: 10px 0 12px;
}

.cliente-domicilio {
  grid-column: span 2;
}

.clientes-import-panel {
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}

.ventas-sync-panel {
  margin: 10px 0 14px;
  padding: 14px;
  border: 1px solid #93c5fd;
  border-radius: 10px;
  background: #eff6ff;
}

.ventas-sync-controles label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.ventas-sync-panel .table-wrap {
  max-height: 320px;
  margin-top: 10px;
}

.ventas-sync-aplicar {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #86b89b;
  border-radius: 8px;
  background: #f0fdf4;
}

.ventas-sync-aplicar strong {
  display: block;
  margin-bottom: 5px;
  color: #14532d;
}

.ventas-sync-confirmacion {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0;
  color: #344054;
  font-size: 12px;
  line-height: 1.4;
}

.ventas-sync-confirmacion input {
  width: auto;
  min-width: auto;
  min-height: auto;
  margin-top: 2px;
}

.clientes-import-panel .table-wrap {
  max-height: 320px;
  margin-top: 10px;
}

.clientes-paginacion {
  justify-content: flex-end;
}

.code-cell,
.code-cell-wide {
  font-family: "Consolas", "SFMono-Regular", monospace;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.code-cell {
  min-width: 120px;
}

.code-cell-wide {
  min-width: 170px;
}

.text-ellipsis-with-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operacion-descripcion,
.bodega-descripcion {
  min-width: 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  border: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
}

.tab-button.active,
.tab-button:hover {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-color: #fff;
}

.nd-panel {
  display: none;
}

.nd-panel.active {
  display: block;
}

.preparar-oc-panel {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(380px, 1.15fr);
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.po-grupo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.po-grupo-edicion,
.po-grupo-cierre {
  grid-column: span 1;
}

.po-grupo-control {
  justify-content: flex-start;
}

.po-grupo input,
.po-grupo button {
  min-height: 34px;
}

.po-grupo input {
  flex: 1 1 150px;
  min-width: 130px;
}

.po-grupo-cierre input {
  flex-basis: 138px;
}

.po-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 220px;
  border: 1px solid #cdd7e1;
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  padding: 4px 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.po-status:empty {
  display: none;
}

.po-status.warn {
  border-color: #f2c2c2;
  background: #fff5f5;
  color: var(--bad);
}

.po-detalle-tecnico[hidden] {
  display: none;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

/* Carga de archivos: lista compacta tipo panel administrativo, una fila por
   archivo, en vez de tarjetas cuadradas grandes. */
.archivo-lista {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(31, 42, 55, 0.05);
}

.archivo-lista-header,
.archivo-fila {
  display: grid;
  grid-template-columns: minmax(170px, 1.3fr) minmax(150px, 1.5fr) 96px minmax(120px, 1fr) minmax(260px, 1.6fr);
  gap: 12px;
  align-items: center;
  padding: 8px 14px;
}

.archivo-lista-header {
  background: #eef2f6;
  color: #344054;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.archivo-fila {
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.archivo-fila-nombre strong {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.archivo-fila-nombre span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.archivo-fila-destino {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.archivo-modo-nota {
  margin-top: 6px;
  color: #20507f;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
}

.archivo-fila-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.archivo-fila-acciones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.archivo-fila-acciones input[type="file"] {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  font-size: 11px;
  padding: 4px;
}

.archivo-fila-acciones button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.archivo-fila .upload-mensaje {
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  .archivo-lista-header {
    display: none;
  }

  .archivo-fila {
    grid-template-columns: 1fr;
  }
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}

.badge.ok {
  background: #e8f5ee;
  color: var(--ok);
}

.badge.bad {
  background: #faeeee;
  color: var(--bad);
}

.run-panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(31, 42, 55, 0.05);
}

.auditoria-detalle {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.auditoria-detalle section {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.auditoria-detalle section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.auditoria-detalle h3 {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.auditoria-detalle dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.auditoria-detalle dl > div {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 10px;
}

.auditoria-detalle dt { font-weight: 700; }
.auditoria-detalle dd { margin: 0; overflow-wrap: anywhere; }

.run-panel {
  min-height: 72px;
  padding: 14px;
  color: var(--muted);
  white-space: pre-wrap;
  margin-bottom: 16px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 210px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.row-active {
  background: #edf6f8;
}

.acciones-cell {
  white-space: nowrap;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.danger-action {
  color: #b42318;
  border-color: #f3c4bf;
  background: #fff8f7;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: #344054;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  background: #fff;
}

tbody tr:hover td {
  background: #f8fbfd;
}

input,
select {
  width: 100%;
  min-width: 120px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  background: #fff;
}

.empty {
  min-height: 84px;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #f8fafc;
  text-align: center;
}

.section-title {
  font-size: 15px;
  margin: 20px 0 10px;
  color: var(--text);
  font-weight: 800;
}

.section-title:first-child {
  margin-top: 0;
}

.nota-resumen {
  margin: -4px 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.fila-total {
  font-weight: 700;
}

.fila-total td {
  background: #eef2f6;
}

.errores-table td {
  vertical-align: top;
}

.priority-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
}

.priority-pill.prioridad-alta {
  background: #fff1f1;
  color: var(--bad);
  border: 1px solid #f0b8b8;
}

.priority-pill.prioridad-media {
  background: #fff7e8;
  color: #946200;
  border: 1px solid #f0cf8a;
}

.priority-pill.prioridad-baja {
  background: #eef8f2;
  color: var(--ok);
  border: 1px solid #b9dec9;
}

.error-detail-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 12px;
  margin-bottom: 14px;
}

.error-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.error-correction-summary {
  display: block;
  margin-bottom: 10px;
}

.error-detail-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px;
}

.error-correction-summary div {
  min-width: 0;
}

.error-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.error-correction-summary span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.error-detail-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.error-correction-summary strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.correccion-contexto {
  display: grid;
  gap: 10px;
}

.correccion-mensaje {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.correccion-mensaje strong {
  color: #b42318;
}

.correccion-inventario-table .campo-error {
  background: #fff7ed;
  color: #9a3412;
  font-weight: 800;
  box-shadow: inset 0 0 0 2px #fdba74;
}

.correccion-campo-requerido {
  font-size: 13px;
  color: var(--muted);
}

.resumen-linea {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 13px;
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  color: var(--text);
}

.resumen-linea strong {
  color: var(--text);
}

.resumen-linea .sep {
  color: var(--muted);
}

.tabla-compacta {
  max-height: none;
  display: inline-block;
}

.tabla-compacta table {
  min-width: 0;
  width: auto;
}

.tabla-compacta th,
.tabla-compacta td {
  padding: 5px 10px;
  font-size: 12px;
}

.tabla-compacta th {
  position: static;
}

.filter-control {
  width: auto;
  min-width: 160px;
  max-width: 100%;
  flex: 1 1 190px;
}

.compras-recibir-filtros {
  align-items: stretch;
}

.compras-recibir-filtros #compras-recibir-busqueda {
  min-width: 260px;
  flex: 1 1 260px;
}

.detalle-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.compras-recibir-detalle {
  min-height: calc(100vh - 104px);
}

.detalle-busqueda {
  min-width: 320px;
  flex: 1 1 320px;
}

.detalle-table-wrap {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

#po-resumen {
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
}

#po-resumen .stat-card {
  padding: 5px 8px;
  min-height: 44px;
}

.stat-card strong {
  display: block;
  font-size: 15px;
  margin-top: 2px;
  line-height: 1.2;
}

.stat-card span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

#po-resumen .stat-card strong {
  font-size: 14px;
}

#po-resumen .stat-card span {
  font-size: 9px;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

/* Tablas operativas con columnas conocidas (Preparar OC, Presupuesto,
   Pedido final): ancho fijo por tipo de dato en vez de por nombre tecnico. */
.tabla-fija {
  table-layout: fixed;
}

.tabla-fija th,
.tabla-fija td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-sku {
  width: 100px;
  white-space: nowrap;
}

.col-desc {
  white-space: normal;
  overflow-wrap: break-word;
}

.col-clasif {
  width: 70px;
  text-align: center;
}

.col-riesgo {
  width: 90px;
  text-align: center;
}

.col-num {
  width: 85px;
  text-align: right;
}

.col-money {
  width: 105px;
  text-align: right;
}

.col-usuario {
  width: 110px;
}

.col-motivo {
  width: 150px;
  white-space: normal;
  overflow-wrap: break-word;
}

.col-origen {
  width: 100px;
}

.col-proveedor {
  width: 140px;
}

.col-accion {
  width: 110px;
}

.operativo-bar {
  background: #eef2f6;
  border-bottom: 1px solid var(--line);
  padding: 10px 22px 12px;
  position: relative;
  z-index: 2;
}

.operativo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  row-gap: 10px;
  align-items: center;
}

.operativo-controls .filter-control,
.operativo-controls button,
.toolbar .filter-control,
.toolbar button {
  min-height: 36px;
}

.operativo-controls .filter-control {
  flex: 1 1 190px;
  min-width: 180px;
}

.operativo-controls #op-busca,
.toolbar input[placeholder*="Buscar"],
.toolbar input[placeholder*="SKU"],
.toolbar input[placeholder*="descripcion"],
.toolbar input[placeholder*="Descripcion"] {
  flex: 2 1 260px;
  min-width: min(260px, 100%);
}

.operativo-controls button {
  flex: 0 0 auto;
}

.risk-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px;
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid #dbe7ef;
  border-radius: var(--radius);
  background: #f8fbfd;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.risk-legend strong {
  color: var(--text);
}

.compact-risk-legend {
  margin: 8px 0 0;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.guia-risk-legend {
  margin-bottom: 8px;
}

.ventas-fuente-categorias {
  margin: 6px 0 10px;
  padding: 7px 10px;
  border: 1px solid #dbe7ef;
  border-radius: 6px;
  background: #f8fbfd;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ventas-fuente-categorias.warn {
  border-color: #f4c790;
  background: #fff8ed;
  color: #925a16;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.segmented-control button {
  min-height: 32px;
  background: #f8fafc;
  color: var(--muted);
}

.segmented-control button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mapa-ventas-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mapa-ventas-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.mapa-ventas-diagnostico {
  margin: 8px 0 12px;
}

.mapa-ventas-diagnostico details {
  border: 1px solid #dbe7ef;
  border-radius: 6px;
  background: #f8fbfd;
}

.mapa-ventas-diagnostico summary {
  cursor: pointer;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  padding: 9px 11px;
}

.mapa-ventas-diagnostico-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  padding: 8px 10px;
}

.mapa-ventas-diagnostico-grid div {
  border: 1px solid #dbe7ef;
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
}

.mapa-ventas-diagnostico span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.mapa-ventas-diagnostico strong {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.mapa-ventas-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.25fr) minmax(330px, 0.75fr);
  gap: 12px;
  align-items: start;
}

.mapa-ventas-panel,
.mapa-ventas-zonas {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
}

.mapa-ventas-panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
}

.mapa-ventas-panel-head .section-title {
  margin: 0;
}

.mapa-ventas-panel-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mapa-ventas-map {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border: 1px solid #bfd3df;
  border-radius: var(--radius);
  background: #dbeafe;
}

.mapa-ventas-map::before {
  content: none;
}

.mapa-ventas-map .leaflet-control-zoom a {
  color: #0f172a;
}

.mapa-leaflet-icon {
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  text-align: center;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.mapa-leaflet-icon:hover,
.mapa-leaflet-icon.selected {
  transform: scale(1.08);
  border-color: #f59e0b;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.32);
  z-index: 3;
}

.mapa-leaflet-icon span {
  font-size: 13px;
}

.mapa-leaflet-icon small,
.mapa-leaflet-icon em {
  display: block;
  margin-top: 2px;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mapa-leaflet-icon small {
  font-size: 9px;
  font-weight: 800;
}

.mapa-leaflet-icon em {
  font-size: 8px;
  font-style: normal;
  opacity: 0.95;
}

.mapa-bubble-alto {
  background: #15803d;
}

.mapa-bubble-medio {
  background: #0369a1;
}

.mapa-bubble-bajo {
  background: #64748b;
}

.mapa-watermark {
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 6px;
  padding: 4px 7px;
}

.mapa-cluster-icon {
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  text-align: center;
}

.mapa-cluster-icon span,
.mapa-cluster-icon small {
  font-size: 10px;
  font-weight: 800;
}

.mapa-cluster-icon strong {
  font-size: 14px;
  margin: 2px 0;
}

.mapa-popup {
  min-width: 210px;
}

.mapa-popup strong {
  display: block;
  margin-bottom: 6px;
  color: #0f172a;
  font-size: 14px;
}

.mapa-popup dl {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 4px 8px;
  margin: 0 0 8px;
}

.mapa-popup dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mapa-popup dd {
  margin: 0;
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
}

.mapa-ventas-leyenda {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mapa-ventas-leyenda span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.mapa-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.mapa-ventas-tabla {
  max-height: 655px;
  overflow: auto;
}

.selected-row td {
  background: #fff7ed;
}

.mapa-ventas-fullscreen-view.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: calc(100vh - 48px);
}

.mapa-fullscreen-topbar,
.mapa-fullscreen-actions,
.mapa-fullscreen-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.mapa-fullscreen-filtros {
  justify-content: flex-start;
}

.mapa-fullscreen-filtros span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #334155;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.mapa-fullscreen-shell {
  position: relative;
  flex: 1;
  min-height: 68vh;
}

.mapa-ventas-map-fullscreen {
  min-height: 72vh;
  height: calc(100vh - 245px);
}

.mapa-fullscreen-table-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 450;
  width: min(560px, calc(100vw - 44px));
  max-height: calc(100% - 20px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
  padding: 12px;
}

.mapa-fullscreen-table-panel .mapa-ventas-tabla {
  max-height: calc(72vh - 70px);
}

.operativo-clasificaciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
}

.operativo-clasificaciones label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.operativo-status {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.operativo-status.warn {
  color: var(--bad);
  font-weight: 700;
}

.checklist-ok {
  color: var(--ok);
  font-weight: 700;
}

.checklist-falta {
  color: var(--bad);
  font-weight: 700;
}

tr.fila-warn td {
  background: #fbeaea;
}

.modo-avanzado {
  margin-top: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #f8f5ec;
}

.modo-avanzado summary {
  cursor: pointer;
  font-weight: 700;
  color: #7a5b16;
}

.modo-avanzado[open] summary {
  margin-bottom: 12px;
}

.advertencia-avanzado {
  margin: 8px 0 14px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fdf3d9;
  color: #7a5b16;
  font-size: 13px;
}

.recepcion-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  margin-bottom: 14px;
}

.recepcion-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.recepcion-control select {
  flex: 1 1 360px;
}

.recepcion-control input[type="file"] {
  flex: 1 1 260px;
  min-width: 220px;
}

#recepcion-preview-table {
  margin-top: 10px;
}

#recepcion-sugerencias {
  margin-top: 10px;
}

.compact {
  padding: 6px 8px;
  white-space: nowrap;
}

.filtro-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}

.filtro-check input[type="checkbox"] {
  width: auto;
  min-width: 0;
  min-height: 0;
}

.row-recomendada {
  background: #eef8f1;
}

.celda-alerta {
  color: var(--bad);
  font-weight: 700;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
    height: auto;
    overflow: auto;
  }

  .sidebar {
    height: auto;
    min-height: auto;
    max-height: 44vh;
  }

  .sidebar-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .nav-item {
    text-align: center;
  }

  .shell {
    height: auto;
    overflow: visible;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .topbar-actions {
    justify-content: flex-start;
    min-width: 0;
    width: 100%;
  }

  .operacion-selector,
  .comprador-selector,
  .bodega-selector,
  .dashboard-rango-controls {
    width: 100%;
  }

  .operacion-selector select,
  .comprador-selector select,
  .bodega-selector select,
  .dashboard-rango-controls input[type="date"] {
    flex: 1 1 auto;
    min-width: 0;
  }

  .preparar-oc-panel {
    grid-template-columns: 1fr;
  }

  .usuario-form,
  .operacion-form,
  .bodega-form {
    grid-template-columns: 1fr;
  }

  .dashboard-tarjetas,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid .dashboard-panel,
  .dashboard-grid .dashboard-panel:nth-child(1),
  .dashboard-grid .dashboard-panel:nth-child(2) {
    grid-column: auto;
  }

  .operativo-bar {
    position: static;
  }

  .toolbar button,
  .operativo-controls button,
  .recepcion-control button {
    flex: 1 1 180px;
  }

  .filter-control,
  .operativo-controls .filter-control,
  .recepcion-control select,
  .recepcion-control input[type="file"] {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }

  .mapa-ventas-layout {
    grid-template-columns: 1fr;
  }

  .mapa-ventas-map {
    min-height: 360px;
  }

  .mapa-ventas-map-fullscreen {
    min-height: 70vh;
    height: calc(100vh - 260px);
  }
}

.bloque-carga {
  margin-bottom: 20px;
}

.bloque-carga .archivo-lista {
  margin-top: 8px;
}

.upload-mensaje {
  margin-top: 8px;
  font-size: 12px;
}

.upload-mensaje.exito {
  color: var(--ok);
}

.upload-mensaje.error {
  color: var(--bad);
}

.danger-zone {
  margin-top: 30px;
  border: 1px solid var(--bad);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fdf0f0;
}

.advertencia-peligro {
  background: #fbe4e4;
  color: var(--bad);
}

button.danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

button.danger:hover {
  background: #832d2d;
  border-color: #832d2d;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 26, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--panel);
  border-radius: 10px;
  padding: 22px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.modal h2 {
  margin-top: 0;
}

.modal-ancho {
  max-width: 860px;
}

.negado-detalle-chips {
  margin: 10px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.negado-detalle-grupo,
.negado-detalle-desc {
  font-size: 13px;
  line-height: 1.6;
}

.chip {
  display: inline-block;
  background: var(--chip-bg, rgba(120, 130, 160, 0.18));
  border-radius: 12px;
  padding: 2px 10px;
  margin: 2px 4px 2px 0;
  font-size: 12px;
}

.fila-clicable {
  cursor: pointer;
}

.fila-clicable:hover {
  background: rgba(120, 130, 160, 0.12);
}

/* Tarjetas principales: grandes, con aire y un acento de color por tipo
   (azul/rojo/verde/morado/naranja), como en el prototipo aprobado. El fondo
   general, el panel blanco y los bordes suaves reutilizan las mismas
   variables (--bg, --panel, --line) del resto del sistema; solo se agregan
   colores de acento propios del dashboard. */
.dashboard-tarjetas {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}

.dashboard-tarjeta {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  min-height: 146px;
}

.dashboard-tarjeta-azul { border-top-color: #2563eb; }
.dashboard-tarjeta-rojo { border-top-color: #dc2626; }
.dashboard-tarjeta-verde { border-top-color: #16a34a; }
.dashboard-tarjeta-morado { border-top-color: #7c3aed; }
.dashboard-tarjeta-naranja { border-top-color: #ea580c; }

.dashboard-tarjeta-encabezado {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.dashboard-tarjeta-icono {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  background: #f1f5f9;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.dashboard-tarjeta-titulo {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.dashboard-tarjeta-cantidad {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}

.dashboard-tarjeta-sublabel {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.dashboard-tarjeta-detalle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.dashboard-tarjeta-valor {
  font-size: 13px;
  color: var(--accent-2);
  font-weight: 600;
  margin-top: 6px;
}

/* Valor en dinero con el mismo acento de la tarjeta (como el prototipo:
   inventario morado, ventas verde, etc.). */
.dashboard-tarjeta-valor-azul { color: #2563eb; }
.dashboard-tarjeta-valor-rojo { color: #dc2626; }
.dashboard-tarjeta-valor-verde { color: #16a34a; }
.dashboard-tarjeta-valor-morado { color: #7c3aed; }
.dashboard-tarjeta-valor-naranja { color: #ea580c; }

/* Paneles inferiores: compactos y parejos. Los paneles de una misma fila se
   estiran a la misma altura (comportamiento default de grid) y el contenido
   largo (Movimientos recientes) se acota con scroll interno vertical, asi
   ninguna tarjeta rompe la proporcion de su fila. */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.dashboard-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 20px;
  min-width: 0;
  min-height: 260px;
}

.dashboard-grid .dashboard-panel {
  grid-column: span 4;
  margin-bottom: 0;
}

.dashboard-grid .dashboard-panel:nth-child(1),
.dashboard-grid .dashboard-panel:nth-child(2) {
  grid-column: span 6;
}

.dashboard-panel .section-title {
  margin-top: 0;
  margin-bottom: 10px;
}

@media (max-width: 1280px) {
  body {
    grid-template-columns: 238px 1fr;
  }

  .dashboard-tarjetas {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

  .dashboard-grid .dashboard-panel,
  .dashboard-grid .dashboard-panel:nth-child(1),
  .dashboard-grid .dashboard-panel:nth-child(2) {
    grid-column: span 6;
  }

  .usuario-form {
    grid-template-columns: minmax(260px, 1fr) minmax(280px, 1fr);
  }

  .usuario-card-acciones {
    grid-column: 1 / -1;
    grid-template-columns: minmax(180px, 260px) auto;
    align-items: end;
  }

  .usuario-card-acciones h3 {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1080px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-titulo {
    max-width: none;
  }

  .topbar-actions {
    justify-content: flex-start;
    min-width: 0;
    width: 100%;
  }

  .dashboard-grid .dashboard-panel,
  .dashboard-grid .dashboard-panel:nth-child(1),
  .dashboard-grid .dashboard-panel:nth-child(2) {
    grid-column: span 12;
  }
}

.guia-layout {
  display: grid;
  gap: 16px;
  max-width: 1120px;
}

.guia-publica-acciones {
  display: none;
}

body.guia-publica .guia-publica-acciones {
  display: flex;
  justify-content: flex-end;
}

.guia-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.guia-bloque {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px;
}

.guia-bloque h2,
.guia-bloque h3 {
  margin: 0 0 10px;
  letter-spacing: 0;
}

.guia-bloque h2 {
  font-size: 22px;
}

.guia-bloque h3 {
  font-size: 16px;
}

.guia-bloque p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.guia-destacado {
  border-left: 4px solid var(--accent);
}

.guia-ok {
  border-left: 4px solid var(--ok);
}

.guia-alerta {
  border-left: 4px solid var(--bad);
}

.guia-cierre {
  background: #f8fafc;
  color: var(--text);
  font-weight: 700;
}

.guia-lista {
  margin: 0;
  padding-left: 20px;
  line-height: 1.7;
}

.guia-checklist {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.guia-checklist div,
.guia-pantallas div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 12px;
}

.guia-checklist strong,
.guia-pantallas strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.guia-checklist span,
.guia-pantallas span {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.guia-nota-fuerte {
  margin-top: 14px !important;
  color: var(--bad) !important;
  font-weight: 700;
}

.guia-pasos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guia-pasos li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  min-width: 0;
}

.guia-numero {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.guia-pasos strong {
  display: block;
  margin-bottom: 4px;
}

.guia-definiciones {
  display: grid;
  gap: 8px;
  margin: 0;
}

.guia-definiciones dt {
  font-weight: 700;
  color: var(--text);
}

.guia-definiciones dd {
  margin: 0 0 8px;
  padding-bottom: 8px;
  color: var(--muted);
  line-height: 1.45;
  border-bottom: 1px solid var(--line);
}

.guia-definiciones dd:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.guia-pantallas {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.guia-columnas {
  columns: 2;
  column-gap: 28px;
}

.guia-formato {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 900px) {
  .guia-grid {
    grid-template-columns: 1fr;
  }

  .guia-checklist,
  .guia-pasos,
  .guia-pantallas {
    grid-template-columns: 1fr;
  }

  .guia-columnas {
    columns: 1;
  }
}

.dashboard-panel .table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

/* Movimientos recientes: scroll interno vertical para que el panel conserve
   el mismo alto visual que sus vecinos aunque haya mas registros. */
#dashboard-movimientos-table {
  max-height: 280px;
  overflow-y: auto;
}

.dashboard-panel-nota {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.dashboard-barras {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dashboard-barra-fila {
  display: grid;
  grid-template-columns: minmax(0, 170px) 1fr minmax(0, 110px);
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.dashboard-barra-etiqueta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.dashboard-barra-track {
  background: rgba(120, 130, 160, 0.15);
  border-radius: 5px;
  height: 12px;
  overflow: hidden;
}

.dashboard-barra-relleno {
  background: var(--accent, #2563eb);
  height: 100%;
  border-radius: 5px;
}

.dashboard-barra-valor {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent-2);
}


/* Tablas compactas del dashboard: encabezados claros, texto truncado para no
   verse amontonado ni forzar scroll horizontal. */
.dashboard-panel .tabla-compacta table {
  width: 100%;
  table-layout: fixed;
}

.dashboard-panel .tabla-compacta td,
.dashboard-panel .tabla-compacta th {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 8px;
  font-size: 12.5px;
}

.dashboard-panel .tabla-compacta .col-desc {
  max-width: 220px;
}

.modal input {
  width: 100%;
  margin: 10px 0;
}

.modal select,
.modal textarea {
  width: 100%;
  margin: 10px 0;
}

.modal label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cierre-pendiente-resumen {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.reset-scope-note {
  margin: 10px 0;
  color: #8a4b00;
  font-size: 13px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.descargas-oc {
  margin-bottom: 16px;
}

.descarga-oc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  margin-bottom: 8px;
  font-size: 13px;
}

.descarga-oc-item button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.descarga-oc-principal {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  margin-bottom: 10px;
}

.oc-historial-table td {
  vertical-align: middle;
}

.archivos-internos.compact {
  font-size: 12px;
}

.archivos-internos.compact summary {
  cursor: pointer;
  color: var(--accent-2);
  font-weight: 700;
}

.archivos-internos {
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--muted);
}

.archivos-internos summary {
  cursor: pointer;
}

.archivos-internos ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

/* Modulo Ventas */
.ventas-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.ventas-panel {
  display: none;
}

.ventas-panel.active {
  display: block;
}

.ventas-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 5px solid #2563eb;
  border-radius: 8px;
  background: #f8fafc;
}

.ventas-hero h2 {
  margin: 0;
  font-size: 20px;
  color: var(--ink);
}

.ventas-hero p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.ventas-hero-badge {
  white-space: nowrap;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
}

.ventas-kpis,
.ventas-clasificacion-kpis,
.ventas-plan {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.ventas-fillrate-meses {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.ventas-kpi-card {
  border-top: 4px solid #64748b;
  background: #fff;
}

.ventas-kpi-card strong {
  font-size: 21px;
}

.ventas-kpi-verde {
  border-top-color: #16a34a;
}

.ventas-kpi-rojo {
  border-top-color: #dc2626;
}

.ventas-kpi-azul {
  border-top-color: #2563eb;
}

.ventas-kpi-card small,
.ventas-clasif-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.ventas-fillrate-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  margin-bottom: 14px;
}

.ventas-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ventas-panel-header .section-title {
  margin: 0;
}

.ventas-panel-header span {
  color: var(--muted);
  font-size: 12px;
}

.ventas-mes-card,
.ventas-plan-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}

.ventas-mes-card strong,
.ventas-plan-card strong {
  display: block;
  color: var(--ink);
}

.ventas-mes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ventas-mes-head span {
  color: #166534;
  font-size: 18px;
  font-weight: 800;
}

.ventas-fillrate-track {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin: 9px 0 7px;
}

.ventas-fillrate-track div {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
}

.ventas-mes-card small,
.ventas-plan-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.ventas-clientes-wrap {
  max-height: none;
}

.ventas-clientes-table {
  min-width: 1120px;
}

.ventas-clientes-table th {
  background: #eef2f7;
  color: #334155;
  font-size: 11px;
}

.ventas-clientes-table td {
  vertical-align: middle;
}

.ventas-clientes-table tbody tr.fila-clicable {
  cursor: pointer;
}

.ventas-clientes-table tbody tr.fila-clicable:hover {
  background: #f8fafc;
}

.ventas-detalle-row td {
  background: #f8fafc;
  padding: 14px;
}

.ventas-detalle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ventas-detalle-grid h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink);
}

.ventas-mini-chart {
  display: grid;
  gap: 8px;
}

.ventas-mini-row {
  display: grid;
  grid-template-columns: 74px 1fr 110px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.ventas-mini-track {
  height: 9px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.ventas-mini-track div {
  height: 100%;
  background: #16a34a;
}

.ventas-mini-row strong {
  text-align: right;
}

.ventas-indicadores {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ventas-indicadores div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.ventas-indicadores span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.ventas-indicadores strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
}

.ventas-historico-panel {
  margin-bottom: 12px;
}

.ventas-traz-table {
  min-width: 1180px;
}

.ventas-traz-table th {
  background: #eef2f7;
  color: #334155;
  font-size: 11px;
}

.ventas-traz-table td {
  vertical-align: middle;
}

.ventas-traz-table .col-desc {
  width: 240px;
}

.ventas-traz-table .col-sku {
  width: 110px;
}

.ventas-traz-table td:nth-child(3) {
  width: 190px;
}

.ventas-truncada {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ventas-clasif-card {
  border-top: 4px solid #64748b;
}

.ventas-clasif-a {
  border-top-color: #16a34a;
}

.ventas-clasif-b {
  border-top-color: #2563eb;
}

.ventas-clasif-c {
  border-top-color: #f59e0b;
}

.ventas-clasif-d {
  border-top-color: #dc2626;
}

.ventas-plan-pareto {
  border-left: 4px solid #f59e0b;
}

.ventas-historico-agrupacion {
  display: flex;
  gap: 6px;
}

.ventas-historico-barras {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.ventas-historico-fila {
  display: grid;
  grid-template-columns: 90px 1fr 100px;
  align-items: center;
  gap: 10px;
}

.ventas-historico-fecha {
  font-size: 12px;
  color: var(--muted);
}

.ventas-historico-barra {
  display: flex;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--panel-alt, #1e293b);
  min-width: 2%;
}

.ventas-historico-total {
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.ventas-historico-barra .seg {
  height: 100%;
}

.ventas-historico-barra .seg-a {
  background: #16a34a;
}

.ventas-historico-barra .seg-b {
  background: #2563eb;
}

.ventas-historico-barra .seg-c {
  background: #f59e0b;
}

.ventas-historico-barra .seg-d {
  background: #dc2626;
}

@media (max-width: 900px) {
  .ventas-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .ventas-detalle-grid {
    grid-template-columns: 1fr;
  }

  .ventas-mini-row {
    grid-template-columns: 66px 1fr;
  }

  .ventas-mini-row strong {
    grid-column: 2;
    text-align: left;
  }
}

@media (max-width: 860px) {
  body {
    display: block;
    grid-template-columns: none;
    height: auto;
    overflow: auto;
  }

  .sidebar,
  .shell,
  .topbar,
  .context-warnings,
  .view {
    width: 100%;
  }

  .sidebar {
    height: auto;
    max-height: none;
  }

  .shell {
    height: auto;
    overflow: visible;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .operacion-selector,
  .comprador-selector,
  .bodega-selector,
  .dashboard-rango-controls {
    flex: 1 1 100%;
    width: 100%;
  }
}

/* Manual de procesos operativos ------------------------------------------ */

.procesos-resumen {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.procesos-stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-width: 120px;
}

.procesos-stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.procesos-stat-valor {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.procesos-status {
  color: var(--muted);
  margin-bottom: 12px;
}

.procesos-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.procesos-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.procesos-area-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: none;
  border: none;
  border-left: 4px solid var(--accent);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  text-align: left;
}

.procesos-area-header:hover {
  background: var(--bg);
}

.procesos-area-nombre {
  font-weight: 600;
}

.procesos-area-conteo {
  font-size: 12px;
  color: var(--muted);
}

.procesos-area-body {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.procesos-proceso {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.procesos-proceso-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  text-align: left;
}

.procesos-proceso-header:hover {
  background: var(--line);
}

.procesos-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.procesos-tag-vig {
  background: rgba(31, 122, 77, 0.12);
  color: var(--ok);
}

.procesos-tag-mod {
  background: rgba(180, 130, 20, 0.14);
  color: #8a5a10;
}

.procesos-tag-der {
  background: rgba(162, 58, 58, 0.12);
  color: var(--bad);
}

.procesos-pasos {
  list-style: decimal;
  margin: 0;
  padding: 12px 12px 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.procesos-pasos li {
  line-height: 1.4;
}

.procesos-paso-nota {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
