/* ===== VARIABLES — Paleta Futurista Kontablex ===== */
:root {
  /* ── PALETA DE TABLAS Y FILTROS ──────────────────────────────────────────────
     Nace en la conciliación bancaria y se afinó en Asientos Contables (25/09/2026):
     las pantallas estaban en gris claro sobre blanco y no se leían. Cada módulo se
     va pasando a estas variables de uno en uno. */
  --k-borde: #cbd5e1;          /* bordes que se ven, sin ser una raya negra */
  --k-borde-fuerte: #94a3b8;   /* separaciones de verdad: cabecera, pie */
  --k-cabecera: #dbe3ed;       /* fila de títulos de una tabla */
  --k-cebra: #f1f5f9;          /* filas pares */
  --k-hover: #dbeafe;          /* fila bajo el ratón */
  --k-texto: #0f172a;          /* casi negro: el gris claro no se leía */
  --k-apagado: #475569;        /* lo secundario, pero legible */
  --k-panel: #f8fafc;          /* fondo de una barra de filtros */
  --k-oscuro: #1e293b;         /* cuadros de totales */

  /* Cyan eléctrico (acción primaria) */
  /* --primary: #22d3ee; */
  --primary: #0A96B6;
  /* --primary-dark: #0891b2; */
  --primary-dark: #066a83;
  --primary-light: #cffafe;
  --primary-glow: rgba(34, 211, 238, 0.4);

  /* Dorado neon (acentos / destacados) */
  --accent: #fde047;
  --accent-dark: #eab308;

  /* Estados */
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;

  /* Superficies oscuras (sidebar, headers) */
  --dark: #0a1628;
  --dark-2: #0f2235;
  --dark-3: #1a2942;

  /* Sidebar — claro y aireado, hace match con el panel de formulario del login */
  --sidebar-bg: #ffffff;
  --sidebar-bg-solid: #ffffff;
  --sidebar-hover: rgba(34, 211, 238, 0.08);
  --sidebar-active-bg: rgba(34, 211, 238, 0.12);
  --sidebar-active: #0891b2;
  --sidebar-text: #0f172a;
  --sidebar-text-active: #066a83;
  --sidebar-divider: #e2e8f0;
  --sidebar-section: #94a3b8;

  /* Topbar — blanco con acento cyan luminoso (como el login) */
  --topbar-bg: #ffffff;
  --topbar-bg-solid: #ffffff;
  --topbar-text: #1e293b;
  --topbar-text-muted: #64748b;
  --topbar-border: rgba(34, 211, 238, 0.25);

  /* Backgrounds y superficies */
  --bg: #f6fbfd;
  --card-bg: #fff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;

  /* Radio y sombras con glow */
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-glow: 0 0 20px var(--primary-glow);

  --sidebar-width: 220px;
  --topbar-height: 56px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { text-decoration: none; color: inherit; }
/* Enlace clickeable estándar (números de asiento, referencias cruzadas, etc.) */
.link { color: var(--primary); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ===== LOGIN — Diseño Split Futurista ===== */
.login-screen {
  min-height: 100vh; display: flex; background: var(--dark);
}

/* Panel izquierdo — imagen hero a pantalla completa */
.login-hero {
  flex: 1.2;
  background-image: url('../assets/login-hero.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #0a1628; /* fallback mientras carga */
  position: relative;
  overflow: hidden;
}
/* Texto HTML oculto — la imagen ya incluye el branding y tagline */
.login-brand,
.login-tagline { display: none; }

/* Panel derecho — formulario */
.login-form-panel {
  width: 480px; background: #fff;
  display: flex; flex-direction: column; justify-content: center; padding: 60px 56px;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}
.login-form-panel .login-logo {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px var(--primary-glow);
  margin-bottom: 28px;
  font-weight: 900; font-size: 28px; color: #fff;
}
.login-form-panel h2 {
  font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -0.5px;
}
.login-form-panel .login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }

.login-form-panel .form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.login-form-panel .form-label .required { color: var(--danger); }
.login-form-panel .form-group { margin-bottom: 20px; }
.login-form-panel input {
  width: 100%; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: var(--radius);
  outline: none; transition: all .2s; font-size: 14px; background: #f8fafc;
}
.login-form-panel input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.login-form-panel .btn-block {
  width: 100%; padding: 13px; font-size: 15px; font-weight: 600; margin-top: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border: none; border-radius: var(--radius); color: #fff; cursor: pointer;
  transition: all .2s;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.login-form-panel .btn-block:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}
.login-hint { margin-top: 20px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Responsive: en pantallas pequeñas, oculta el hero */
@media (max-width: 900px) {
  .login-hero { display: none; }
  .login-form-panel { width: 100%; }
}

/* ===== TOPBAR ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex; align-items: center; padding: 0 16px; z-index: 100;
  box-shadow: 0 2px 14px rgba(34, 211, 238, .08);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; }
.topbar-brand {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px;
  min-width: 0; overflow: hidden;
  background: var(--brand-gradient, linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-brand i {
  font-size: 20px;
  background: var(--brand-gradient, linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
/* Stats del topbar — configurables por el usuario via el panel de Configurar
   topbar (.topbar-shortcut-cfg). Cuando todas están desactivadas, el contenedor
   queda vacío y no ocupa lugar; si hay activas, se muestran como pills. */
.topbar-stats { display: flex; gap: 12px; overflow: hidden; min-width: 0; align-items: center; }
.topbar-stats:empty { display: none; }
.topbar-shortcuts { display: flex; align-items: center; gap: 2px; flex: 1; flex-wrap: nowrap; overflow-x: auto; padding: 0 8px; margin: 0 4px; }
.topbar-shortcuts::-webkit-scrollbar { height: 4px; }
.topbar-shortcuts::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.topbar-shortcut-btn { background: transparent; border: none; min-width: 64px; padding: 4px 6px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: background 0.15s, transform 0.1s; flex-shrink: 0; }
.topbar-shortcut-btn i { font-size: 16px; }
.topbar-shortcut-label { font-size: 10px; color: var(--topbar-text-muted, var(--text-muted)); white-space: nowrap; line-height: 1; font-weight: 500; }
.topbar-shortcut-btn:hover { background: var(--topbar-shortcut-hover, #f1f5f9); transform: translateY(-1px); }
.topbar-shortcut-btn:hover .topbar-shortcut-label { color: var(--topbar-text, var(--text)); }
.topbar-shortcut-cfg i { color: var(--topbar-text-muted, var(--text-muted)) !important; }
.topbar-shortcut-cfg:hover { background: var(--topbar-shortcut-hover, var(--primary-light)); }
.topbar-shortcut-cfg:hover i { color: var(--topbar-text, var(--primary-dark)) !important; }
/* user name top-right */
.topbar .topbar-user { color: var(--topbar-text, var(--text-muted)); }
@media (max-width: 768px) { .topbar-shortcuts { display: none; } }
.stat-pill {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px;
  background: var(--stat-pill-bg, var(--primary-light)); border-radius: 20px;
  font-size: 12px; color: var(--stat-pill-text, var(--primary-dark)); white-space: nowrap;
  border: 1px solid var(--stat-pill-border, rgba(34, 211, 238, 0.25));
}
.stat-pill i { font-size: 13px; color: var(--stat-pill-text, var(--primary-dark)); }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-shrink: 0; }
.topbar-user { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ===== LAYOUT ===== */
.app { min-height: 100vh; }
.layout { display: flex; margin-top: var(--topbar-height); min-height: calc(100vh - var(--topbar-height)); }

/* ===== SIDEBAR ===== */
:root { --sidebar-collapsed-width: 52px; }

.sidebar {
  width: var(--sidebar-collapsed-width);
  background: var(--sidebar-bg); color: var(--sidebar-text);
  border-right: 1px solid var(--border);
  position: fixed; top: var(--topbar-height); bottom: 0; left: 0;
  overflow: hidden;
  transition: width .25s ease;
  z-index: 90;
  scrollbar-width: thin; scrollbar-color: rgba(34,211,238,.3) transparent;
}
/* Expand on hover */
.sidebar:hover {
  width: var(--sidebar-width);
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(34, 211, 238, .12);
}
.sidebar-nav { padding: 8px 0; }
.nav-item {
  display: flex; align-items: center; gap: 0; padding: 11px 0;
  color: var(--sidebar-text); transition: background .15s, color .15s;
  cursor: pointer; white-space: nowrap; overflow: hidden;
  position: relative;
  font-weight: 500;
}
.nav-item i { color: var(--sidebar-icon, var(--primary)); transition: color .15s; }
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}
.nav-item:hover i { color: var(--sidebar-icon-hover, var(--primary-dark)); }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}
.nav-item.active i { color: var(--sidebar-icon-active, var(--primary-dark)); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--sidebar-accent, var(--primary));
  box-shadow: 0 0 10px var(--sidebar-accent-glow, var(--primary-glow));
}
/* Icon cell — fixed 52px wide always */
.nav-item i {
  min-width: 52px; width: 52px; text-align: center;
  font-size: 16px; flex-shrink: 0;
}
/* Label hidden when collapsed, visible on hover via parent */
.nav-item span {
  opacity: 0; transition: opacity .15s ease;
  font-size: 13px; font-weight: 500;
}
.sidebar:hover .nav-item span { opacity: 1; }

/* ── Collapsible nav-group ── */
.nav-group { position: relative; }

/* Parent item: the toggle row */
.nav-parent { position: relative; }
.nav-parent .nav-arrow {
  min-width: auto; width: auto; font-size: 10px;
  margin-left: auto; margin-right: 14px;
  transition: transform .2s ease;
  opacity: 0;
}
.sidebar:hover .nav-parent .nav-arrow { opacity: 1; }
.nav-group.open .nav-parent .nav-arrow { transform: rotate(180deg); }
.nav-group.open .nav-parent {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}
.nav-group.open .nav-parent i { color: var(--sidebar-icon-active, var(--primary-dark)); }

/* Children container: hidden by default */
.nav-children {
  max-height: 0; overflow: hidden;
  transition: max-height .25s ease;
  background: var(--sidebar-children-bg, rgba(34, 211, 238, .04));
}
.nav-group.open .nav-children { max-height: 480px; }

/* Sub-grupos colapsables (un nivel adentro) */
.nav-subgroup .nav-subparent {
  padding: 8px 0;
  font-size: 12px;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  display: flex; align-items: center;
  cursor: pointer;
}
.nav-subgroup .nav-subparent span {
  flex: 1; padding-left: 52px;
}
.nav-subgroup .nav-subparent .nav-arrow {
  margin-right: 14px; font-size: 10px;
  transition: transform .2s ease;
  opacity: 0;
}
.sidebar:hover .nav-subgroup .nav-subparent .nav-arrow { opacity: 1; }
.nav-subgroup.open .nav-subparent .nav-arrow { transform: rotate(180deg); }
.nav-subgroup.open .nav-subparent {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-icon, var(--primary));
}
.nav-subchildren {
  max-height: 0; overflow: hidden;
  transition: max-height .25s ease;
  background: rgba(0, 0, 0, .12);
}
.nav-subgroup.open .nav-subchildren { max-height: 240px; }
.nav-subchild {
  padding: 8px 0 8px 68px !important;
  font-size: 12.5px !important;
}

/* Individual child row */
.nav-child {
  padding: 9px 0 9px 52px;
  font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
}
.nav-child span { opacity: 0; transition: opacity .15s ease; }
.sidebar:hover .nav-child span { opacity: 1; }

/* The "+" action button inside the child */
/* Link inside nav-child (when using div wrapper) */
.nav-child-link {
  flex: 1; color: inherit; text-decoration: none; display: flex; align-items: center;
}

.nav-child-action {
  background: none; border: none; cursor: pointer;
  color: var(--sidebar-section, var(--text-muted)); font-size: 14px;
  width: 28px; height: 28px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
  display: flex; align-items: center; justify-content: center;
  margin-right: 10px; transition: all .15s;
  opacity: 0;
}
.sidebar:hover .nav-child-action { opacity: 1; }
.nav-child-action:hover {
  background: var(--sidebar-icon, var(--primary)); color: #fff;
  box-shadow: 0 0 10px var(--sidebar-accent-glow, var(--primary-glow));
}

/* Hide children completely when sidebar is collapsed (excepto si .open en móvil) */
.sidebar:not(:hover):not(.open) .nav-children { max-height: 0 !important; }

/* Divider */
.nav-divider {
  height: 0; overflow: hidden; opacity: 0;
  transition: opacity .15s ease, height .15s ease;
  padding: 0 18px; font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--sidebar-section); font-weight: 700;
  white-space: nowrap;
  border-top: 1px solid var(--sidebar-divider);
  margin-top: 8px;
}
.sidebar:hover .nav-divider {
  height: 28px; opacity: 1;
  display: flex; align-items: flex-end; padding-bottom: 4px; padding-top: 12px;
}

/* ===== MAIN CONTENT ===== */
.main-content { margin-left: var(--sidebar-collapsed-width); flex: 1; padding: 20px; transition: margin-left .25s; }
.main-content.expanded { margin-left: 0; }

/* ===== CARDS ===== */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h2 { font-size: 16px; font-weight: 600; color: var(--dark); }
.card-body { padding: 20px; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-weight: 500; transition: all .2s; cursor: pointer; border: none; font-size: 13px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--primary-glow); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); border-color: var(--primary); color: var(--primary-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-icon { width: 34px; height: 34px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all .2s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color .2s; background: #fff; color: var(--text);
}
.form-control:focus { border-color: var(--primary); }
.form-control-sm { padding: 6px 10px; font-size: 13px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

/* Sin flechitas de incremento/decremento en los inputs numéricos — ocupan
   espacio y no se usan; los valores se escriben a mano. */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* Selector de nivel de precio (PVP) en la línea de factura: solo se ve la
   flechita; el valor seleccionado va oculto (color:transparent). Al desplegar
   se ven los valores (las <option> llevan color propio). */
.pvp-select {
  appearance: none; -webkit-appearance: none;
  width: 28px; min-width: 28px; align-self: stretch;
  padding: 0; margin: 0; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: 4px;
  background-color: #fff; color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.pvp-select option { color: #1e293b; }

.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Section titles inside forms */
.form-section-title {
  margin: 0 0 14px; font-size: 14px; font-weight: 600;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* Role checkboxes (persona form) */
.role-checkboxes {
  display: flex; flex-direction: column; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.role-check {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background .1s;
}
.role-check:last-child { border-bottom: none; }
.role-check:hover { background: var(--primary-light); }
.role-check input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

/* Role blocks: cada rol tiene un panel con header (checkbox) y body (cuenta) */
.role-blocks { display: flex; flex-direction: column; gap: 12px; }
.role-block {
  border: 1px solid var(--border); border-radius: var(--radius);
  /* overflow visible para que el dropdown del AccountPicker (position:absolute)
     no quede clipeado dentro del bloque */
  overflow: visible; background: #fff;
}
.role-block-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: 14px; font-weight: 500; cursor: pointer;
  background: #f8fafc;
  /* esquinas superiores redondeadas (el .role-block ya no tiene overflow:hidden) */
  border-radius: var(--radius) var(--radius) 0 0;
}
.role-block-header input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.role-block-body {
  padding: 12px 16px; border-top: 1px solid var(--border);
  background: #fff;
}
.role-block-body label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}

/* Active state for nav-child */
.nav-child.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

/* ── Read-only form mode ── */
.form-readonly {
  position: relative;
  background: #f5f6f8;
  border-radius: var(--radius);
  padding: 20px;
  cursor: not-allowed;
}
.form-readonly::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: var(--radius);
  z-index: 1;
  pointer-events: none;
}
.form-readonly .form-control,
.form-readonly select.form-control {
  background: #e9ecef;
  color: #495057;
  cursor: not-allowed;
  border-color: #d5d8dc;
}
.form-readonly .role-check {
  cursor: not-allowed;
  opacity: .7;
}
.form-readonly .role-check:hover { background: transparent; }
.form-readonly input[type=checkbox] { cursor: not-allowed; }
.form-readonly-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; margin-bottom: 16px;
  background: #fff3cd; border: 1px solid #ffc107;
  border-radius: var(--radius); font-size: 13px; color: #856404;
}
.form-readonly-banner i { font-size: 16px; }

/* Filter labels */
.filter-label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  margin-bottom: 4px;
}

/* ── Invoice success banner ── */
.invoice-success-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; margin-bottom: 0;
  background: #d4edda; border: 1px solid #28a745;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 14px; font-weight: 600; color: #155724;
}
.invoice-success-banner i { font-size: 18px; }

/* ── Invoice toolbar ── */
.invoice-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 16px;
  background: #f0f2f5; border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 14px; min-width: 60px;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: all .15s; color: var(--text);
  font-size: 11px; font-weight: 500;
}
.toolbar-btn i { font-size: 18px; color: var(--primary); }
.toolbar-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.toolbar-btn:disabled { opacity: .5; cursor: not-allowed; }
.toolbar-sep {
  width: 1px; height: 40px; background: var(--border); margin: 0 6px;
}

/* ══ LISTADOS: barra de filtros compacta y tabla legible ══════════════════════
   Nace en Asientos Contables (25/09/2026). Son opt-in: hay que poner la clase.
   La idea: etiqueta corta DENTRO del campo y la explicación en el title, para no
   gastar una línea por cada label. */
.k-filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.k-filtros .form-control { height: 30px; font-size: 12.5px; padding: 3px 8px; border-color: var(--k-borde); color: var(--k-texto); }
/* Un select dibuja su flecha con un background a la derecha: sin ese hueco se le monta sobre el texto. */
.k-filtros select.form-control { padding-right: 26px; }
.k-f { display: flex; align-items: center; gap: 5px; background: #fff; border: 1px solid var(--k-borde); border-radius: 7px; padding: 2px 4px 2px 8px; }
.k-f > span { font-size: 11px; color: var(--k-apagado); white-space: nowrap; font-weight: 600; }
.k-f .form-control { border: 0; box-shadow: none; background: transparent; height: 26px; }
.k-salto { flex-basis: 100%; height: 0; }
.k-rangos { display: inline-flex; border: 1px solid var(--k-borde); border-radius: 7px; overflow: hidden; background: #fff; }
.k-rangos button { border: 0; background: #fff; font-size: 11.5px; padding: 5px 9px; cursor: pointer; color: var(--k-apagado); border-left: 1px solid var(--k-borde); font-weight: 600; }
.k-rangos button:first-child { border-left: 0; }
.k-rangos button:hover { background: var(--k-cabecera); color: var(--k-texto); }
.k-panel { background: var(--k-panel); }
.k-panel.card, .card.k-panel { border: 1px solid var(--k-borde); }
/* Un botón apagado tiene que NOTARSE apagado: .btn:disabled no traía estilo. */
.k-filtros .btn:disabled, .k-filtros .btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; filter: grayscale(.4); }

.data-table.k-tabla { border-collapse: collapse; }
.data-table.k-tabla th { background: var(--k-cabecera); color: var(--k-texto); font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--k-borde-fuerte); }
.data-table.k-tabla th.text-right { text-align: right; }
.data-table.k-tabla td { padding: 7px 10px; font-size: 12.5px; color: var(--k-texto); border-bottom: 1px solid var(--k-borde); }
.data-table.k-tabla tbody tr:nth-child(even) td { background: var(--k-cebra); }
.data-table.k-tabla tbody tr:hover td { background: var(--k-hover); }
.data-table.k-tabla tfoot td { background: var(--k-oscuro); color: #fff; font-weight: 700; padding: 9px 10px; border: 0; }
.data-table.k-tabla tfoot .k-num { color: #fff; }
.data-table.k-tabla .btn-icon { color: var(--k-apagado); }
.data-table.k-tabla .btn-icon:hover { color: var(--primary); }
.data-table.k-tabla .btn-icon.k-borrar:hover { color: var(--danger); }
/* Cifras que se leen en columna, textos largos que no rompen la fila, y lo secundario legible. */
.k-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Una columna alineada a la derecha es, en la práctica, una columna de cifras: que no baile. */
.data-table.k-tabla td.text-right, .data-table.k-tabla th.text-right { font-variant-numeric: tabular-nums; white-space: nowrap; }
.k-elip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-chip { padding: 2px 9px; border-radius: 10px; font-size: 10px; font-weight: 700; white-space: nowrap; letter-spacing: .02em; }
.k-sec { font-size: 11.5px; color: var(--k-apagado); }

/* Document filter rows */
.doc-filters-row {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.doc-filter-field { display: flex; flex-direction: column; }

/* ===== TABLE ===== */
.table-container { overflow-x: auto; }
.data-table th { background: #f8f9fa; padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table.k-tabla tbody tr:last-child td { border-bottom: 1px solid var(--k-borde); }
.data-table tr:hover td { background: #fafbfc; }
.table-actions { display: flex; gap: 4px; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-secondary { background: #e2e3e5; color: #383d41; }

/* ===== SEARCH BAR ===== */
.search-bar { display: flex; gap: 10px; align-items: center; }
.search-input-wrap { position: relative; }
.search-input-wrap input { padding-left: 36px; min-width: 240px; }
.search-input-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; gap: 4px; margin-top: 16px; }
.pagination .page-info { color: var(--text-muted); font-size: 13px; margin-right: auto; }
.page-btn { width: 32px; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--border); font-size: 13px; color: var(--text); transition: all .2s; background: #fff; cursor: pointer; }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 680px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box.modal-lg { max-width: 900px; }
.modal-box.modal-sm { max-width: 440px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ===== ALERTS ===== */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ===== DASHBOARD ===== */
/* ===== INICIO: accesos directos ===== */
.dash-section-title {
  font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); font-weight: 600;
  margin: 24px 0 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}
.quick-action {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px; text-decoration: none; color: var(--text);
  border-radius: var(--radius); border: 1px solid transparent;
  transition: transform .15s, border-color .15s, background .15s;
  cursor: pointer;
}
.quick-action:hover {
  background: #f8fafc; border-color: var(--border);
  transform: translateY(-2px);
}
.quick-action-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.quick-action-cyan   { background: var(--primary-light); color: var(--primary); }
.quick-action-blue   { background: #dbeafe;              color: #2563eb; }
.quick-action-green  { background: #d4edda;              color: var(--success); }
.quick-action-orange { background: #fff3cd;              color: #e67e22; }
.quick-action-purple { background: #ede9fe;              color: #7c3aed; }
.quick-action-red    { background: #f8d7da;              color: var(--danger); }
.quick-action-label {
  font-size: 13px; text-align: center; line-height: 1.3;
  font-weight: 500;
}

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #d4edda; color: var(--success); }
.stat-icon.orange { background: #fff3cd; color: #e67e22; }
.stat-icon.red { background: #f8d7da; color: var(--danger); }
.stat-info h3 { font-size: 26px; font-weight: 700; color: var(--dark); }
.stat-info p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== INVOICE FORM ===== */
.invoice-form { background: #f8f9fa; border-radius: var(--radius); padding: 16px; }
.invoice-form-header { padding: 16px 20px; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, var(--primary-light), #fff); border-radius: var(--radius) var(--radius) 0 0; }
.invoice-form-header h2 { font-size: 15px; font-weight: 600; color: var(--primary-dark); }
.invoice-form-header h2 i { margin-right: 8px; }
.invoice-client-row { padding: 16px 20px; display: flex; gap: 16px; align-items: flex-end; border-bottom: 1px solid var(--border); flex-wrap: wrap; }

/* Document info grid (Contifico-style) */
.doc-info-grid { display: flex; flex-direction: column; gap: 10px; }
.doc-info-row { display: flex; align-items: center; gap: 10px; }
.doc-info-row > label { width: 150px; flex-shrink: 0; font-size: 13px; font-weight: 500; color: var(--text-muted); text-align: right; }
.doc-info-row > input, .doc-info-row > select { max-width: 350px; }
.doc-info-row > div { flex: 1; max-width: 500px; }
.invoice-client-info { flex: 1; min-width: 260px; }
.invoice-client-name { font-weight: 600; color: var(--dark); font-size: 15px; }
.invoice-client-email { font-size: 12px; color: var(--text-muted); }
.invoice-meta { display: flex; gap: 16px; }
.invoice-meta-field label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.invoice-meta-field input { border: 1.5px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; width: 150px; }

.product-search-row { padding: 14px 20px; border-bottom: 1px solid #f0f0f0; display: flex; gap: 10px; align-items: center; background: #fafbfc; }
.product-autocomplete { position: relative; flex: 1; }
.product-autocomplete input { width: 100%; }
.autocomplete-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 1000; max-height: 280px; overflow-y: auto; }
.autocomplete-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.autocomplete-item:hover { background: var(--primary-light); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item .item-name { font-weight: 500; font-size: 13px; }
.autocomplete-item .item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.invoice-items { padding: 0 20px 16px; }
.invoice-items table { margin-top: 8px; }
.invoice-items th { font-size: 11px; }
.invoice-items td input { width: 80px; padding: 5px 8px; border: 1.5px solid var(--border); border-radius: 4px; text-align: right; }
.invoice-items td input.qty { width: 60px; text-align: center; }
.invoice-items td input.price { width: 100px; }
.invoice-items td input.disc { width: 80px; }

.invoice-totals { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.totals-box { width: 320px; }
.total-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.total-row.final { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 16px; }

.invoice-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; gap: 10px; }
.payment-section { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.payment-select { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius); background: #fff; }
.payment-select label { font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.payment-select input[type="number"] { width: 100px; border: none; outline: none; font-size: 13px; }

/* ===== CLIENT SEARCH AUTOCOMPLETE ===== */
.client-search-wrap { position: relative; flex: 1; min-width: 260px; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 20px; font-weight: 700; color: var(--dark); }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: 15px; }

/* ===== CONFIG ===== */
.config-section { margin-bottom: 24px; }
.config-section-title { font-size: 13px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--primary-light); }
.logo-preview { width: 120px; height: 80px; object-fit: contain; border: 1.5px solid var(--border); border-radius: var(--radius); padding: 8px; background: #fff; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast-container > .toast { pointer-events: auto; }
.toast { padding: 12px 18px; border-radius: var(--radius); color: #fff; font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,.2); animation: slideIn .3s ease; display: flex; align-items: center; gap: 8px; min-width: 240px; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
.toast-warning { background: var(--warning); color: #333; }
/* Enlace dentro de un aviso (p. ej. "ver MOV000123"): se tiene que notar que se puede pulsar. */
.toast-link { color: inherit; font-weight: 700; text-decoration: underline; white-space: nowrap; }
.toast-link:hover { opacity: .85; }

/* Toasts importantes (error/warning) flotan centrados sobre la pantalla */
.toast.toast-centered {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 15px;
  padding: 18px 26px;
  min-width: 320px;
  max-width: 520px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  z-index: 10000;
  animation: toastPop .25s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes toastPop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.85); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1);   }
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== CLASES: form modal ===== */
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 4px 0; }
.checkbox-row input[type=checkbox] {
  margin-top: 3px; flex-shrink: 0;
  width: 18px; height: 18px; accent-color: var(--primary);
}
.checkbox-row span { font-size: 13px; line-height: 1.5; }
.checkbox-row small { font-weight: normal; }

.clase-toggle-block {
  border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px; background: #fff;
}

/* ===== ACCOUNT PICKER (autocomplete cuentas) ===== */
.account-picker { position: relative; }
.account-picker-input-wrap { position: relative; }
.account-picker-search {
  padding-right: 36px;  /* hueco para la lupa */
}
.account-picker-icon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; font-size: 13px;
}
.account-picker-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
  max-height: 220px; overflow-y: auto; z-index: 100;
}
.account-picker-option {
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}
.account-picker-option:last-child { border-bottom: none; }
.account-picker-option:hover { background: #f0f9ff; }
.account-picker-empty { padding: 12px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ===== TOGGLE SWITCH (config) ===== */
.config-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 16px;
  background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px;
}
.config-toggle-label { display: flex; flex-direction: column; gap: 4px; }
.config-toggle-label strong { font-size: 14px; color: #1e293b; }
.config-toggle-label small { font-size: 12px; line-height: 1.5; }

.toggle-switch {
  position: relative; display: inline-block;
  width: 52px; height: 28px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 28px;
  transition: background .25s;
}
.toggle-switch-slider::before {
  content: ""; position: absolute;
  height: 22px; width: 22px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: transform .25s;
}
.toggle-switch input:checked + .toggle-switch-slider { background: #22c55e; }
.toggle-switch input:checked + .toggle-switch-slider::before { transform: translateX(24px); }
.toggle-switch input:focus-visible + .toggle-switch-slider {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.d-flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* ===== BACKDROP (móvil — solo cuando sidebar está expandido) ===== */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: var(--topbar-height);   /* deja la topbar accesible */
  left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.45);
  z-index: 89;                 /* justo debajo del sidebar (z-index:90) */
  animation: bd-fade-in .2s ease;
}
.sidebar-backdrop.show { display: block; }
@keyframes bd-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  /* En móvil el sidebar NO depende de :hover para NADA. El único estado que
     expande / revela contenido es .sidebar.open. Esto elimina el :hover
     "pegajoso" del touch y cualquier desincronización entre JS y CSS. */
  .sidebar { width: var(--sidebar-collapsed-width); }
  .sidebar:hover {
    width: var(--sidebar-collapsed-width); box-shadow: none; overflow: hidden;
  }
  .sidebar:hover .nav-item span,
  .sidebar:hover .nav-child span,
  .sidebar:hover .nav-arrow,
  .sidebar:hover .nav-child-action { opacity: 0; }
  .sidebar:hover .nav-divider { height: 0; opacity: 0; }

  /* Solo .sidebar.open expande y revela. */
  .sidebar.open {
    width: 260px;
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
  }
  .sidebar.open .nav-item span,
  .sidebar.open .nav-child span,
  .sidebar.open .nav-arrow,
  .sidebar.open .nav-child-action { opacity: 1; }
  .sidebar.open .nav-divider {
    height: 28px; opacity: 1; display: flex; align-items: flex-end;
    padding-bottom: 4px; padding-top: 12px;
  }
  /* Los submenús se ven SOLO si el sidebar está .open Y el grupo está .open. */
  .sidebar.open .nav-group.open .nav-children { max-height: 480px; }
  .sidebar.open .nav-subgroup.open .nav-subchildren { max-height: 240px; }
  /* Si el sidebar NO está .open, los submenús quedan colapsados pase lo que
     pase — aunque algún .nav-group.open quedara suelto, no rompe el layout.
     SIN dependencia de :hover (esa era la otra mitad del bug). */
  .sidebar:not(.open) .nav-children,
  .sidebar:not(.open) .nav-subchildren { max-height: 0 !important; }

  .main-content { margin-left: var(--sidebar-collapsed-width); padding: 16px; }
  .topbar-stats { display: none; }
  /* El nombre de usuario se oculta en móvil — el botón de salir queda */
  .topbar-user { display: none; }
  .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-2 { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .login-card { width: 100%; margin: 16px; }
}

/* ===== PRINT ===== */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  body { background: #fff; }
}

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover { color: var(--primary); }

/* ===== STATUS COLORS ===== */
.status-pagada { color: var(--success); }
.status-pendiente { color: var(--warning); }
.status-enviada { color: var(--primary); }
.status-autorizada { color: var(--success); }
.status-anulada { color: var(--danger); }

/* ===== PASSWORD TOGGLE (botón ojo) ===== */
.pwd-wrap { position: relative; display: block; width: 100%; }
.pwd-wrap input[type="password"],
.pwd-wrap input[type="text"] {
  width: 100%;
  padding-right: 42px !important;
}
.pwd-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: color .15s, background .15s;
  z-index: 2;
}
.pwd-toggle:hover { color: var(--primary); background: rgba(34, 211, 238, 0.08); }
.pwd-toggle:active { transform: translateY(-50%) scale(0.95); }
.pwd-toggle i { pointer-events: none; }

/* ── Plan de Cuentas: context menu (click derecho) ── */
.pc-context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  padding: 4px 0;
  font-size: 13px;
  user-select: none;
}
.pc-context-menu.hidden { display: none; }
.pc-ctx-item {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.pc-ctx-item:hover { background: var(--primary); color: #fff; }
.pc-ctx-item:hover i { color: #fff !important; }
.pc-ctx-item i { width: 16px; text-align: center; color: var(--text-muted); }
.pc-ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.pc-row { transition: background .1s; }
.pc-row:hover { background: rgba(34, 211, 238, 0.05); }

/* ── Plan de Cuentas: selector de tipo (categoría SRI) ── */
.pc-tipo-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.pc-tipo-item:last-child { border-bottom: none; }
.pc-tipo-item:hover { background: rgba(34, 211, 238, 0.08); }
.pc-tipo-item.active { background: rgba(34, 211, 238, 0.15); font-weight: 600; }
.pc-tipo-grupo {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--border);
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ===== POS — Punto de Venta (pantalla dedicada) ===== */
body.pos-mode .topbar,
body.pos-mode .sidebar,
body.pos-mode #sidebar-backdrop { display: none !important; }
body.pos-mode .layout { margin-top: 0; }
body.pos-mode .main-content { margin-left: 0; padding: 0; }

.pos-screen { display: flex; flex-direction: column; height: 100vh; background: #f1f5f9; }
.pos-header { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: #0f172a; color: #fff; flex-wrap: wrap; }
.pos-brand { font-weight: 700; font-size: 16px; }
.pos-cliente { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 14px; }
.pos-header-actions { display: flex; gap: 8px; }
.pos-body { flex: 1; display: flex; gap: 12px; padding: 12px; overflow: hidden; }
.pos-left { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pos-search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.pos-search input { border: none; outline: none; flex: 1; font-size: 15px; }
.pos-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; align-content: start; }
.pos-prod { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; cursor: pointer; text-align: center; display: flex; flex-direction: column; gap: 6px; transition: transform .05s, box-shadow .1s; }
.pos-prod:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.pos-prod:active { transform: scale(.96); }
.pos-prod-img { width: 100%; aspect-ratio: 1; background: #f8fafc; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.pos-prod-img img { width: 100%; height: 100%; object-fit: cover; }
.pos-noimg { color: #cbd5e1; font-size: 32px; }
.pos-prod-name { font-size: 12px; font-weight: 600; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 29px; }
.pos-prod-price { font-size: 15px; font-weight: 700; color: var(--primary); }
.pos-right { width: 380px; flex-shrink: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; }
.pos-cart-title { padding: 12px 14px; font-weight: 700; border-bottom: 1px solid var(--border); }
.pos-cart { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px; scrollbar-gutter: stable; }
.pos-cart-empty { text-align: center; color: #94a3b8; padding: 40px 10px; }
.pos-cart-empty i { font-size: 36px; display: block; margin-bottom: 8px; }
/* Ítem del carrito POS — 2 filas: (nombre · subtotal · X) arriba, (precio · cantidad) abajo */
.pos-cart-item { display: flex; flex-direction: column; gap: 3px; padding: 7px 10px; border-bottom: 2px solid var(--primary); min-width: 0; box-sizing: border-box; }
.pos-cart-item:nth-child(odd) { background: #f8fafc; }
.pos-cart-item:hover { background: #dbeafe; box-shadow: inset 3px 0 0 var(--primary); }
.pos-cart-item:last-child { border-bottom: none; }
.pos-ci-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pos-ci-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; line-height: 1.3; word-break: break-word; }
.pos-ci-sub { font-weight: 700; font-size: 14px; white-space: nowrap; flex-shrink: 0; }
.pos-ci-del { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 15px; flex-shrink: 0; padding: 0 2px; line-height: 1; }
.pos-ci-bot { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pos-ci-price { font-size: 11px; color: #94a3b8; display: flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; overflow: hidden; }
.pos-ci-qty { display: flex; align-items: center; gap: 5px; flex-shrink: 0; margin-right: auto; }
.pos-ci-qty button { width: 26px; height: 26px; border: 1px solid var(--border); background: #f8fafc; border-radius: 6px; font-size: 16px; cursor: pointer; line-height: 1; }
.pos-ci-qty > span { min-width: 22px; text-align: center; font-weight: 600; }
.pos-totals { padding: 10px 14px; border-top: 1px solid var(--border); }
.pos-tot-row { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
/* POS — desplegable sutil de "Observación del ticket" */
.pos-nota { border-top: 1px solid #eef2f6; }
.pos-nota-toggle { width: 100%; display: flex; align-items: center; gap: 8px; background: none; border: none; padding: 8px 14px; font-size: 12px; color: var(--text-muted); cursor: pointer; text-align: left; }
.pos-nota-toggle:hover { color: var(--primary); background: #f8fafc; }
.pos-nota-chev { margin-left: auto; font-size: 10px; transition: transform .15s; }
.pos-nota-input { display: block; width: calc(100% - 28px); margin: 0 14px 8px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; box-sizing: border-box; }
.pos-nota-input:focus { outline: none; border-color: var(--primary); }
.pos-tot-final { font-size: 18px; font-weight: 800; border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 6px; }
.pos-cart-actions { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.pos-cart-actions .btn { flex: 1; }
.pos-cobrar-btn { flex: 2 !important; font-size: 16px; font-weight: 700; }
.pos-radio { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; flex: 1; }

/* POS — botones del header visibles sobre fondo oscuro */
.pos-header .btn { border: 1px solid rgba(255,255,255,.55); color: #fff; background: rgba(255,255,255,.10); font-weight: 600; }
.pos-header .btn:hover { background: rgba(255,255,255,.22); border-color: #fff; }
.pos-cliente { background: rgba(255,255,255,.10); padding: 6px 12px; border-radius: 8px; }
.pos-cliente #pos-cliente-nombre { font-weight: 700; }

/* POS — selector de cliente inline en el header */
.pos-cliente { flex-wrap: wrap; gap: 8px; }
.pos-persona-wrap { position: relative; }
.pos-persona-wrap input { min-width: 250px; background: #fff; color: #0f172a; }
.pos-persona-sel { font-size: 12.5px; color: #4ade80; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }

/* POS — el dropdown de búsqueda hereda el blanco del header oscuro; forzar texto oscuro */
.pos-cliente .autocomplete-dropdown,
.pos-cliente .autocomplete-item,
.pos-cliente .autocomplete-item .item-name { color: #0f172a; }
.pos-cliente .autocomplete-item:hover { background: #f1f5f9; }

/* POS — precio editable / selector PVP en el carrito */
.pos-ci-precio-inp { width: 58px; flex-shrink: 0; padding: 2px 6px; border: 1px solid var(--primary); border-radius: 5px; font-size: 12px; font-weight: 700; }
.pos-ci-pvp { padding: 2px 4px; border: 1px solid var(--border); border-radius: 5px; font-size: 11px; max-width: 120px; min-width: 0; }
.pos-ci-cu { font-size: 11px; color: #94a3b8; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* POS — selector de vendedor en el header */
.pos-vendedor { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.10); padding: 4px 10px; border-radius: 8px; color: #fff; }
.pos-vendedor select { background: #fff; color: #0f172a; min-width: 150px; }

/* POS — barra de categorías (chips) + estrella de favoritos */
.pos-cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; }
.pos-cat { flex-shrink: 0; padding: 7px 14px; border: 1px solid var(--border); background: #fff; border-radius: 20px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; color: #475569; }
.pos-cat:hover { background: #f1f5f9; }
.pos-cat.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pos-prod { position: relative; }
.pos-fav { position: absolute; top: 4px; right: 4px; z-index: 2; width: 26px; height: 26px; border: none; background: rgba(255,255,255,.85); border-radius: 50%; cursor: pointer; color: #cbd5e1; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.pos-fav:hover { background: #fff; color: #f59e0b; }
.pos-fav.on { color: #f59e0b; }

/* Distintivo de unidad de medida (kg, g, lb…) junto a la cantidad — venta por peso */
.pos-unit-tag { font-size: 12px; font-weight: 700; color: var(--primary); background: #eff6ff; border: 1px solid #bfdbfe; padding: 1px 7px; border-radius: 6px; line-height: 1.6; white-space: nowrap; }
/* Pastilla de unidad en la lista/grid de productos (distingue peso de "unid.") */
.prod-unit-tag { display: inline-block; font-weight: 700; font-size: 9.5px; color: var(--primary); background: #eff6ff; border: 1px solid #bfdbfe; padding: 0 5px; border-radius: 6px; letter-spacing: .2px; text-transform: uppercase; }
/* Selector de unidad de venta (kg/lb/g…) en la línea de factura/recibo/compra */
.item-unit-sel { font-size: 12px; font-weight: 700; color: var(--primary); background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 2px 4px; cursor: pointer; }

/* POS — venta por peso/fracción */
.pos-prod-peso { position: absolute; top: 4px; left: 4px; z-index: 2; background: #0f172a; color: #fff; font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 999px; line-height: 1.4; }
.pos-prod-xu { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.pos-ci-peso { display: inline-flex; align-items: center; gap: 5px; height: 26px; border: 1px solid var(--primary); background: #eff6ff; color: var(--primary); font-weight: 700; font-size: 12px; padding: 0 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.pos-ci-peso i { font-size: 10px; opacity: .8; }
.pos-ci-peso:hover { background: #dbeafe; }
/* ── Pad de peso / importe del POS (compacto, sin scroll) ── */
.pos-pad-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.pos-pad-units { display: flex; gap: 5px; }
/* Botones de unidad (kg/lb/g…) */
.pos-pad-unit { border: 1.5px solid var(--border); background: #fff; color: #475569; font-weight: 700; font-size: 13px; padding: 5px 11px; border-radius: 7px; cursor: pointer; min-width: 42px; }
.pos-pad-unit.active { border-color: var(--primary); background: var(--primary); color: #fff; }
/* Precio base — destacado */
.pos-pad-precio { font-size: 15px; font-weight: 800; color: var(--primary); background: #eff6ff; border: 1px solid #bfdbfe; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.pos-pad-precio small { font-weight: 600; color: #64748b; }
/* Modos: Por peso / Por importe */
.pos-pad-modes { display: flex; gap: 6px; margin-bottom: 8px; }
.pos-pad-mode { flex: 1; border: 1.5px solid var(--border); background: #fff; color: #475569; font-weight: 700; font-size: 13px; padding: 8px 0; border-radius: 8px; cursor: pointer; }
.pos-pad-mode.active { border-color: var(--primary); background: var(--primary); color: #fff; }
/* Pantalla (número grande) */
.pos-pad-screen { display: flex; align-items: baseline; justify-content: center; gap: 6px; background: #0f172a; color: #fff; border-radius: 10px; padding: 12px; margin-bottom: 4px; }
.pos-pad-screen #pos-pad-display { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pos-pad-cur { font-size: 20px; color: #94a3b8; }
.pos-pad-suf { font-size: 17px; color: #94a3b8; }
.pos-pad-conv { text-align: center; font-size: 15px; color: var(--primary); min-height: 20px; margin-bottom: 8px; }
/* Teclado: botones cuadrados compactos */
.pos-pad-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pos-pad-key { border: 1.5px solid var(--border); background: #fff; color: #1e293b; font-size: 19px; font-weight: 600; padding: 10px 0; border-radius: 8px; cursor: pointer; }
.pos-pad-key:hover { background: #f1f5f9; }
.pos-pad-key:active { background: #e2e8f0; }
.pos-pad-actions { display: flex; gap: 8px; margin-top: 10px; }
.pos-pad-actions .btn { flex: 1; }

/* POS — buscador y categorías en la misma fila */
.pos-topbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.pos-topbar .pos-search { margin-bottom: 0; flex: 0 0 340px; }
.pos-topbar .pos-cats { margin-bottom: 0; flex: 1; min-width: 0; padding-bottom: 0; }
