/* =========================================================================
   CRM Plásticos Espinal — Sistema de diseño "Cartel de plaza, versión mostrador"
   La misma marca festiva del sitio público (azul noche, cinta tricolor,
   tipografía de afiche, sombras duras de imprenta) puesta a trabajar:
   la identidad vive en el marco (sidebar, barra, botones); las superficies
   de datos quedan claras, grandes y legibles. Texto grande a propósito:
   el dueño lo pidió así.
   ========================================================================= */

/* ---- Tipografías de la marca (autoalojadas, mismas del sitio público) ---- */
@font-face {
    font-family: "Archivo"; font-style: normal; font-weight: 400 700; font-display: swap;
    src: url("../fonts/archivo-latin.woff2") format("woff2");
}
@font-face {
    font-family: "Archivo Black"; font-style: normal; font-weight: 400; font-display: swap;
    src: url("../fonts/archivoblack-latin.woff2") format("woff2");
}

:root {
    /* Paleta de la marca (la del logo y el sitio público) */
    --noche: #0e1a47;       /* azul noche: el lienzo de la marca */
    --noche-2: #14235c;
    --noche-3: #0a1233;
    --azul: #1e49b8;        /* acción primaria / enlaces */
    --azul-osc: #173a96;
    --rojo: #e63927;        /* vender / peligro / dinero que sale */
    --rojo-osc: #c42b1c;
    --amarillo: #ffc933;    /* selección, resaltado, momento de marca */
    --amarillo-osc: #f0b400;
    --verde: #0f7a43;       /* éxito / cobrar / dinero que entra */
    --verde-osc: #0b5c33;

    /* Superficies y texto */
    --bg: #eef2fc;          /* fondo del área de trabajo (azul clarísimo) */
    --surface: #ffffff;
    --tint: #f5f8ff;
    --text: #131a33;        /* tinta */
    --text-2: #4a5470;      /* tinta secundaria (contraste AA sobre blanco) */
    --muted: #5b6480;
    --line: #dde3f5;
    --line-2: #c3cdeb;

    /* Sombra dura de imprenta: el sello del cartel */
    --dura: 5px 5px 0 rgba(14, 26, 71, .10);
    --dura-sm: 3px 3px 0 rgba(14, 26, 71, .09);
    --dura-oscura: 8px 10px 0 rgba(4, 8, 26, .4);
    --shadow: var(--dura);
    --shadow-sm: var(--dura-sm);

    --radio: 12px;
    --salida: cubic-bezier(0.19, 1, 0.22, 1);
    --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --display: "Archivo Black", "Archivo", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, monospace;

    /* Cinta tricolor: motivo recurrente de la marca */
    --cinta: repeating-linear-gradient(135deg,
        var(--rojo) 0 16px, var(--amarillo) 16px 32px, var(--azul) 32px 48px);

    /* Aliases para estilos inline heredados de versiones anteriores. */
    --azul-800: var(--noche);
    --rojo-600: var(--rojo);
    --bd-azul: var(--line-2);
    --bd-rojo: rgba(230, 57, 39, .35);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;               /* texto grande: requisito del dueño */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background: var(--bg);
}
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 {
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--text);
}
a { color: var(--azul); }
.text-primary { color: var(--azul) !important; }
.text-danger { color: var(--rojo-osc) !important; }
.text-muted { color: var(--muted) !important; }
.text-success { color: var(--verde) !important; }
img { max-width: 100%; }

:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
.sidebar :focus-visible, .topbar :focus-visible { outline-color: var(--amarillo); }

/* El fondo animado de la versión anterior quedó retirado. */
.bg-fondo { display: none; }

/* ========================= LAYOUT (sidebar) ========================= */
.app-shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
    width: 256px; flex: none;
    background: var(--noche);
    color: #c7d1f0;
    display: flex; flex-direction: column;
    padding: 22px 14px 14px;
    position: sticky; top: 0; height: 100vh;
}
/* Cinta tricolor en el borde superior: continúa en la barra del contenido. */
.sidebar::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px;
    background: var(--cinta);
}
.sidebar__brand {
    display: flex; align-items: center; gap: 11px;
    text-decoration: none; color: #fff;
    padding: 6px 8px 18px;
}
.sidebar__logo {
    width: 48px; height: 48px; border-radius: 10px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; flex: none; box-shadow: 3px 3px 0 rgba(4, 8, 26, .45);
}
.sidebar__logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.sidebar__logo i { color: var(--rojo); font-size: 1.3rem; }
.sidebar__name {
    font-family: var(--display); font-weight: 400; font-size: 14px;
    line-height: 1.15; text-transform: uppercase; letter-spacing: .02em; color: #fff;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; padding-top: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 10px;
    color: #c7d1f0; font-size: 15px; font-weight: 600;
    text-decoration: none; transition: background .15s ease, color .15s ease;
}
.nav-item i { font-size: 1.1rem; }
.nav-item:hover { background: var(--noche-2); color: #fff; }
.nav-item.is-active {
    background: var(--noche-2);
    color: #fff; font-weight: 700;
    box-shadow: inset 4px 0 0 var(--amarillo);
}
.nav-item.is-active i { color: var(--amarillo); }
.nav-badge {
    margin-left: auto; font-size: 12px; font-weight: 700;
    color: var(--text); background: var(--amarillo);
    border-radius: 999px; padding: 1px 8px;
}

.sidebar__user { margin-top: auto; padding-top: 12px; }
.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 12px; background: var(--noche-2);
    border: 1px solid rgba(255, 255, 255, .12);
    text-decoration: none; color: #fff;
}
.user-chip:hover { background: var(--noche-3); color: #fff; }
.user-chip__avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--amarillo); color: var(--text);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; flex: none;
}
.user-chip__info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-chip__info strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__info small { color: #c7d1f0; font-size: 12px; }
.user-chip .bi-chevron-up { color: #c7d1f0; }

/* Menú desplegable (perfil) */
.dropdown-menu {
    border: 1px solid var(--line-2);
    border-radius: 12px;
    box-shadow: var(--dura);
    padding: 8px;
    background: #fff;
    min-width: 230px;
}
.dropdown-item {
    border-radius: 9px; padding: 10px 12px; font-weight: 600; font-size: 15px;
    color: var(--text-2); display: flex; align-items: center; gap: .6rem;
    transition: background .15s ease, color .15s ease;
}
.dropdown-item i { font-size: 1.05rem; }
.dropdown-item:hover, .dropdown-item:focus { background: rgba(30, 73, 184, .10); color: var(--azul); }
.dropdown-item.text-danger { color: var(--rojo-osc) !important; }
.dropdown-item.text-danger:hover { background: rgba(230, 57, 39, .12); }
.dropdown-divider { border-top: 1px solid var(--line); margin: 6px 4px; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30; min-height: 80px;
    display: flex; align-items: center; gap: 14px;
    padding: 18px clamp(16px, 2.4vw, 34px) 12px;
    background: var(--noche);
    color: #fff;
}
/* La cinta tricolor cruza también la barra: una sola franja de marca arriba. */
.topbar::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px;
    background: var(--cinta);
}
.topbar__toggle {
    display: inline-flex; width: 44px; height: 44px; border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, .45); background: transparent; color: #fff;
    align-items: center; justify-content: center; cursor: pointer; font-size: 1.3rem; flex: none;
    transition: background .15s ease, border-color .15s ease;
}
.topbar__toggle:hover { background: rgba(255, 255, 255, .1); border-color: #fff; }
/* Logo SIEMPRE visible y centrado en la barra (identidad de marca). */
.topbar__brand {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, calc(-50% + 3px));
    text-decoration: none; display: inline-flex;
}
.topbar__logo {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    height: 54px; padding: 4px 14px;
    background: #fff; border-radius: 10px;
    box-shadow: 3px 3px 0 rgba(4, 8, 26, .45); color: var(--text);
}
.topbar__logo img { height: 100%; width: auto; max-width: 230px; object-fit: contain; }
.topbar__ayuda {
    margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
    background: transparent; color: #fff; text-decoration: none;
    border: 2px solid rgba(255, 255, 255, .45); border-radius: 10px;
    padding: 9px 14px; min-height: 44px; font-size: 15px; font-weight: 700;
    transition: background .15s ease, border-color .15s ease;
}
.topbar__ayuda:hover { background: rgba(255, 255, 255, .1); border-color: #fff; color: #fff; }
/* Vender: la acción más importante del negocio, en amarillo de cartel. */
.topbar__cta {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--amarillo); color: var(--text); text-decoration: none;
    border-radius: 10px; padding: 10px 16px; min-height: 44px;
    font-size: 15px; font-weight: 700;
    transition: transform .16s var(--salida), box-shadow .16s var(--salida), background .15s ease;
}
.topbar__cta:hover {
    background: #ffd45c; color: var(--text);
    transform: translate(-2px, -2px); box-shadow: 4px 4px 0 rgba(4, 8, 26, .45);
}
.topbar__cta:active { transform: none; box-shadow: none; }

.content { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: clamp(16px, 2.4vw, 34px); }

.sidebar-backdrop { display: none; }
@media (max-width: 992px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 1050; transform: translateX(-100%); transition: transform .25s var(--salida); box-shadow: var(--dura-oscura); }
    .sidebar.abierto { transform: none; }
    .topbar__toggle { display: inline-flex; }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(4, 8, 26, .5); z-index: 1040; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    .sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }
}
@media (min-width: 993px) {
    .app-shell.colapsado .sidebar { display: none; }
}

/* ========================= TARJETAS / SUPERFICIES ========================= */
.card { border: 1px solid var(--line-2); border-radius: var(--radio); background: var(--surface); box-shadow: var(--dura-sm); }
.card.shadow-sm { box-shadow: var(--dura-sm) !important; }
.tabla-card, .cmr-card {
    background: var(--surface); border: 1px solid var(--line-2);
    border-radius: var(--radio); box-shadow: var(--dura); overflow: hidden;
}
.tabla-card__cabecera, .cmr-card__cabecera {
    display: flex; justify-content: space-between; align-items: center;
    padding: 13px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-weight: 700; font-size: 1rem; color: var(--text);
}

/* ---- Encabezado de página: título de afiche + acciones ---- */
.cmr-hero, .producto-hero {
    position: relative;
    background: transparent;
    border: 0; border-bottom: 2px solid var(--line-2);
    border-radius: 0; padding: 2px 0 16px;
    box-shadow: none; color: var(--text);
}
.cmr-hero::before, .producto-hero::before { display: none; }
.cmr-hero h1, .producto-hero h1 {
    font-family: var(--display); font-weight: 400;
    text-transform: uppercase; letter-spacing: .01em;
    font-size: 1.5rem; margin-bottom: 2px; color: var(--text);
}
.cmr-hero__contenido, .producto-hero-contenido {
    position: relative; z-index: 2;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.cmr-hero p, .producto-hero p { color: var(--text-2); font-size: 1rem; margin-bottom: 0; }
.cmr-hero .opacity-75, .producto-hero .opacity-75 { opacity: 1 !important; color: var(--text-2); }
.cmr-hero .forma, .producto-hero .forma { display: none; }
.cmr-hero .text-white-50 { color: var(--text-2) !important; }
.cmr-hero .btn-light, .producto-hero .btn-light { background: #fff; border: 1px solid var(--line-2); color: var(--text); }
.cmr-hero .btn-light:hover { background: var(--tint); }

/* Botón de cartel: plano, con sombra dura al pasar el mouse. */
.btn-hero, .btn-nuevo-producto {
    background: var(--rojo);
    color: #fff; border: none; border-radius: 10px;
    padding: 11px 18px; min-height: 44px; font-weight: 700; font-size: 15px; text-decoration: none;
    display: inline-flex; align-items: center; gap: .5rem;
    transition: transform .16s var(--salida), box-shadow .16s var(--salida), background .15s ease;
}
.btn-hero:hover, .btn-nuevo-producto:hover {
    color: #fff; background: var(--rojo-osc);
    transform: translate(-2px, -2px); box-shadow: 4px 4px 0 rgba(14, 26, 71, .22);
}
.btn-hero:active, .btn-nuevo-producto:active { transform: none; box-shadow: none; }

/* ---- KPIs ---- */
.kpi {
    background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radio);
    padding: 16px 18px; box-shadow: var(--dura);
    display: flex; flex-direction: column; gap: .3rem; height: 100%; text-decoration: none;
    transition: transform .16s var(--salida), box-shadow .16s var(--salida);
}
a.kpi:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 rgba(14, 26, 71, .13); }
.kpi__label { font-size: 15px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.kpi__label i { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: rgba(30, 73, 184, .12); color: var(--azul); font-size: 1.05rem; }
.kpi__valor { font-size: 1.9rem; font-weight: 700; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; margin-top: .1rem; }
.kpi__valor.es-rojo { color: var(--rojo-osc); }
.kpi__valor.es-azul { color: var(--azul); }
.kpi:has(.es-rojo) .kpi__label i { background: rgba(230, 57, 39, .12); color: var(--rojo-osc); }
.kpi:has(.es-azul) .kpi__label i { background: rgba(30, 73, 184, .12); color: var(--azul); }
.kpi__pie { font-size: 14px; color: var(--muted); }

/* ---- Tarjetas de estadística ---- */
.stat-card {
    position: relative; overflow: hidden; border-radius: var(--radio);
    padding: 16px 18px; background: var(--surface); border: 1px solid var(--line-2);
    box-shadow: var(--dura); color: var(--text); text-decoration: none; display: block;
    transition: transform .16s var(--salida), box-shadow .16s var(--salida);
}
a.stat-card:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 rgba(14, 26, 71, .13); color: var(--text); }
.stat-card .stat-titulo { font-size: 15px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: .45rem; }
.stat-card .stat-titulo i { display: inline-flex; align-items: center; justify-content: center; width: 29px; height: 29px; border-radius: 8px; font-size: 1rem; }
.stat-card .stat-valor { font-weight: 700; font-size: 1.8rem; font-variant-numeric: tabular-nums; line-height: 1.1; margin-top: .2rem; }
.stat-card .stat-link { font-size: 14px; color: var(--muted); }
.stat-card .stat-icono { position: absolute; right: .55rem; bottom: -.3rem; font-size: 3.4rem; opacity: .08; }
.stat-azul .stat-titulo i { background: rgba(30, 73, 184, .13); color: var(--azul); }
.stat-rojo .stat-titulo i { background: rgba(230, 57, 39, .13); color: var(--rojo-osc); }
.stat-azul-osc .stat-titulo i { background: rgba(14, 26, 71, .10); color: var(--noche); }
.stat-mixto .stat-titulo i { background: rgba(30, 73, 184, .13); color: var(--azul); }
.stat-azul .stat-valor { color: var(--azul); }
.stat-rojo .stat-valor { color: var(--rojo-osc); }
.stat-azul-osc .stat-valor { color: var(--text); }
.stat-mixto .stat-valor { color: var(--azul); }

/* ========================= TABLAS ========================= */
.tabla-cmr { margin: 0; color: var(--text); }
.tabla-cmr thead th {
    background: var(--tint); color: var(--text-2);
    border-bottom: 1px solid var(--line-2); font-size: .8rem;
    text-transform: uppercase; letter-spacing: .05em; font-weight: 700; padding: .6rem .75rem;
}
.tabla-cmr tbody td { vertical-align: middle; padding: .6rem .75rem; border-color: var(--line); font-size: .95rem; font-variant-numeric: tabular-nums; }
.tabla-cmr tbody tr { transition: background .12s ease; }
.tabla-cmr tbody tr:hover { background: var(--tint); }
.tabla-cmr tfoot td { background: var(--tint); color: var(--text); font-weight: 700; padding: .6rem .75rem; border-color: var(--line-2); font-variant-numeric: tabular-nums; }
.table { color: var(--text); }
/* Celdas de dinero y cantidades: a la derecha, con cifras tabulares. */
.cifra { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Filtros por columna y orden */
.fila-filtros th { background: var(--surface); padding: .4rem .5rem !important; border-bottom: 1px solid var(--line); }
.fila-filtros input { width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: .3rem .5rem; font-size: .9rem; }
.fila-filtros input:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 .15rem rgba(30, 73, 184, .18); }
.th-orden { cursor: pointer; user-select: none; white-space: nowrap; }
.th-orden:hover { color: var(--azul); }
.caret-orden { font-size: .7rem; opacity: .9; }

/* ---- Botones pequeños (acciones de tabla) ---- */
.btn-mini { border: none; border-radius: 9px; padding: .5rem .7rem; font-size: .9rem; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; cursor: pointer; transition: background .15s ease, color .15s ease, transform .15s var(--salida), box-shadow .15s var(--salida); }
.btn-mini:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 rgba(14, 26, 71, .18); }
.btn-mini:active { transform: none; box-shadow: none; }
.btn-mini-azul { background: rgba(30, 73, 184, .12); color: var(--azul); }
.btn-mini-azul:hover { background: var(--azul); color: #fff; }
.btn-mini-rojo { background: rgba(230, 57, 39, .12); color: var(--rojo-osc); }
.btn-mini-rojo:hover { background: var(--rojo); color: #fff; }
.btn-mini-solido { background: var(--rojo); color: #fff; }
.btn-mini-solido:hover { background: var(--rojo-osc); color: #fff; }

/* ---- Badges ---- */
.badge-cmr { background: rgba(30, 73, 184, .12); color: var(--azul); padding: .25rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge-rojo { background: rgba(230, 57, 39, .12); color: var(--rojo-osc); }

/* ========================= FORMULARIOS ========================= */
.form-control, .form-select { border: 1px solid var(--line-2); border-radius: 9px; color: var(--text); background: #fff; font-size: 1rem; min-height: 42px; }
.form-control-sm, .form-select-sm { min-height: 34px; font-size: .9rem; }
.form-control:focus, .form-select:focus { border-color: var(--azul); box-shadow: 0 0 0 .2rem rgba(30, 73, 184, .18); }
.input-group-text { background: var(--tint); border: 1px solid var(--line-2); color: var(--text-2); }
.form-label { font-weight: 600; color: var(--text); font-size: .9rem; margin-bottom: .3rem; }
.form-text { color: var(--muted); }

.form-card { border: 1px solid var(--line-2); border-radius: var(--radio); box-shadow: var(--dura); overflow: hidden; background: var(--surface); }
.form-card-cabecera { background: var(--noche); color: #fff; padding: 18px 22px; position: relative; }
.form-card-cabecera h1, .form-card-cabecera .h4, .form-card-cabecera .h5 { color: #fff; }
.form-card-cabecera small { color: #c7d1f0; opacity: 1; }
.form-card-cabecera::after { content: ""; position: absolute; left: 0; bottom: 0; width: 100%; height: 5px; background: var(--cinta); }
.form-seccion-titulo {
    display: inline-block; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em;
    font-weight: 700; color: var(--noche);
    border-bottom: 3px solid var(--amarillo); padding-bottom: .15rem; margin: .4rem 0;
}

.btn-guardar {
    background: var(--rojo); border: none; color: #fff; font-weight: 700;
    border-radius: 10px; padding: .7rem 1.5rem; min-height: 46px; font-size: 1rem;
    transition: transform .16s var(--salida), box-shadow .16s var(--salida), background .15s ease;
}
.btn-guardar:hover { color: #fff; background: var(--rojo-osc); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 rgba(14, 26, 71, .22); }
.btn-guardar:active { transform: none; box-shadow: none; }
.btn-primary { background: var(--azul); border-color: var(--azul); font-weight: 600; }
.btn-primary:hover, .btn-primary:focus { background: var(--azul-osc); border-color: var(--azul-osc); }
.btn-outline-primary { color: var(--azul); border-color: var(--azul); font-weight: 600; }
.btn-outline-primary:hover { background: var(--azul); border-color: var(--azul); }
.btn-success { background: var(--verde); border-color: var(--verde); font-weight: 700; }
.btn-success:hover, .btn-success:focus { background: var(--verde-osc); border-color: var(--verde-osc); }
.btn-outline-success { color: var(--verde); border-color: var(--verde); font-weight: 600; }
.btn-outline-success:hover { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn-danger { background: var(--rojo); border-color: var(--rojo); font-weight: 600; }
.btn-danger:hover { background: var(--rojo-osc); border-color: var(--rojo-osc); }
.btn-outline-danger { color: var(--rojo-osc); border-color: var(--rojo-osc); font-weight: 600; }
.btn-outline-danger:hover { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn-outline-secondary { color: var(--text-2); border-color: var(--line-2); font-weight: 600; }
.btn-outline-secondary:hover { background: var(--tint); color: var(--text); border-color: var(--line-2); }

.dropzone-foto { border: 2px dashed var(--line-2); border-radius: 10px; padding: 1rem; text-align: center; background: var(--tint); transition: border-color .2s ease, background .2s ease; }
.dropzone-foto:hover { border-color: var(--azul); background: rgba(30, 73, 184, .06); }

/* ========================= MODALES / ALERTAS / VARIOS ========================= */
.modal-content { border: 1px solid var(--line-2); border-radius: var(--radio); box-shadow: var(--dura-oscura); }
.modal-header { border-bottom: 1px solid var(--line); padding: 14px 18px; }
.modal-title { font-weight: 700; font-size: 1.1rem; }
.modal-body { padding: 16px 18px; }
.modal-footer { border-top: 1px solid var(--line); padding: 12px 18px; }
.alert { border-radius: 10px; border-width: 1px; font-size: 1rem; }
.alert-success { background: #e8f5ee; border-color: rgba(15, 122, 67, .35); color: #0b5c33; }
.alert-danger  { background: #fdeceb; border-color: rgba(196, 43, 28, .35); color: #a02114; }
.alert-warning { background: #fff4d6; border-color: rgba(240, 180, 0, .5); color: #6e5200; }
.alert-info    { background: #eaf0fd; border-color: rgba(30, 73, 184, .3); color: var(--azul-osc); }

/* Pestañas (cuentas del POS y otras): estilo boleto de feria. */
.nav-tabs { border-bottom: 2px solid var(--line-2); gap: 4px; }
.nav-tabs .nav-link {
    border: 1px solid var(--line-2); border-bottom: 0;
    border-radius: 10px 10px 0 0; background: var(--surface);
    color: var(--text-2); font-weight: 600; font-size: 15px; padding: .55rem .9rem;
}
.nav-tabs .nav-link:hover { color: var(--text); background: var(--tint); }
.nav-tabs .nav-link.active {
    background: var(--amarillo); color: var(--text); font-weight: 700;
    border-color: var(--amarillo-osc);
}

/* ========================= PRODUCTOS (catálogo) ========================= */
.producto-card {
    background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radio);
    overflow: hidden; height: 100%; display: flex; flex-direction: column;
    box-shadow: var(--dura-sm); opacity: 0; animation: aparecer .35s ease forwards;
    transition: transform .2s var(--salida), box-shadow .2s var(--salida);
}
.producto-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 rgba(14, 26, 71, .13); }
.producto-imagen { position: relative; aspect-ratio: 4/3; overflow: hidden; background: var(--tint); }
.producto-imagen img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--salida); }
.producto-card:hover .producto-imagen img { transform: scale(1.05); }
.producto-sin-imagen { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 3rem; color: var(--line-2); background: var(--tint); }
.producto-categoria { position: absolute; top: .6rem; left: .6rem; background: var(--noche); color: #fff; padding: .25rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 700; box-shadow: 2px 2px 0 rgba(4, 8, 26, .3); }
.producto-estado { position: absolute; top: .6rem; right: .6rem; padding: .22rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700; color: #fff; }
.producto-estado.es-activo { background: var(--verde); }
.producto-estado.es-inactivo { background: var(--muted); }
.producto-card.inactivo { opacity: .6; filter: grayscale(.3); }
.producto-card.inactivo:hover { opacity: 1; filter: none; }
.producto-cuerpo { padding: .9rem 1rem .4rem; flex: 1; }
.producto-nombre { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: .3rem; line-height: 1.25; }
.producto-codigo { font-size: .85rem; color: var(--text-2); margin-bottom: .5rem; }
.producto-precio { font-size: 1.45rem; font-weight: 700; color: var(--rojo-osc); font-variant-numeric: tabular-nums; }
.producto-acciones { display: flex; gap: .5rem; padding: .55rem 1rem 1rem; }
.btn-accion { border: none; border-radius: 9px; padding: .55rem; min-height: 40px; font-weight: 600; font-size: .9rem; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; cursor: pointer; transition: all .16s ease; }
.btn-editar { flex: 1; background: rgba(30, 73, 184, .12); color: var(--azul); }
.btn-editar:hover { background: var(--azul); color: #fff; }
.btn-eliminar { background: rgba(230, 57, 39, .12); color: var(--rojo-osc); padding: .55rem .85rem; }
.btn-eliminar:hover { background: var(--rojo); color: #fff; }
.producto-vacio { text-align: center; padding: 3.5rem 1rem; color: var(--text-2); }
.producto-vacio .icono { font-size: 4rem; color: var(--line-2); }
.producto-buscador { border: 1px solid var(--line-2); border-radius: 10px; }
.producto-buscador:focus { border-color: var(--azul); box-shadow: 0 0 0 .15rem rgba(30, 73, 184, .18); outline: none; }

/* ========================= PUNTO DE VENTA ========================= */
.pos-grid { max-height: 460px; overflow-y: auto; padding-right: .25rem; }
.pos-producto {
    width: 100%; height: 100%; text-align: left;
    border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface);
    padding: .65rem .75rem; min-height: 44px; cursor: pointer;
    transition: transform .15s var(--salida), box-shadow .15s var(--salida), border-color .15s ease;
}
.pos-producto:hover { transform: translate(-2px, -2px); border-color: var(--noche); box-shadow: 4px 4px 0 rgba(14, 26, 71, .15); }
.pos-producto:active { transform: none; box-shadow: none; }
.pos-producto .nombre { font-weight: 700; color: var(--text); font-size: .95rem; line-height: 1.25; }
.pos-producto .cod { font-size: .8rem; color: var(--text-2); }
.pos-producto .precio { font-weight: 700; color: var(--rojo-osc); font-variant-numeric: tabular-nums; }
.pos-factura-num { background: var(--noche); border: none; color: #fff; border-radius: 10px; padding: .5rem 1rem; text-align: center; }
.pos-factura-num .num { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos-factura-num .small, .pos-factura-num .opacity-75 { color: #c7d1f0; opacity: 1 !important; }
@media (min-width: 992px) { .pos-cuenta { position: sticky; top: 96px; } }

/* ========================= FACTURA ========================= */
.factura-cabecera { background: var(--noche); color: #fff; text-align: center; padding: 1.5rem 1rem; border-bottom: 6px solid transparent; border-image: var(--cinta) 1; }

/* ========================= ANIMACIONES ========================= */
@keyframes aparecer { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.aparece { opacity: 0; animation: aparecer .35s ease forwards; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .aparece, .producto-card { opacity: 1; }
}

/* ========================= IMPRESIÓN ========================= */
@media print {
    .sidebar, .topbar, .sidebar-backdrop, footer, .d-print-none,
    .fila-filtros, .tabla-card__cabecera, .btn-mini, .producto-acciones { display: none !important; }
    body, .content { background: #fff !important; }
    .app-main, .content { margin: 0 !important; padding: 0 !important; max-width: 100% !important; }
    .factura-print { box-shadow: none !important; border: none !important; }
    /* La factura impresa va en tinta negra sobre blanco: ahorra tinta y
       garantiza legibilidad aunque la impresora no imprima fondos. */
    .factura-cabecera { background: #fff !important; color: #000 !important; border-bottom: 3px solid #000 !important; border-image: none !important; }
    .producto-card, .stat-card, .tabla-card { break-inside: avoid; box-shadow: none !important; }
}

/* ========================= RESPONSIVE ========================= */
@media (max-width: 700px) {
    .topbar { min-height: 76px; }
    .topbar__logo { height: 50px; max-width: 190px; padding: 4px 10px; }
}
@media (max-width: 576px) {
    .cmr-hero, .producto-hero { padding: 2px 0 12px; }
    .cmr-hero h1, .producto-hero h1 { font-size: 1.25rem; }
    .btn-hero, .btn-nuevo-producto { width: 100%; justify-content: center; }
    .kpi__valor, .stat-card .stat-valor { font-size: 1.5rem; }
    .tabla-cmr { min-width: 560px; }

    /* Tabla de líneas de la factura de compra: en móviles muy pequeños se
       apila como tarjetas legibles (cada fila = un producto, con su etiqueta). */
    #lineas-compra { display: block; }
    #lineas-compra tr {
        display: block; border: 1px solid var(--line-2);
        border-radius: 12px; padding: .5rem .75rem; margin-bottom: .75rem;
        background: #fff; box-shadow: var(--dura-sm);
    }
    #lineas-compra td {
        display: flex; align-items: center; justify-content: space-between;
        gap: .75rem; border: 0; padding: .35rem 0;
    }
    #lineas-compra td::before {
        content: attr(data-etq); font-size: .85rem; font-weight: 600;
        color: var(--text-2); flex: 0 0 auto;
    }
    #lineas-compra td > .input-group,
    #lineas-compra td > .form-select,
    #lineas-compra td > .form-control { flex: 1 1 auto; min-width: 0; }
    /* Campos más altos para el dedo (mínimo táctil recomendado). */
    #lineas-compra .form-control, #lineas-compra .form-select { min-height: 44px; }
    #lineas-compra td.sub { font-weight: 700; }
    .tabla-lineas-compra thead { display: none; }

    #sel-proveedor, #sel-proveedor + .btn { min-height: 46px; }
    #sel-proveedor + .btn { font-weight: 600; }
}
