@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../assets/fonts/inter-400-700-latin.woff2") format("woff2");
}

@font-face {
    font-family: "Fraunces";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../assets/fonts/fraunces-700-latin.woff2") format("woff2");
}

:root {
    color-scheme: light;
    --ts-font-body: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
    --ts-font-title: "Fraunces", Georgia, "Times New Roman", serif;
    font-family: var(--ts-font-body);
    --ts-green-950: #00351f;
    --ts-green-900: #00452a;
    --ts-green-800: #075c38;
    --ts-green-700: #147047;
    --ts-green-600: #27865b;
    --ts-green-100: #e6f3e7;
    --ts-green-50: #f2f8ef;
    --ts-cream: #f4ead8;
    --ts-background: #f8f3e9;
    --ts-surface: #fffdf9;
    --ts-gold: #c89420;
    --ts-gold-soft: #f7e8bb;
    --ts-red: #c8332d;
    --ts-red-soft: #fbe6e1;
    --ts-warning: #d8890b;
    --ts-warning-soft: #fff2d3;
    --ts-blue: #2675a8;
    --ts-blue-soft: #e4f1f8;
    --ts-text: #173126;
    --ts-text-strong: #0a2518;
    --ts-text-muted: #6f766f;
    --ts-border: #e6dece;
    --ts-border-strong: #d6cab8;
    --ts-shadow-sm: 0 3px 12px rgba(45, 54, 42, .07);
    --ts-shadow: 0 12px 34px rgba(45, 54, 42, .10);
    --ts-shadow-lg: 0 24px 70px rgba(16, 45, 29, .22);
    --ts-radius-sm: 9px;
    --ts-radius: 15px;
    --ts-radius-lg: 22px;
    --ts-sidebar-width: 276px;

    /* Compatibilidad con variables ya usadas por las páginas. */
    --primario: var(--ts-green-700);
    --primario-oscuro: var(--ts-green-900);
    --oscuro: var(--ts-green-950);
    --texto: var(--ts-text);
    --secundario: var(--ts-text-muted);
}

*, *::before, *::after { box-sizing: border-box; }

html { min-width: 320px; background: var(--ts-background); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ts-text);
    background:
        radial-gradient(circle at 92% 4%, rgba(200, 148, 32, .10), transparent 27rem),
        linear-gradient(135deg, rgba(255, 255, 255, .72), transparent 42rem),
        var(--ts-background);
    font-family: var(--ts-font-body);
    line-height: 1.45;
    overflow-x: hidden;
}

/* Tipografía administrativa. Esta hoja no se carga dentro de /simple/. */
html body,
html body .sidebar,
html body .ts-topbar,
html body button,
html body input,
html body select,
html body textarea,
html body table,
html body th,
html body td,
html body .modal,
html body [role="dialog"],
html body .badge,
html body .estado,
html body .paginacion,
html body .pagination,
html body .breadcrumb,
html body .breadcrumbs {
    font-family: var(--ts-font-body);
}

html body main h1,
html body .encabezado h1,
html body .encabezado-personal h1,
html body .encabezado-documento h1 {
    font-family: var(--ts-font-title);
    font-weight: 700;
    font-optical-sizing: auto;
}

a { color: var(--ts-green-700); }

button, input, select, textarea { font: inherit; }

button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(200, 148, 32, .28);
    outline-offset: 2px;
}

.contenedor {
    display: flex !important;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar e identidad */
body .sidebar,
body .sidebar.seguridad-sidebar {
    position: sticky;
    inset: 0 auto 0 0;
    z-index: 1200;
    width: var(--ts-sidebar-width);
    min-width: var(--ts-sidebar-width);
    height: 100vh;
    padding: 18px 14px 20px;
    color: rgba(255, 255, 255, .86);
    background:
        radial-gradient(circle at 48% 105%, rgba(200, 148, 32, .18), transparent 36%),
        linear-gradient(165deg, var(--ts-green-900), var(--ts-green-950) 68%, #002a19);
    box-shadow: 8px 0 34px rgba(0, 42, 25, .17);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.28) transparent;
}

.sidebar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 120px;
    z-index: -1;
    opacity: .28;
    background:
        linear-gradient(155deg, transparent 44%, rgba(255,255,255,.16) 45% 48%, transparent 49%) 0 35px / 94px 58px repeat-x,
        linear-gradient(25deg, transparent 46%, rgba(200,148,32,.35) 47% 50%, transparent 51%) 30px 62px / 125px 50px repeat-x;
    pointer-events: none;
}

.sidebar > h2 { display: none; }

.ts-brand {
    flex: 0 0 auto;
    margin: 0 5px 14px;
    padding: 4px 8px 14px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.13);
}

.ts-brand-logo-wrap {
    width: 172px;
    height: 150px;
    margin: 0 auto 7px;
    display: grid;
    place-items: center;
    overflow: visible;
    background: transparent;
}

.ts-brand img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

.ts-brand-name {
    display: block;
    color: #fff8e8;
    font-family: var(--ts-font-body);
    font-size: .98rem;
    font-weight: 800;
    letter-spacing: .015em;
}

.ts-brand-subtitle {
    display: block;
    margin-top: 2px;
    color: rgba(255,255,255,.63);
    font-size: .69rem;
    letter-spacing: .12em;
    text-transform: uppercase;
}

body .sidebar a {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 44px;
    gap: 11px;
    margin: 3px 2px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: rgba(255,255,255,.83);
    background: transparent;
    text-decoration: none;
    font-size: .91rem;
    font-weight: 650;
    transition: color .16s ease, background .16s ease, transform .16s ease;
}

body .sidebar a:hover {
    color: #fff;
    background: rgba(255,255,255,.095);
    transform: translateX(2px);
}

body .sidebar a.activo {
    color: #fff;
    border-color: rgba(255,255,255,.10);
    background: linear-gradient(90deg, rgba(94, 152, 82, .46), rgba(255,255,255,.10));
    box-shadow: inset 3px 0 0 var(--ts-gold), 0 6px 18px rgba(0,0,0,.10);
}

.ts-nav-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    display: grid;
    place-items: center;
    color: #f4ead8;
}

.ts-nav-icon svg { width: 21px; height: 21px; stroke: currentColor; }

body .seguridad-sidebar .seguridad-seccion {
    margin: 15px 12px 6px;
    color: rgba(255,255,255,.50);
    font-size: .65rem;
    letter-spacing: .14em;
}

body .seguridad-sidebar .seguridad-usuario {
    margin: auto 3px 0;
    padding: 15px 10px 2px;
    border-top: 1px solid rgba(255,255,255,.14);
}

body .seguridad-sidebar .seguridad-nombre { color: #fff; font-size: .9rem; }
body .seguridad-sidebar .seguridad-roles { color: rgba(255,255,255,.62); font-size: .73rem; }

body .seguridad-sidebar .seguridad-logout {
    min-height: 38px;
    border-radius: 9px;
    border-color: rgba(255,255,255,.18);
    color: rgba(255,255,255,.9);
    background: rgba(255,255,255,.055);
}

body .seguridad-sidebar .seguridad-logout:hover { background: rgba(255,255,255,.12); }

/* Área principal y barra superior */
.contenido {
    flex: 1 1 auto;
    width: calc(100% - var(--ts-sidebar-width));
    min-width: 0;
    padding: 24px clamp(20px, 2.2vw, 38px) 40px !important;
}

.ts-topbar {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.ts-topbar-context { min-width: 0; }

.ts-topbar-eyebrow {
    display: block;
    color: var(--ts-gold);
    font-size: .7rem;
    font-weight: 850;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.ts-topbar-brand {
    display: block;
    margin-top: 2px;
    color: var(--ts-green-950);
    font-family: var(--ts-font-title);
    font-size: 1.02rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ts-topbar-actions { display: flex; align-items: center; gap: 10px; }

.ts-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 285px;
    padding: 6px 12px 6px 7px;
    border: 1px solid var(--ts-border);
    border-radius: 999px;
    background: rgba(255,253,249,.92);
    box-shadow: var(--ts-shadow-sm);
}

.ts-user-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, var(--ts-gold), #9f6c0e);
    font-weight: 900;
    box-shadow: inset 0 0 0 3px rgba(255,255,255,.28);
}

.ts-user-text { min-width: 0; line-height: 1.2; }
.ts-user-name { display: block; color: var(--ts-text-strong); font-size: .86rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-user-role { display: block; margin-top: 3px; color: var(--ts-text-muted); font-size: .67rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ts-topbar-logout,
.ts-menu-toggle {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--ts-border);
    border-radius: 50%;
    color: var(--ts-green-800);
    background: var(--ts-surface);
    cursor: pointer;
    box-shadow: var(--ts-shadow-sm);
}

.ts-topbar-logout:hover,
.ts-menu-toggle:hover { color: #fff; background: var(--ts-green-700); border-color: var(--ts-green-700); }
.ts-topbar-logout svg, .ts-menu-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.ts-menu-toggle { display: none; border-radius: 11px; }
.ts-sidebar-overlay { display: none; }

/* Encabezados */
.encabezado {
    position: relative;
    min-height: 124px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin: 0 0 24px !important;
    padding: 25px clamp(22px, 3vw, 36px) !important;
    overflow: hidden;
    border: 1px solid rgba(214,202,184,.82) !important;
    border-radius: var(--ts-radius-lg) !important;
    color: var(--ts-text) !important;
    background:
        radial-gradient(ellipse at 90% 120%, rgba(200,148,32,.16), transparent 42%),
        linear-gradient(105deg, rgba(255,255,255,.98), rgba(255,252,244,.88)) !important;
    box-shadow: var(--ts-shadow) !important;
}

.encabezado::after {
    content: "";
    position: absolute;
    right: -15px;
    bottom: -25px;
    width: 43%;
    height: 95px;
    opacity: .34;
    background:
        linear-gradient(155deg, transparent 47%, var(--ts-gold-soft) 48% 52%, transparent 53%) 0 18px / 100px 60px repeat-x,
        linear-gradient(25deg, transparent 47%, #dfe9d7 48% 52%, transparent 53%) 20px 42px / 130px 58px repeat-x;
    pointer-events: none;
}

.encabezado > * { position: relative; z-index: 1; }

.encabezado h1 {
    margin: 0 0 5px !important;
    color: var(--ts-green-950) !important;
    font-family: var(--ts-font-title);
    font-size: clamp(1.75rem, 2.8vw, 2.55rem) !important;
    line-height: 1.08;
    letter-spacing: -.025em;
}

.encabezado p { margin: 0; max-width: 720px; color: var(--ts-text-muted) !important; }

h2, h3 { color: var(--ts-text-strong); }

.seccion-titulo,
.encabezado-seccion,
.panel-cabecera,
.barra-listado,
.historial-encabezado {
    border-color: var(--ts-border) !important;
}

/* Superficies y tarjetas */
.panel,
.panel-tabla,
.panel-filtros,
.panel-cxc,
.panel-formula,
.panel-costos,
.panel-costos-detalle,
.panel-costos-formulario,
.panel-datos-operativos,
.panel-producto-terminado,
.panel-lote-resultado,
.tarjeta,
.tarjeta-catalogo,
.seccion-detalle,
.seccion-formulario,
.subseccion,
.historial,
.resultado-visual,
.resumen-confirmacion,
.confirmacion-cabecera,
.detalle-cabecera,
.detalle-producto-terminado {
    border-color: var(--ts-border) !important;
    border-radius: var(--ts-radius) !important;
    background: var(--ts-surface) !important;
    box-shadow: var(--ts-shadow-sm) !important;
}

.resumen {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)) !important;
    gap: 14px !important;
    margin: 0 0 22px !important;
}

.resumen .tarjeta,
.tarjeta {
    position: relative;
    min-height: 112px;
    padding: 20px !important;
    overflow: hidden;
}

.resumen .tarjeta::before,
.tarjeta::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(var(--ts-green-600), var(--ts-green-800));
}

.tarjeta p { margin-top: 0; color: var(--ts-text-muted) !important; font-size: .82rem; font-weight: 700; }
.tarjeta h2, .tarjeta strong { color: var(--ts-green-950) !important; }

.catalogos-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)) !important;
    gap: 18px !important;
}

.tarjeta-catalogo {
    position: relative;
    min-height: 230px;
    padding: 24px !important;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.tarjeta-catalogo.habilitada:hover {
    transform: translateY(-3px);
    border-color: #b6ccb4 !important;
    box-shadow: var(--ts-shadow) !important;
}

.tarjeta-catalogo .identificador {
    width: 54px !important;
    height: 54px !important;
    display: grid;
    place-items: center;
    border-radius: 15px !important;
    color: var(--ts-green-900) !important;
    background: var(--ts-green-100) !important;
    font-weight: 900;
}

.tarjeta-catalogo h2 { font-family: var(--ts-font-title); }
.tarjeta-catalogo p { color: var(--ts-text-muted) !important; }
.nota-pendientes { color: var(--ts-text-muted) !important; }

/* Tablas */
.tabla-contenedor,
.tabla-formulario-contenedor {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    border: 1px solid var(--ts-border) !important;
    border-radius: 13px !important;
    background: var(--ts-surface) !important;
    scrollbar-width: thin;
    scrollbar-color: #c9bda9 transparent;
}

table {
    width: 100%;
    border-collapse: collapse;
    color: var(--ts-text);
    background: transparent;
}

th {
    padding: 13px 14px !important;
    border-bottom: 1px solid var(--ts-border-strong) !important;
    color: #43564a !important;
    background: #f3eee3 !important;
    font-size: .71rem !important;
    font-weight: 850 !important;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    padding: 13px 14px !important;
    border-bottom: 1px solid #eee8dd !important;
    color: var(--ts-text);
    vertical-align: middle;
}

tbody tr { transition: background .14s ease; }
tbody tr:hover { background: rgba(230,243,231,.55) !important; }
tbody tr:last-child td { border-bottom: 0 !important; }

/* Formularios */
label {
    color: #33483b !important;
    font-size: .79rem !important;
    font-weight: 800 !important;
    letter-spacing: .01em;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    min-height: 45px;
    padding: 10px 12px !important;
    border: 1px solid #cfc5b6 !important;
    border-radius: var(--ts-radius-sm) !important;
    color: var(--ts-text) !important;
    background: #fffefb !important;
    box-shadow: inset 0 1px 2px rgba(37,48,40,.025);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea { min-height: 92px; resize: vertical; }

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    outline: none !important;
    border-color: var(--ts-green-600) !important;
    box-shadow: 0 0 0 3px rgba(39,134,91,.14) !important;
    background: #fff !important;
}

input:disabled,
input[readonly],
select:disabled,
textarea:disabled {
    color: #737a73 !important;
    background: #f2eee6 !important;
    cursor: not-allowed;
}

input[type="checkbox"], input[type="radio"] {
    accent-color: var(--ts-green-700);
}

.campo,
.campo-filtro,
.campo-historial { min-width: 0; }

.ayuda,
.ayuda-campo,
.texto-ayuda,
.texto-secundario,
.modal-descripcion { color: var(--ts-text-muted) !important; }

.filtros,
.filtros-historial,
.filtros-lotes,
.formulario-grid,
.campos-encabezado,
.campos-costos,
.datos-generales {
    gap: 14px !important;
}

/* Botones */
.boton,
.boton-administrar,
.boton-accion,
.boton-editar,
.boton-activar,
.boton-confirmar,
.boton-cobro,
.boton-abono,
.boton-sin-pago,
.seguridad-acceso-denegado a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px !important;
    border: 1px solid var(--ts-green-700) !important;
    border-radius: 9px !important;
    color: #fff !important;
    background: linear-gradient(145deg, var(--ts-green-700), var(--ts-green-800)) !important;
    box-shadow: 0 4px 12px rgba(20,112,71,.16);
    text-decoration: none;
    font-weight: 800 !important;
    cursor: pointer;
    transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

.boton:hover,
.boton-administrar:hover,
.boton-accion:hover,
.boton-editar:hover,
.boton-activar:hover,
.boton-confirmar:hover,
.boton-cobro:hover,
.boton-abono:hover,
.boton-sin-pago:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
    box-shadow: 0 7px 17px rgba(20,112,71,.22);
}

.boton-secundario,
.boton-cancelar:not(.cerrar-modal),
.volver-catalogos,
.boton-ver,
.boton-ver-lote,
.boton-imprimir,
.boton-estado {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 15px !important;
    border: 1px solid var(--ts-border-strong) !important;
    border-radius: 9px !important;
    color: var(--ts-green-900) !important;
    background: #f7f2e8 !important;
    text-decoration: none;
    font-weight: 800 !important;
    cursor: pointer;
}

.boton-rechazar,
.boton-desactivar,
.boton-eliminar,
.boton-peligro {
    min-height: 40px;
    padding: 9px 14px !important;
    border: 1px solid #d85b52 !important;
    border-radius: 9px !important;
    color: #fff !important;
    background: linear-gradient(145deg, #d34b43, var(--ts-red)) !important;
    font-weight: 800 !important;
    cursor: pointer;
}

button:disabled,
.boton:disabled,
.boton-administrar:disabled {
    opacity: .55 !important;
    filter: grayscale(.2);
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.cerrar-modal {
    color: var(--ts-text-muted) !important;
    background: transparent !important;
    border-color: transparent !important;
}

.acciones,
.acciones-historial {
    display: flex !important;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px !important;
}

.boton-ver,
.boton-ver-lote,
.boton-imprimir,
.boton-estado,
.boton-eliminar,
.boton-peligro {
    min-height: 34px;
    padding: 6px 10px !important;
    border-radius: 8px !important;
    font-size: .76rem !important;
    font-weight: 800 !important;
    cursor: pointer;
}

/* Modales */
.modal {
    z-index: 5000 !important;
    padding: 22px !important;
    background: rgba(4, 31, 19, .64) !important;
    backdrop-filter: blur(5px);
}

.modal[hidden] { display: none !important; }

.modal-contenido {
    width: min(100%, 880px);
    max-height: calc(100vh - 44px) !important;
    padding: clamp(22px, 3vw, 34px) !important;
    overflow-y: auto !important;
    border: 1px solid rgba(255,255,255,.72) !important;
    border-radius: 19px !important;
    color: var(--ts-text) !important;
    background: var(--ts-surface) !important;
    box-shadow: var(--ts-shadow-lg) !important;
}

.modal-contenido.grande,
.modal-contenido.detalle,
.modal-contenido.modal-amplio { width: min(100%, 1180px) !important; }

.modal-contenido.confirmacion,
.modal-contenido.modal-contenido-confirmacion { width: min(100%, 980px) !important; }

.modal-contenido.pequeno { width: min(100%, 520px) !important; }

html body .modal-contenido h2,
html body .modal-encabezado h2,
html body .modal-cabecera h2,
html body .vm-dialog h2 {
    color: var(--ts-green-950) !important;
    font-family: var(--ts-font-title);
    font-weight: 700;
    font-optical-sizing: auto;
    font-size: clamp(1.35rem, 2vw, 1.75rem);
}

.modal-encabezado {
    margin: calc(clamp(22px, 3vw, 34px) * -1) calc(clamp(22px, 3vw, 34px) * -1) 22px !important;
    padding: 20px clamp(22px, 3vw, 34px) !important;
    border-bottom: 1px solid var(--ts-border) !important;
    background: linear-gradient(100deg, #f4f7ed, #fffaf0) !important;
}

.modal-botones,
.modal-acciones,
.acciones-modal {
    gap: 10px !important;
    margin-top: 24px !important;
    padding-top: 18px !important;
    border-top: 1px solid var(--ts-border) !important;
}

/* Administración de usuarios, roles y permisos */
.permisos {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 13px !important;
}

.grupo-permisos {
    padding: 15px !important;
    border: 1px solid var(--ts-border) !important;
    border-radius: 12px !important;
    background: #f8f4eb !important;
}

.grupo-permisos h3 {
    margin: 0 0 10px !important;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ts-border);
    color: var(--ts-green-900) !important;
    font-size: .82rem !important;
    letter-spacing: .055em;
}

.permiso,
.rol-opcion {
    display: flex !important;
    align-items: flex-start !important;
    gap: 9px !important;
    padding: 9px !important;
    border: 1px solid transparent;
    border-radius: 9px !important;
    background: #fff !important;
    transition: border-color .14s ease, background .14s ease;
}

.permiso:hover,
.rol-opcion:hover { border-color: #bfd2bb; background: var(--ts-green-50) !important; }
.permiso input,
.rol-opcion input { width: 17px !important; height: 17px !important; min-height: 17px !important; flex: 0 0 17px; margin-top: 2px; }
.permiso small { color: var(--ts-text-muted) !important; }

.roles-lista {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
    padding: 12px !important;
    border: 1px solid var(--ts-border) !important;
    border-radius: 11px !important;
    background: #f8f4eb !important;
}

/* Estados, mensajes y alertas */
.ts-badge,
.estado,
.etiqueta,
.estado-catalogo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 27px;
    padding: 4px 9px !important;
    border: 1px solid transparent !important;
    border-radius: 999px !important;
    font-size: .7rem !important;
    font-weight: 850 !important;
    letter-spacing: .025em;
    line-height: 1.1;
}

.ts-badge--success,
.estado-activo,
.estado-confirmado,
.estado-completo,
.estado-pagada,
.estado-normal {
    color: #175d35 !important;
    border-color: #bcdcbc !important;
    background: #e8f5e5 !important;
}

.ts-badge--warning,
.estado-pendiente,
.estado-borrador,
.estado-parcial,
.estado-incompleto {
    color: #8b5a00 !important;
    border-color: #efd89e !important;
    background: var(--ts-warning-soft) !important;
}

.ts-badge--danger,
.estado-inactivo,
.estado-rechazado,
.estado-anulado,
.estado-bloqueado,
.estado-vencida,
.estado-stock-bajo {
    color: #9d2b27 !important;
    border-color: #efc1ba !important;
    background: var(--ts-red-soft) !important;
}

.ts-badge--info,
.estado-contado,
.estado-credito {
    color: #1c638e !important;
    border-color: #b8d8e8 !important;
    background: var(--ts-blue-soft) !important;
}

.mensaje,
.aviso,
.nota,
.advertencia-calidad,
.aviso-borrador,
.aviso-costos-borrador,
.aviso-pago-inicial,
.mensaje-costeo {
    border-radius: 10px !important;
    box-shadow: none !important;
}

.mensaje.exito,
.mensaje-exito { color: #175d35 !important; border-color: #bcdcbc !important; background: #e8f5e5 !important; }
.mensaje.error,
.mensaje-error { color: #9d2b27 !important; border-color: #efc1ba !important; background: var(--ts-red-soft) !important; }
.mensaje.advertencia { color: #8b5a00 !important; border-color: #efd89e !important; background: var(--ts-warning-soft) !important; }

body .seguridad-toast {
    color: #8f2c27;
    border-color: #efc1ba;
    border-radius: 12px;
    background: #fff5f1;
    box-shadow: var(--ts-shadow);
}

body .seguridad-acceso-denegado {
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-lg);
    background: var(--ts-surface);
    box-shadow: var(--ts-shadow);
}

/* Venta: condición y pago inicial */
.opciones-condicion {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
}

.opcion-condicion {
    min-height: 108px;
    border: 2px solid var(--ts-border) !important;
    border-radius: 14px !important;
    background: #fffdf8 !important;
}

.opcion-condicion:has(input:checked) {
    border-color: var(--ts-green-600) !important;
    background: var(--ts-green-50) !important;
    box-shadow: 0 0 0 3px rgba(39,134,91,.10) !important;
}

.pago-inicial-panel,
.cliente-credito-confirmacion,
.condicion-venta-panel {
    border-color: var(--ts-border) !important;
    border-radius: 14px !important;
    background: #fbf7ee !important;
}

.importe-destacado,
.dato-costo-destacado,
.total-final { color: var(--ts-green-900) !important; }

/* Dashboard */
.ts-dashboard-hero {
    min-height: 160px;
    align-items: center;
}

.ts-dashboard-welcome { max-width: 740px; }
.ts-dashboard-welcome .ts-welcome { color: var(--ts-green-800); font-weight: 800; }

.ts-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 22px;
    align-items: start;
}

.ts-dashboard-main,
.ts-dashboard-side { display: grid; gap: 22px; min-width: 0; }

.ts-section-card {
    padding: 22px;
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius);
    background: var(--ts-surface);
    box-shadow: var(--ts-shadow-sm);
}

.ts-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 17px;
}

.ts-section-heading h2 { margin: 0; font-size: 1.08rem; }
.ts-section-heading p { margin: 3px 0 0; color: var(--ts-text-muted); font-size: .82rem; }

.ts-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 13px;
}

.ts-metric {
    position: relative;
    min-height: 144px;
    display: grid;
    grid-template-columns: 48px 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 8px 12px;
    padding: 18px;
    border: 1px solid var(--ts-border);
    border-radius: 14px;
    color: inherit;
    background: #fff;
    text-decoration: none;
    box-shadow: var(--ts-shadow-sm);
    transition: transform .16s ease, box-shadow .16s ease;
}

.ts-metric:hover { transform: translateY(-2px); box-shadow: var(--ts-shadow); }
.ts-metric-icon { grid-row: 1 / span 2; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; color: var(--ts-green-800); background: var(--ts-green-100); }
.ts-metric-icon svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.ts-metric-label { color: var(--ts-text-muted); font-size: .78rem; font-weight: 750; }
.ts-metric-value { align-self: end; color: var(--ts-text-strong); font-size: 1.75rem; font-weight: 900; line-height: 1; }
.ts-metric-link { grid-column: 1 / -1; padding-top: 9px; border-top: 1px solid var(--ts-border); color: var(--ts-green-700); font-size: .73rem; font-weight: 850; }
.ts-metric.ts-loading .ts-metric-value { color: #aaa193; font-size: 1rem; }
.ts-metric.ts-danger .ts-metric-icon { color: var(--ts-red); background: var(--ts-red-soft); }
.ts-metric.ts-gold .ts-metric-icon { color: #9c6a05; background: var(--ts-gold-soft); }

.ts-quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.ts-quick-action { min-height: 105px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px; border: 1px solid var(--ts-border); border-radius: 14px; color: var(--ts-green-900); background: var(--ts-green-50); text-align: center; text-decoration: none; font-size: .78rem; font-weight: 850; }
.ts-quick-action:hover { border-color: #aac6a7; background: #e7f2e3; }
.ts-quick-action svg { width: 29px; height: 29px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.ts-alert-list { display: grid; gap: 10px; }
.ts-alert-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 13px; border-radius: 12px; color: #754c03; background: var(--ts-warning-soft); }
.ts-alert-item.danger { color: #8f2c27; background: var(--ts-red-soft); }
.ts-alert-item.success { color: #175d35; background: var(--ts-green-100); }
.ts-alert-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.65); font-weight: 900; }
.ts-alert-text strong { display: block; font-size: .78rem; }
.ts-alert-text span { display: block; margin-top: 2px; font-size: .68rem; opacity: .83; }
.ts-alert-count { min-width: 27px; height: 27px; display: grid; place-items: center; padding: 0 7px; border-radius: 999px; color: #fff; background: currentColor; font-size: .72rem; font-weight: 900; }
.ts-alert-count > span { color: #fff; }

.ts-modules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 12px; }
.ts-module-link { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 13px; border: 1px solid var(--ts-border); border-radius: 12px; color: inherit; background: #fff; text-decoration: none; }
.ts-module-link:hover { border-color: #b6ccb4; background: var(--ts-green-50); }
.ts-module-link-icon { width: 39px; height: 39px; flex: 0 0 39px; display: grid; place-items: center; border-radius: 11px; color: var(--ts-green-800); background: var(--ts-green-100); }
.ts-module-link-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.ts-module-link strong { display: block; font-size: .82rem; }
.ts-module-link span { display: block; margin-top: 2px; color: var(--ts-text-muted); font-size: .68rem; }

.ts-empty { margin: 0; padding: 20px; border: 1px dashed var(--ts-border-strong); border-radius: 12px; color: var(--ts-text-muted); background: #fbf8f1; text-align: center; }

/* Login */
body.ts-login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 12% 18%, rgba(200,148,32,.18), transparent 24rem),
        linear-gradient(120deg, rgba(0,69,42,.97) 0 42%, rgba(0,69,42,.88) 42.1% 43%, transparent 43.1%),
        linear-gradient(145deg, #efe3cc, #fffdf8 70%);
}

.ts-login-shell {
    width: min(100%, 980px);
    min-height: 610px;
    display: grid;
    grid-template-columns: minmax(300px, .95fr) minmax(360px, 1.05fr);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.52);
    border-radius: 26px;
    background: var(--ts-surface);
    box-shadow: 0 35px 100px rgba(0,42,25,.25);
}

.ts-login-brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 38px;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(circle at 50% 18%, rgba(255,255,255,.12), transparent 14rem),
        linear-gradient(160deg, var(--ts-green-800), var(--ts-green-950));
}

.ts-login-brand-panel::after {
    content: "";
    position: absolute;
    inset: auto -40px 0;
    height: 150px;
    opacity: .36;
    background:
        linear-gradient(155deg, transparent 46%, rgba(255,255,255,.25) 47% 50%, transparent 51%) 0 25px / 115px 65px repeat-x,
        linear-gradient(25deg, transparent 46%, rgba(200,148,32,.55) 47% 50%, transparent 51%) 20px 65px / 145px 60px repeat-x;
}

.ts-login-logo {
    position: absolute;
    top: 32px;
    left: 50%;
    width: 255px;
    height: 255px;
    object-fit: cover;
    transform: translateX(-50%);
    border-radius: 48% 48% 24px 24px;
    box-shadow: 0 18px 45px rgba(0,0,0,.22);
}

.ts-login-brand-copy { position: relative; z-index: 1; }
.ts-login-brand-copy strong { display: block; font-family: var(--ts-font-title); font-size: 1.55rem; line-height: 1.1; }
.ts-login-brand-copy span { display: block; margin-top: 9px; color: rgba(255,255,255,.72); font-size: .82rem; }

.login.ts-login-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(32px, 5vw, 62px) !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--ts-surface) !important;
    box-shadow: none !important;
}

.ts-login-card .marca {
    width: 48px !important;
    height: 48px !important;
    margin-bottom: 18px !important;
    border-radius: 14px !important;
    color: var(--ts-green-900) !important;
    background: var(--ts-green-100) !important;
}

.ts-login-card h1 { color: var(--ts-green-950); font-family: var(--ts-font-title); font-size: clamp(1.75rem, 3vw, 2.25rem); }
.ts-login-card .subtitulo { margin-bottom: 30px; color: var(--ts-text-muted); }
.ts-login-card button[type="submit"] { min-height: 50px; border: 0; border-radius: 10px; color: #fff; background: linear-gradient(145deg, var(--ts-green-700), var(--ts-green-900)); font-weight: 850; cursor: pointer; }
.ts-login-card button[type="submit"]:hover { filter: brightness(1.05); }

/* Comprobante */
.hoja { color: #1f2d25 !important; background: #fff !important; }
.encabezado-documento { border-color: var(--ts-green-800) !important; }
.encabezado-documento h1 { color: var(--ts-green-900) !important; font-family: var(--ts-font-title); }

@media (max-width: 1180px) {
    .ts-dashboard-grid { grid-template-columns: 1fr; }
    .ts-dashboard-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    body .sidebar,
    body .sidebar.seguridad-sidebar {
        position: fixed;
        transform: translateX(-102%);
        transition: transform .22s ease;
    }

    body.ts-menu-abierto .sidebar { transform: translateX(0); }

    .contenido { width: 100%; padding: 18px clamp(16px, 3vw, 28px) 32px !important; }
    .ts-menu-toggle { display: grid; }
    .ts-topbar-context { margin-right: auto; }

    .ts-sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 1100;
        display: block;
        visibility: hidden;
        opacity: 0;
        border: 0;
        background: rgba(3,32,19,.48);
        transition: opacity .2s ease, visibility .2s ease;
    }

    body.ts-menu-abierto .ts-sidebar-overlay { visibility: visible; opacity: 1; }
}

@media (max-width: 760px) {
    .contenido { padding-inline: 14px !important; }
    .ts-topbar { min-height: 50px; margin-bottom: 13px; }
    .ts-topbar-context { display: none; }
    .ts-user-chip { padding-right: 8px; }
    .ts-user-role { display: none; }
    .ts-user-name { max-width: 115px; }
    .ts-topbar-logout { width: 39px; height: 39px; }
    .encabezado { min-height: 112px; padding: 22px 20px !important; flex-direction: column; align-items: flex-start; }
    .encabezado > button, .encabezado > a { align-self: stretch; width: 100%; }
    .resumen { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .resumen .tarjeta, .tarjeta { min-height: 98px; padding: 16px !important; }
    .filtros, .filtros-historial, .filtros-lotes, .formulario-grid, .campos-encabezado, .campos-costos, .datos-generales { grid-template-columns: 1fr !important; }
    .modal { padding: 10px !important; align-items: flex-start !important; }
    .modal-contenido { max-height: calc(100vh - 20px) !important; padding: 20px 16px !important; border-radius: 15px !important; }
    .modal-botones, .modal-acciones, .acciones-modal { display: grid !important; grid-template-columns: 1fr !important; }
    .modal-botones button, .modal-acciones button, .acciones-modal button { width: 100%; }
    .opciones-condicion { grid-template-columns: 1fr !important; }
    .permisos, .roles-lista { grid-template-columns: 1fr !important; }
    .ts-dashboard-side { grid-template-columns: 1fr; }
    .ts-section-card { padding: 17px; }
    .ts-metrics { grid-template-columns: 1fr; }
    .ts-quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ts-login-shell { grid-template-columns: 1fr; min-height: auto; }
    .ts-login-brand-panel { min-height: 235px; padding: 22px; justify-content: flex-end; }
    .ts-login-logo { top: -4px; width: 195px; height: 195px; }
    .ts-login-brand-copy strong { font-size: 1.2rem; }
    .ts-login-brand-copy span { display: none; }
    .login.ts-login-card { padding: 30px 22px !important; }
}

@media (max-width: 480px) {
    body.ts-login-page { padding: 10px; }
    .ts-login-shell { border-radius: 18px; }
    .resumen { grid-template-columns: 1fr !important; }
    .ts-user-text { display: none; }
    .ts-user-chip { padding: 4px; }
    .ts-quick-actions { grid-template-columns: 1fr; }
    th, td { padding: 11px 10px !important; }
}

@media print {
    body { background: #fff !important; }
    .sidebar, .ts-topbar, .ts-sidebar-overlay { display: none !important; }
    .contenido { width: 100% !important; padding: 0 !important; }
    .hoja { box-shadow: none !important; border: 0 !important; }
}
