﻿/* ==========================================================================
   SISTEMA DE DISENO
   Interfaz densa y sobria, pensada para uso intensivo durante toda la jornada.
   Sin sombras decorativas, sin degradados, sin tarjetas superpuestas.
   ========================================================================== */

:root {
    /* Superficies */
    --bg:            #f4f5f7;
    --surface:       #ffffff;
    --surface-alt:   #fafbfc;
    --surface-sunken:#eef0f3;

    /* Texto */
    --text:          #1a1f27;
    --text-soft:     #4a5361;
    --text-muted:    #646d7a;   /* 5.05:1 sobre blanco: cumple WCAG AA en texto pequeno */
    --text-invert:   #ffffff;

    /* Lineas */
    --border:        #dcdfe4;
    --border-strong: #c3c8d0;
    --border-subtle: #eceef1;   /* separador de filas en tablas y listas */

    /* Interaccion */
    --surface-hover: #f7f9fc;   /* fila de tabla bajo el cursor */

    /* Marca */
    --brand:         #0b57d0;
    --brand-dark:    #08419e;
    --brand-soft:    #e8f0fd;
    --brand-border:  #b9d0f6;

    /* Estados */
    --ok:            #157347;
    --ok-soft:       #e3f4ea;
    --warn:          #b45309;
    --warn-soft:     #fdf0dd;
    --danger:        #c02626;
    --danger-soft:   #fdeaea;
    --info:          #0b6b8f;
    --info-soft:     #e4f2f8;

    /* Barra lateral */
    --nav-bg:        #121826;
    --nav-bg-hover:  #1c2536;
    --nav-text:      #9aa5b5;
    --nav-text-on:   #ffffff;
    --nav-section:   #626f83;
    --nav-border:    #212b3c;

    /* Medidas */
    --nav-w:         232px;
    --topbar-h:      52px;
    --radius:        4px;
    --radius-lg:     6px;

    /* Tipografia */
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
    --fs:   13.5px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: var(--fs);
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 10px; }

.icon { flex: none; vertical-align: -0.15em; }

/* Numeros alineados: imprescindible en columnas de importes */
.num, .table td.num, .table th.num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}
.mono { font-family: var(--mono); font-size: .92em; }

/* ==========================================================================
   ESTRUCTURA
   ========================================================================== */

.app {
    display: grid;
    grid-template-columns: var(--nav-w) 1fr;
    min-height: 100vh;
}

/* --- Barra lateral --- */
.nav {
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.nav__brand {
    display: flex;
    align-items: center;
    gap: 9px;
    height: var(--topbar-h);
    padding: 0 14px;
    border-bottom: 1px solid var(--nav-border);
    color: #fff;
    flex: none;
}
.nav__brand:hover { text-decoration: none; }
.nav__logo {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    background: var(--brand);
    border-radius: var(--radius);
    color: #fff;
    flex: none;
}
.nav__title {
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav__scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 16px;
    scrollbar-width: thin;
    scrollbar-color: #2b3646 transparent;
}
.nav__scroll::-webkit-scrollbar { width: 8px; }
.nav__scroll::-webkit-scrollbar-thumb { background: #2b3646; border-radius: 4px; }

.nav__section {
    padding: 14px 14px 5px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #626f83;
}

.nav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    color: var(--nav-text);
    font-size: 13px;
    border-left: 2px solid transparent;
    white-space: nowrap;
}
.nav__item:hover {
    background: var(--nav-bg-hover);
    color: #dbe2ec;
    text-decoration: none;
}
.nav__item.is-active {
    background: var(--nav-bg-hover);
    color: var(--nav-text-on);
    border-left-color: var(--brand);
    font-weight: 500;
}
.nav__item .icon { opacity: .85; }
.nav__item.is-active .icon { opacity: 1; color: #6ea8fe; }

.nav__badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 9px;
    line-height: 1.5;
}

/* Capa oscura tras el menu lateral; solo existe en pantallas pequenas */
.nav-backdrop { display: none; }

/* --- Contenido --- */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar__toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px;
    cursor: pointer;
    color: var(--text-soft);
}

/* Buscador global */
.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch__input {
    width: 100%;
    height: 32px;
    padding: 0 30px 0 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
    font: inherit;
    font-size: 13px;
    color: var(--text);
}
.gsearch__input:focus {
    outline: none;
    background: #fff;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.gsearch__icon {
    position: absolute; left: 9px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.gsearch__hint {
    position: absolute; right: 8px; top: 50%;
    transform: translateY(-50%);
    font-size: 10.5px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 4px;
    background: #fff;
    pointer-events: none;
}
.gsearch__results {
    position: absolute;
    top: calc(100% + 4px); left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
    max-height: 420px;
    overflow-y: auto;
    display: none;
    z-index: 60;
}
.gsearch__results.is-open { display: block; }
.gsearch__group {
    padding: 6px 10px 3px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}
.gsearch__item {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px;
    color: var(--text);
    border-bottom: 1px solid var(--surface-sunken);
}
.gsearch__item:hover, .gsearch__item.is-highlighted {
    background: var(--brand-soft);
    text-decoration: none;
}
.gsearch__item small { color: var(--text-muted); margin-left: auto; }

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.iconbtn {
    position: relative;
    width: 32px; height: 32px;
    display: grid; place-items: center;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-soft);
    cursor: pointer;
}
.iconbtn:hover { background: var(--surface-sunken); color: var(--text); }
.iconbtn__dot {
    position: absolute; top: 5px; right: 5px;
    width: 7px; height: 7px;
    background: var(--danger);
    border: 1.5px solid #fff;
    border-radius: 50%;
}

.usermenu { position: relative; }
.usermenu__btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 4px 7px 4px 4px;
    cursor: pointer; font: inherit; color: var(--text);
}
.usermenu__btn:hover { background: var(--surface-sunken); }
.avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-size: 11px; font-weight: 600;
    flex: none;
}
.usermenu__name { font-size: 12.5px; font-weight: 500; line-height: 1.2; }
.usermenu__role { font-size: 11px; color: var(--text-muted); line-height: 1.2; }

.dropdown {
    position: absolute;
    top: calc(100% + 5px); right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
    padding: 4px;
    display: none;
    z-index: 70;
}
.dropdown.is-open { display: block; }
.dropdown--wide { min-width: 340px; }
.dropdown__item {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 9px;
    color: var(--text);
    border-radius: 3px;
    font-size: 13px;
}
.dropdown__item:hover { background: var(--surface-sunken); text-decoration: none; }
.dropdown__sep { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown__head {
    padding: 8px 9px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.dropdown__empty { padding: 20px 10px; text-align: center; color: var(--text-muted); font-size: 12.5px; }

/* --- Area de trabajo --- */
.content { padding: 16px 18px 40px; flex: 1; min-width: 0; }

.page {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.page__title { font-size: 19px; line-height: 1.25; }
.page__subtitle { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.page__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand); }

/* ==========================================================================
   COMPONENTES
   ========================================================================== */

/* --- Tarjeta / panel --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.card + .card { margin-top: 14px; }
.card__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.card__title { font-size: 13.5px; font-weight: 600; }
.card__subtitle { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.card__body { padding: 14px; }
.card__body--flush { padding: 0; }
.card__foot {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    flex-wrap: wrap;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Botones --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-sunken); text-decoration: none; }
.btn:active { background: #e4e7eb; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: #a11f1f; border-color: #a11f1f; }
.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--ok:hover { background: #11603b; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-sunken); }
.btn--link { border: none; background: none; color: var(--brand); padding: 0; height: auto; }
.btn--link:hover { text-decoration: underline; background: none; }
.btn--sm { height: 27px; padding: 0 8px; font-size: 12.5px; }
.btn--lg { height: 38px; padding: 0 18px; font-size: 14px; }
.btn--icon { width: 32px; padding: 0; }
.btn--icon.btn--sm { width: 27px; }
.btn--block { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.is-active { background: var(--brand-soft); border-color: var(--brand-border); color: var(--brand-dark); z-index: 1; }

/* --- Formularios --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 12px 14px;
}
.col-1  { grid-column: span 1; }  .col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }  .col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }  .col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }  .col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }  .col-10 { grid-column: span 10; }
.col-11 { grid-column: span 11; } .col-12 { grid-column: span 12; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-soft);
}
.label .req { color: var(--danger); }

.input, .select, .textarea {
    width: 100%;
    height: 32px;
    padding: 0 9px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    font: inherit;
    font-size: 13px;
    color: var(--text);
}
.textarea { height: auto; padding: 7px 9px; resize: vertical; min-height: 64px; line-height: 1.5; }
.select {
    appearance: none;
    padding-right: 26px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378818f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.input:disabled, .select:disabled, .textarea:disabled,
.input[readonly] { background: var(--surface-sunken); color: var(--text-soft); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input::placeholder { color: #a5adb8; }

.input--money { text-align: right; font-variant-numeric: tabular-nums; }

.help { font-size: 11.5px; color: var(--text-muted); }
.error-text { font-size: 11.5px; color: var(--danger); }

.check { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.check input[type=checkbox], .check input[type=radio] { width: 15px; height: 15px; accent-color: var(--brand); margin: 0; cursor: pointer; }

.input-group { display: flex; }
.input-group .input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; margin-left: -1px; }
.input-group__addon {
    display: flex; align-items: center;
    padding: 0 9px;
    border: 1px solid var(--border-strong);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    background: var(--surface-sunken);
    color: var(--text-muted);
    font-size: 12.5px;
}
.input-group__addon + .input { border-radius: 0 var(--radius) var(--radius) 0; }

fieldset { border: none; padding: 0; margin: 0 0 18px; }
.fieldset__legend {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    padding-bottom: 6px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* --- Barra de filtros --- */
.filters {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.filters .field { min-width: 150px; }
.filters .field--search { min-width: 240px; flex: 1; max-width: 340px; }

/* --- Tablas --- */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    text-align: left;
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    background: var(--surface-alt);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}
.table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.is-selected { background: var(--brand-soft); }
.table__actions { white-space: nowrap; text-align: right; width: 1%; }
.table__actions .btn { margin-left: 3px; }
.table--fixed { table-layout: fixed; }
.table td.strong, .table th.strong { font-weight: 600; color: var(--text); }
.table tfoot td {
    background: var(--surface-alt);
    font-weight: 600;
    border-top: 1px solid var(--border-strong);
    border-bottom: none;
}
.table--compact td, .table--compact th { padding: 5px 10px; }

.table__link { font-weight: 500; }
.table__meta { color: var(--text-muted); font-size: 11.5px; display: block; }

/* --- Etiquetas de estado --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge--neutral { background: var(--surface-sunken); color: var(--text-soft); border-color: var(--border); }
.badge--success { background: var(--ok-soft);     color: #0f5132; border-color: #bfe3cd; }
.badge--danger  { background: var(--danger-soft); color: #8f1d1d; border-color: #f3c9c9; }
.badge--warning { background: var(--warn-soft);   color: #8a4108; border-color: #f2d9b3; }
.badge--info    { background: var(--info-soft);   color: #0a5570; border-color: #bfdfec; }
.badge--brand   { background: var(--brand-soft);  color: var(--brand-dark); border-color: var(--brand-border); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--danger { background: var(--danger); }
.dot--neutral { background: var(--text-muted); }

/* --- Mensajes --- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 12px;
    background: var(--surface);
}
.alert--success { border-left-color: var(--ok);     background: var(--ok-soft);     color: #10502f; }
.alert--error   { border-left-color: var(--danger); background: var(--danger-soft); color: #8f1d1d; }
.alert--warning { border-left-color: var(--warn);   background: var(--warn-soft);   color: #8a4108; }
.alert--info    { border-left-color: var(--info);   background: var(--info-soft);   color: #0a5570; }
.alert__close { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: .6; padding: 0; }
.alert__close:hover { opacity: 1; }

/* Avisos flotantes */
.toasts {
    position: fixed;
    bottom: 18px; right: 18px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 200;
    max-width: 360px;
}
.toast {
    display: flex; align-items: flex-start; gap: 9px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(16, 24, 40, .14);
    padding: 10px 12px;
    font-size: 13px;
    animation: toast-in .18s ease-out;
}
.toast--success { border-left-color: var(--ok); }
.toast--error   { border-left-color: var(--danger); }
.toast--warning { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --- Estado vacio --- */
.empty {
    padding: 44px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty__icon { color: var(--border-strong); margin-bottom: 8px; }
.empty__title { font-size: 14px; font-weight: 600; color: var(--text-soft); margin-bottom: 3px; }
.empty__text { font-size: 12.5px; max-width: 380px; margin: 0 auto 14px; }

/* --- Paginacion --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.pagination__pages { display: flex; gap: 3px; }
.pagination__page {
    min-width: 28px; height: 28px;
    display: grid; place-items: center;
    padding: 0 7px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-soft);
    background: var(--surface);
    font-size: 12.5px;
}
.pagination__page:hover { background: var(--surface-sunken); text-decoration: none; }
.pagination__page.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination__page.is-disabled { opacity: .45; pointer-events: none; }

/* --- Pestanas --- */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
    overflow-x: auto;
}
.tab {
    padding: 8px 13px;
    font-size: 13px;
    color: var(--text-soft);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none; border-left: none; border-right: none;
    font-family: inherit;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

/* --- Ventanas modales --- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(16, 22, 32, .45);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    z-index: 150;
    overflow-y: auto;
}
.modal-backdrop.is-open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 16px 48px rgba(16, 24, 40, .22);
    width: 100%;
    max-width: 560px;
    animation: modal-in .14s ease-out;
}
.modal--sm { max-width: 420px; }
.modal--lg { max-width: 860px; }
.modal--xl { max-width: 1100px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.modal__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.modal__title { font-size: 14.5px; font-weight: 600; }
.modal__body { padding: 16px; max-height: 70vh; overflow-y: auto; }
.modal__foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Indicadores del tablero --- */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.kpi__label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}
.kpi__value {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.kpi__meta { font-size: 11.5px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.kpi__delta--up { color: var(--ok); }
.kpi__delta--down { color: var(--danger); }
.kpi--accent { border-left: 3px solid var(--brand); }
.kpi--warn { border-left: 3px solid var(--warn); }
.kpi--danger { border-left: 3px solid var(--danger); }
.kpi--ok { border-left: 3px solid var(--ok); }

/* --- Rejilla del tablero --- */
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2-1 { grid-template-columns: 2fr 1fr; }
.grid--1-2 { grid-template-columns: 1fr 2fr; }

/* --- Graficos --- */
.chart { width: 100%; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 14px 0; font-size: 12px; color: var(--text-soft); }
.chart-legend__item { display: flex; align-items: center; gap: 5px; }
.chart-legend__swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }

/* --- Lista de detalle --- */
.deflist { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.deflist dt { color: var(--text-muted); font-size: 12.5px; }
.deflist dd { margin: 0; font-weight: 500; }

.datalist { display: flex; flex-direction: column; }
.datalist__row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-subtle);
}
.datalist__row:last-child { border-bottom: none; }
.datalist__row:hover { background: var(--surface-alt); }
.datalist__main { min-width: 0; flex: 1; }
.datalist__title { font-weight: 500; font-size: 13px; }
.datalist__meta { color: var(--text-muted); font-size: 11.5px; }

/* --- Utilidades --- */
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.small { font-size: 12px; }
.xsmall { font-size: 11.5px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.flex-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.w-100 { width: 100%; }
.text-ok { color: var(--ok); }
.text-danger { color: var(--danger); }

/* Tecla de atajo mostrada dentro de un rotulo */
.kbd {
    display: inline-block;
    min-width: 20px;
    padding: 0 4px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-soft);
    font-family: var(--mono);
    font-size: 10.5px;
    line-height: 16px;
    text-align: center;
}
.text-warn { color: var(--warn); }
.text-brand { color: var(--brand); }

/* Indicadores de stock */
.stock { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.stock--ok .dot { background: var(--ok); }
.stock--low .dot { background: var(--warn); }
.stock--out .dot { background: var(--danger); }
.stock--low { color: var(--warn); font-weight: 500; }
.stock--out { color: var(--danger); font-weight: 500; }

/* --- Carga --- */
.spinner {
    width: 15px; height: 15px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row { padding: 26px; text-align: center; color: var(--text-muted); }

/* ==========================================================================
   ACCESO
   ========================================================================== */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 440px;
    background: var(--surface);
}
.auth__aside {
    background: var(--nav-bg);
    color: #fff;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.auth__aside::after {
    /* Trama tecnica discreta, sin degradados llamativos */
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px);
    background-size: 34px 34px;
    pointer-events: none;
}
.auth__brand { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.auth__brand-name { font-size: 15px; font-weight: 600; }
.auth__pitch { position: relative; z-index: 1; max-width: 420px; }
.auth__pitch h2 { font-size: 25px; line-height: 1.3; margin-bottom: 12px; font-weight: 600; }
.auth__pitch p { color: #97a3b6; font-size: 13.5px; line-height: 1.6; }
.auth__features { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 9px; }
.auth__features li { display: flex; align-items: center; gap: 9px; color: #b9c3d1; font-size: 13px; }
.auth__features .icon { color: #6ea8fe; }
.auth__legal { position: relative; z-index: 1; color: #5f6b7d; font-size: 11.5px; }

.auth__panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px;
    border-left: 1px solid var(--border);
}
.auth__form { width: 100%; max-width: 340px; margin: 0 auto; }
.auth__title { font-size: 20px; margin-bottom: 4px; }
.auth__subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.auth__field { margin-bottom: 13px; }
.auth__input { height: 38px; font-size: 14px; }
.auth__row { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 18px; }
.auth__foot { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); text-align: center; }

.pwd-wrap { position: relative; }
.pwd-toggle {
    position: absolute; right: 6px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: grid; place-items: center;
}
.pwd-toggle:hover { color: var(--text); }

/* ==========================================================================
   PAGINAS DE ERROR
   ========================================================================== */

.errorpage {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    text-align: center;
}
.errorpage__code {
    font-size: 60px;
    font-weight: 600;
    color: var(--border-strong);
    line-height: 1;
    letter-spacing: -0.03em;
}
.errorpage__title { font-size: 19px; margin: 10px 0 6px; }
.errorpage__text { color: var(--text-muted); max-width: 380px; margin: 0 auto 20px; font-size: 13.5px; }

/* ==========================================================================
   IMPRESION
   ========================================================================== */

@media print {
    .nav, .topbar, .page__actions, .filters, .pagination, .no-print { display: none !important; }
    .app { display: block; }
    .content { padding: 0; }
    .card { border: none; }
    body { background: #fff; font-size: 11pt; }
}

/* ==========================================================================
   ADAPTACION A PANTALLAS PEQUENAS
   ========================================================================== */

@media (max-width: 1200px) {
    .grid--2-1, .grid--1-2, .grid--3 { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .app { grid-template-columns: 1fr; }
    .nav {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: var(--nav-w);
        z-index: 120;
        transform: translateX(-100%);
        transition: transform .18s ease-out;
        height: 100vh;
    }
    .nav.is-open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .topbar__toggle { display: grid; place-items: center; }
    .nav-backdrop {
        position: fixed; inset: 0;
        background: rgba(16, 22, 32, .45);
        z-index: 110;
        display: none;
    }
    .nav-backdrop.is-open { display: block; }
    .grid--2 { grid-template-columns: 1fr; }
    .auth { grid-template-columns: 1fr; }
    .auth__aside { display: none; }
    .auth__panel { border-left: none; }
}

@media (max-width: 768px) {
    .content { padding: 12px; }
    .form-grid > [class^="col-"] { grid-column: span 12; }
    .col-6-m { grid-column: span 6; }
    .page__title { font-size: 17px; }
    .kpi__value { font-size: 19px; }
    .filters .field, .filters .field--search { min-width: 100%; max-width: none; }
    .gsearch { max-width: none; }
    .usermenu__name, .usermenu__role { display: none; }
}

/* Lista numerada explicativa (paneles de ayuda de Configuracion) */
.howto { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-soft); }
.howto li { margin-bottom: 9px; line-height: 1.5; }
.howto li:last-child { margin-bottom: 0; }
.howto strong { color: var(--text); font-weight: 600; }
