/*
|--------------------------------------------------------------------------
| Altas y Bajas · hoja de estilos
|--------------------------------------------------------------------------
| Diseño propio, sin frameworks. Paleta azul marino (marca Zafiro) con acento
| naranja. Todo el layout es responsive y accesible por teclado.
*/

:root {
    --bg: #f4f6f9;
    --bg-soft: #eef1f5;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e2e6ec;
    --border-strong: #cbd3dd;
    --text: #152235;
    --text-soft: #39485c;
    --muted: #667386;
    --navy: #0b1f33;
    --navy-2: #102b46;
    --navy-3: #16395c;
    --brand: #f97316;
    --brand-dark: #ea580c;
    --brand-soft: #fff1e6;
    --success: #15803d;
    --success-soft: #e9f9ef;
    --warning: #b45309;
    --warning-soft: #fff7e5;
    --danger: #b91c1c;
    --danger-soft: #fdecec;
    --info: #1d4ed8;
    --info-soft: #eaf1ff;
    --progress: #c2410c;
    --progress-soft: #fff1e8;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(16, 31, 51, 0.05);
    --shadow: 0 12px 28px -18px rgba(16, 31, 51, 0.28);
    --shadow-lg: 0 30px 60px -25px rgba(7, 20, 35, 0.4);
    --sidebar-w: 264px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1, h2, h3, h4, p, ul, ol, figure {
    margin: 0;
}

ul, ol {
    padding-left: 1.15rem;
}

a {
    color: var(--info);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

button {
    cursor: pointer;
}

img {
    max-width: 100%;
    display: block;
}

svg.icon {
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
}

svg.icon-sm {
    width: 1rem;
    height: 1rem;
}

svg.icon-xs {
    width: 0.875rem;
    height: 0.875rem;
}

[hidden] {
    display: none !important;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 999;
    padding: 0.65rem 1rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.skip-link:focus {
    top: 1rem;
}

/* -------------------------------------------------------------------------
 * Botones
 * ---------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 40px;
    padding: 0.55rem 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible,
.icon-btn:focus-visible,
.page-btn:focus-visible,
.nav-link:focus-visible {
    outline: 3px solid rgba(249, 115, 22, 0.35);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(180deg, #fb8a3b, var(--brand));
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 6px 14px -8px rgba(234, 88, 12, 0.85);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #f97316, var(--brand-dark));
    border-color: var(--brand-dark);
    color: #fff;
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text-soft);
}

.btn-secondary:hover {
    background: var(--surface-2);
    border-color: #b6c1ce;
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
}

.btn-ghost:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #166534;
    border-color: #166534;
}

.btn-danger {
    background: var(--danger-soft);
    border-color: #f4c7c7;
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-sm {
    min-height: 32px;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

/* -------------------------------------------------------------------------
 * Formularios
 * ---------------------------------------------------------------------- */
.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.field > span {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
}

.field input[type="text"],
.field input[type="search"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field select,
.field textarea {
    width: 100%;
    min-height: 40px;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.16);
}

.field input[readonly],
.field textarea[readonly] {
    background: var(--bg-soft);
    color: var(--muted);
}

.field-hint {
    font-size: 0.76rem;
    color: var(--muted);
}

.field-full {
    grid-column: 1 / -1;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    width: 1.1rem;
    height: 1.1rem;
    transform: translateY(-50%);
    color: #8b97a8;
    pointer-events: none;
    z-index: 1;
}

.input-wrap input {
    padding-left: 2.45rem;
    padding-right: 2.8rem;
}

.input-action {
    position: absolute;
    right: 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
}

.input-action:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.form-error {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #f3c2c2;
    border-radius: 10px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 0.88rem;
    font-weight: 600;
}

.form-note {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.form-note svg {
    margin-top: 0.15rem;
}

/* -------------------------------------------------------------------------
 * Estructura
 * ---------------------------------------------------------------------- */
.app-body {
    min-height: 100vh;
    background:
        radial-gradient(1100px 500px at 88% -12%, rgba(249, 115, 22, 0.06), transparent 60%),
        var(--bg);
}

.app-shell {
    min-height: 100vh;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin-left: var(--sidebar-w);
}

.content {
    width: 100%;
    margin: 0;
    padding: 1.5rem clamp(1rem, 2.4vw, 2.25rem) 2.5rem;
    flex: 1;
}

.mobile-only {
    display: none;
}

/* -------------------------------------------------------------------------
 * Barra lateral
 * ---------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    padding: 1.1rem 0.9rem;
    color: rgba(255, 255, 255, 0.78);
    background:
        radial-gradient(420px 240px at 10% 0%, rgba(249, 115, 22, 0.2), transparent 65%),
        linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 65%, #0a1a2b 100%);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.3rem 0.4rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: #fff;
    padding: 2px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.brand-text strong {
    color: #fff;
    font-size: 0.92rem;
    letter-spacing: 0.01em;
}

.brand-text span {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.1rem 0;
}

.nav-section {
    margin: 0.75rem 0.6rem 0.35rem;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.nav-section:first-child {
    margin-top: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.62rem 0.7rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    text-decoration: none;
}

.nav-link.is-active {
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.22), rgba(249, 115, 22, 0.06));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand);
}

.nav-icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    color: rgba(255, 255, 255, 0.55);
}

.nav-link.is-active .nav-icon {
    color: #fdba74;
}

.nav-badge {
    margin-left: auto;
    min-width: 22px;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem;
}

.sidebar-user div {
    min-width: 0;
}

.sidebar-user strong {
    display: block;
    overflow: hidden;
    color: #fff;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user span:not(.avatar) {
    display: block;
    color: rgba(255, 255, 255, 0.48);
    font-size: 0.7rem;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.55rem 0.6rem;
    border-radius: 9px;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.8rem;
    text-decoration: none;
}

.logout-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    text-decoration: none;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(7, 18, 30, 0.55);
    backdrop-filter: blur(3px);
}

/* -------------------------------------------------------------------------
 * Cabecera
 * ---------------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 76px;
    padding: 0.9rem clamp(1rem, 2.4vw, 2.25rem);
    border-bottom: 1px solid rgba(226, 230, 236, 0.85);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
}

.page-heading {
    min-width: 0;
}

.page-heading h1 {
    font-size: clamp(1.15rem, 2vw, 1.45rem);
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--text);
}

.page-heading p {
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-left: auto;
    padding: 0.35rem 0.55rem 0.35rem 0.35rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
}

.topbar-user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.topbar-user-text strong {
    font-size: 0.78rem;
}

.topbar-user-text span {
    color: var(--muted);
    font-size: 0.68rem;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(145deg, #16395c, #0b1f33);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-xs {
    width: 30px;
    height: 30px;
    font-size: 0.72rem;
}

/* -------------------------------------------------------------------------
 * Tarjetas estadísticas
 * ---------------------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}

.stats-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 0.1rem 0.8rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    flex: 0 0 auto;
    grid-row: 1 / span 3;
}

/* Las tarjetas antiguas ponen etiqueta, valor y detalle como hijos directos.
   La cuadrícula los mantiene apilados en la segunda columna, a la derecha del
   icono, sin obligar a reescribir todas las plantillas. */
.stat-label,
.stat-value,
.stat-meta {
    grid-column: 2;
}

.stat-icon svg {
    width: 1.15rem;
    height: 1.15rem;
}

.stat-label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stat-value {
    margin-top: 0.15rem;
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    font-weight: 750;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-meta {
    margin-top: 0.1rem;
    color: var(--muted);
    font-size: 0.74rem;
}

.tone-slate { background: #eef2f7; color: #42556d; }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-progress { background: var(--progress-soft); color: var(--progress); }
.tone-neutral { background: #f1f3f6; color: #526277; }

/* -------------------------------------------------------------------------
 * Paneles
 * ---------------------------------------------------------------------- */
.panel {
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fff, #fcfcfd);
}

.panel-head h2 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1rem;
    font-weight: 750;
    letter-spacing: -0.01em;
}

.panel-head p {
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.eyebrow {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--brand-dark);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 0.7rem;
    font-weight: 700;
}

.table-head {
    border-bottom: 1px solid var(--border);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 0.45rem;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.04);
}

.status-dot.is-success { background: #22c55e; }
.status-dot.is-warning { background: #f59e0b; }

/* -------------------------------------------------------------------------
 * Filtros
 * ---------------------------------------------------------------------- */
.filters {
    border-bottom: 1px solid var(--border);
}

.filters-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.25rem;
    color: var(--text-soft);
    font-size: 0.84rem;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.filters-summary::-webkit-details-marker {
    display: none;
}

.filters-summary span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.filters-summary:hover {
    background: var(--surface-2);
}

.filters[open] .filters-summary {
    border-bottom: 1px solid var(--border);
}

.filter-form {
    padding: 1.1rem 1.25rem 1.25rem;
    background: var(--surface-2);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Búsquedas guardadas --------------------------------------------------- */
.saved-searches-panel {
    padding: 0;
    overflow: hidden;
}

.saved-searches-body {
    display: grid;
    gap: 0.9rem;
    padding: 1rem 1.25rem 1.2rem;
    background: var(--surface-2);
}

.saved-search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem;
}

.saved-search-form .filter-field {
    flex: 1 1 260px;
    margin: 0;
}

.saved-search-list {
    display: grid;
    gap: 0.45rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.saved-search-list li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
}

.saved-search-list li form {
    margin: 0 0 0 auto;
}

.saved-search-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    font-weight: 600;
}

.saved-search-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-search-date {
    color: var(--muted);
    font-size: 0.72rem;
    white-space: nowrap;
}

/* -------------------------------------------------------------------------
 * Tabla
 * ---------------------------------------------------------------------- */
.table-wrap {
    width: 100%;
    max-height: 72vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 1180px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.82rem;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
}

.sort-link:hover,
.sort-link:focus-visible {
    color: var(--text);
    text-decoration: none;
}

.sort-link:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
}

.data-table tbody td {
    padding: 0.68rem 0.8rem;
    border-bottom: 1px solid #edf0f4;
    vertical-align: top;
}

.data-table tbody tr {
    transition: background-color 0.12s ease;
}

.data-table tbody tr:hover td {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table .num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.data-table .muted {
    color: var(--muted);
}

.data-table .small {
    font-size: 0.73rem;
}

.actions-col {
    text-align: right;
    white-space: nowrap;
}

.tone-row.tone-success td { background: #f4fcf6; }
.tone-row.tone-warning td { background: #fffbf2; }
.tone-row.tone-progress td { background: #fff8f2; }
.tone-row.tone-info td { background: #f4f9ff; }
.tone-row.tone-danger td { background: #fff6f6; }
.tone-row.tone-neutral td { background: #fff; }

.tone-row:hover td {
    background: #f4f7fb !important;
}

.client-cell {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 190px;
}

.client-name {
    display: block;
    max-width: 260px;
    overflow: hidden;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.client-meta {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    white-space: nowrap;
}

.invoice {
    display: block;
    color: var(--text);
    font-weight: 650;
    white-space: nowrap;
}

.amount {
    display: block;
    font-weight: 650;
    white-space: nowrap;
}

.amount-danger {
    color: var(--danger);
}

.obs-cell {
    min-width: 210px;
    max-width: 300px;
}

.obs-label {
    display: inline-block;
    margin-right: 0.25rem;
    padding: 0 0.28rem;
    border-radius: 4px;
    background: #eef2f7;
    color: #526277;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    vertical-align: 1px;
}

.obs-label-adm {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.obs-text {
    display: block;
    margin-bottom: 0.2rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--text-soft);
    font-size: 0.75rem;
    line-height: 1.35;
}

.badge {
    display: inline-flex;
    align-items: center;
    max-width: 190px;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.67rem;
    font-weight: 750;
    line-height: 1.35;
    white-space: normal;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-progress { background: var(--progress-soft); color: var(--progress); }
.badge-neutral { background: #eef1f5; color: #5b6b80; }

.lock-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-right: 0.35rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: 0.66rem;
    font-weight: 700;
    vertical-align: middle;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* -------------------------------------------------------------------------
 * Paginación y estado vacío
 * ---------------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    flex-wrap: wrap;
}

.page-info {
    color: var(--muted);
    font-size: 0.78rem;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.45rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 650;
    text-decoration: none;
}

.page-btn:hover {
    background: var(--brand-soft);
    border-color: #f7cba8;
    color: var(--brand-dark);
    text-decoration: none;
}

.page-btn.is-current {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}

.page-btn.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.page-edge {
    font-weight: 800;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 2.6rem 1rem;
    text-align: center;
}

.empty-icon {
    width: 2.4rem;
    height: 2.4rem;
    color: #a7b3c2;
}

.empty-state h3 {
    font-size: 0.95rem;
}

.empty-state p {
    max-width: 360px;
    color: var(--muted);
    font-size: 0.82rem;
}

/* -------------------------------------------------------------------------
 * Mensajes flash y toasts
 * ---------------------------------------------------------------------- */
.flash {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    font-size: 0.85rem;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.flash.is-leaving {
    opacity: 0;
    transform: translateY(-4px);
}

.flash-success { border-color: #bfe8cd; background: var(--success-soft); color: #14532d; }
.flash-danger  { border-color: #f3c2c2; background: var(--danger-soft); color: #7f1d1d; }
.flash-warning { border-color: #f3d8a8; background: var(--warning-soft); color: #7c3e06; }
.flash-info    { border-color: #c9d9fa; background: var(--info-soft); color: #1e3a8a; }

.flash-text {
    flex: 1;
}

.flash-close {
    display: inline-flex;
    padding: 0.1rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: currentColor;
    opacity: 0.7;
}

.flash-close:hover {
    opacity: 1;
}

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(360px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    color: var(--text-soft);
    font-size: 0.84rem;
    font-weight: 550;
    animation: toast-in 0.18s ease-out;
    pointer-events: auto;
}

.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: #f59e0b; }
.toast-danger  { border-left-color: var(--danger); }
.toast-info    { border-left-color: var(--info); }

.toast.is-leaving {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------------------
 * Diálogo de edición
 * ---------------------------------------------------------------------- */
.modal {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 1.25rem;
    border: 0;
    background: transparent;
}

.modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal::backdrop {
    background: rgba(7, 18, 30, 0.58);
    backdrop-filter: blur(4px);
}

.modal-card {
    display: flex;
    flex-direction: column;
    width: min(920px, 100%);
    max-height: 92vh;
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.3rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #fff, #fbfcfd);
}

.modal-head h2 {
    font-size: 1.15rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.modal-body {
    padding: 1.2rem 1.3rem;
    overflow-y: auto;
}

.modal-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.55rem;
    margin-bottom: 1.2rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.modal-summary div {
    min-width: 0;
    padding: 0.25rem 0.4rem;
}

.modal-summary span {
    display: block;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.modal-summary strong {
    display: block;
    overflow: hidden;
    margin-top: 0.1rem;
    font-size: 0.84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.edit-form .field:has(textarea) {
    grid-column: 1 / -1;
}

.form-error {
    grid-column: 1 / -1;
}

.modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.3rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    flex-wrap: wrap;
}

.lock-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.74rem;
}

.lock-hint.is-danger {
    color: var(--danger);
    font-weight: 650;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

body.modal-open {
    overflow: hidden;
}

/* -------------------------------------------------------------------------
 * Importación / exportación
 * ---------------------------------------------------------------------- */
.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.two-col .panel {
    margin-bottom: 1.25rem;
}

.upload-form {
    padding: 1.1rem 1.25rem 0.75rem;
}

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.9rem;
    padding: 1.4rem 1rem;
    border: 1.5px dashed #c7d1dd;
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-within {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    width: 1.7rem;
    height: 1.7rem;
    color: var(--brand);
}

.dropzone strong {
    color: var(--text);
    font-size: 0.88rem;
}

.dropzone span {
    font-size: 0.76rem;
}

.dropzone .file-name {
    margin-top: 0.35rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-soft);
    font-size: 0.72rem;
    font-weight: 600;
}

.format-box {
    margin: 0 1.25rem 1.25rem;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.format-box h3 {
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
}

.format-box p {
    color: var(--muted);
    font-size: 0.78rem;
}

.format-code {
    display: block;
    margin: 0.55rem 0;
    padding: 0.6rem;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    background: #fff;
    color: #24364b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.7rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.plain-list {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.plain-list li + li {
    margin-top: 0.2rem;
}

.plain-list strong {
    color: var(--text-soft);
}

.result-panel {
    border-color: #cfe7d8;
}

.result-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem;
    padding: 1.1rem 1.25rem 0.4rem;
}

.result-metrics div {
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
}

.result-metrics span {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.result-metrics strong {
    display: block;
    margin-top: 0.15rem;
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
}

.result-panel .form-note {
    margin: 0.4rem 1.25rem;
}

.result-errors {
    margin: 0.6rem 1.25rem 1.2rem;
    padding: 0.7rem;
    border: 1px solid #f3d8a8;
    border-radius: 10px;
    background: var(--warning-soft);
    color: #7c3e06;
    font-size: 0.8rem;
}

.result-errors summary {
    cursor: pointer;
    font-weight: 700;
}

.result-errors ul {
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
}

.export-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    padding: 1.1rem 1.25rem 1.25rem;
}

.export-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.export-card:hover {
    border-color: #f2c19b;
    box-shadow: var(--shadow);
    text-decoration: none;
    transform: translateY(-1px);
}

.export-card div {
    min-width: 0;
    flex: 1;
}

.export-card strong {
    display: block;
    font-size: 0.88rem;
}

.export-card span:not(.stat-icon) {
    display: block;
    color: var(--muted);
    font-size: 0.74rem;
}

.export-card > .icon {
    color: var(--muted);
}

/* -------------------------------------------------------------------------
 * Formulario de usuarios
 * ---------------------------------------------------------------------- */
.user-form {
    padding: 1.1rem 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.form-note {
    padding: 0 1.25rem 1.1rem;
}

/* -------------------------------------------------------------------------
 * Pie
 * ---------------------------------------------------------------------- */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem clamp(1rem, 2.4vw, 2.25rem);
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.74rem;
}

/* -------------------------------------------------------------------------
 * Acceso
 * ---------------------------------------------------------------------- */
.auth-body {
    min-height: 100vh;
    background: var(--bg);
}

/* Si reCAPTCHA está desactivado, no debe quedar ningún badge flotante
   (el distintivo gris de Google) tapando el formulario de acceso. */
.auth-body[data-recaptcha="0"] .grecaptcha-badge {
    display: none !important;
}

.auth-shell {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    min-height: 100vh;
}

.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    padding: clamp(1.8rem, 4.5vw, 4rem);
    background:
        radial-gradient(550px 420px at 85% 10%, rgba(249, 115, 22, 0.3), transparent 65%),
        radial-gradient(500px 400px at 5% 90%, rgba(29, 78, 216, 0.25), transparent 60%),
        linear-gradient(150deg, #0a1a2b 0%, #102b46 55%, #0b1f33 100%);
    color: #fff;
    overflow: hidden;
}

.auth-brand::before,
.auth-brand::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    pointer-events: none;
}

.auth-brand::before {
    width: 520px;
    height: 520px;
    right: -220px;
    top: -160px;
}

.auth-brand::after {
    width: 360px;
    height: 360px;
    left: -160px;
    bottom: -140px;
}

.auth-brand-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.auth-logo {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: #fff;
}

.auth-copy {
    position: relative;
    z-index: 1;
    max-width: 540px;
}

.auth-copy .eyebrow {
    color: #fdba74;
}

.auth-copy h1 {
    font-size: clamp(2.1rem, 4.5vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.02;
}

.auth-copy > p:not(.eyebrow) {
    margin-top: 1rem;
    color: rgba(255, 255, 255, 0.68);
    font-size: clamp(0.9rem, 1.3vw, 1rem);
    max-width: 460px;
}

.auth-features {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-top: 1.6rem;
    padding: 0;
    list-style: none;
}

.auth-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.86rem;
}

.auth-features svg {
    color: #fdba74;
}

.auth-foot {
    position: relative;
    z-index: 1;
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.auth-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    background:
        radial-gradient(700px 400px at 100% 0%, rgba(249, 115, 22, 0.07), transparent 60%),
        var(--bg);
}

.auth-card {
    width: min(430px, 100%);
    padding: clamp(1.5rem, 3.5vw, 2.3rem);
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.auth-head {
    margin-bottom: 1.4rem;
}

.auth-head h2 {
    font-size: 1.55rem;
    font-weight: 780;
    letter-spacing: -0.03em;
}

.auth-head p {
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.auth-form .btn-block {
    min-height: 44px;
    margin-top: 0.2rem;
}

.recaptcha-note {
    margin-top: 0.2rem;
    color: #8a96a6;
    font-size: 0.67rem;
    line-height: 1.45;
    text-align: center;
}

.auth-legal {
    color: var(--muted);
    font-size: 0.72rem;
    text-align: center;
}

/* -------------------------------------------------------------------------
 * Página de error
 * ---------------------------------------------------------------------- */
.error-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: var(--bg);
}

.error-card {
    width: min(520px, 100%);
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.error-card h1 {
    margin-bottom: 0.6rem;
    font-size: 1.3rem;
}

.error-card p {
    margin-bottom: 1rem;
    color: var(--muted);
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */
@media (max-width: 1280px) {
    .field-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    :root {
        --sidebar-w: 264px;
    }

    .sidebar {
        transform: translateX(-102%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .mobile-only {
        display: inline-flex;
    }

    .topbar {
        min-height: 68px;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        min-height: auto;
        padding: 1.4rem 1.5rem;
        gap: 1rem;
    }

    .auth-copy h1 {
        font-size: 1.8rem;
    }

    .auth-copy > p:not(.eyebrow),
    .auth-features,
    .auth-foot {
        display: none;
    }

    .auth-panel {
        padding: 1.5rem 1rem 2.5rem;
        justify-content: flex-start;
    }

    .auth-card {
        margin-top: -1.2rem;
        position: relative;
        z-index: 2;
    }
}

@media (max-width: 760px) {
    .content {
        padding: 1rem 0.85rem 2rem;
    }

    .topbar {
        padding: 0.7rem 0.85rem;
    }

    .topbar-user-text {
        display: none;
    }

    .topbar-user {
        padding: 0.25rem;
        border: 0;
        background: transparent;
    }

    .panel-head {
        flex-direction: column;
        align-items: stretch;
        padding: 0.95rem 1rem;
    }

    .panel-actions {
        justify-content: flex-start;
    }

    .field-grid,
    .edit-form,
    .two-col,
    .export-grid {
        grid-template-columns: 1fr;
    }

    .modal-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-form,
    .upload-form,
    .user-form {
        padding: 0.9rem 1rem 1rem;
    }

    .result-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 0.9rem 1rem 0.3rem;
    }

    .stats-grid,
    .stats-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
    }

    .stat-card {
        padding: 0.8rem;
    }

    .stat-icon {
        width: 34px;
        height: 34px;
    }

    .pagination {
        justify-content: center;
        padding: 0.75rem 0.9rem;
    }

    .page-info {
        width: 100%;
        text-align: center;
    }

    .modal {
        padding: 0;
    }

    .modal[open] {
        align-items: flex-end;
    }

    .modal-card {
        width: 100%;
        max-height: 94vh;
        border-radius: 18px 18px 0 0;
    }

    .modal-head,
    .modal-body,
    .modal-foot {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .modal-foot {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .lock-hint {
        justify-content: center;
    }

    .app-footer {
        padding: 0.8rem 1rem;
        flex-direction: column;
        gap: 0.2rem;
        text-align: center;
    }
}

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

    .auth-brand {
        padding: 1.1rem 1rem;
    }

    .auth-logo {
        width: 44px;
        height: 44px;
    }

    .auth-copy h1 {
        font-size: 1.5rem;
    }

    .auth-card {
        padding: 1.3rem;
        border-radius: 18px;
    }

    .modal-summary {
        grid-template-columns: 1fr;
    }

    .toast-stack {
        right: 0.6rem;
        bottom: 0.6rem;
        width: calc(100vw - 1.2rem);
    }
}

/* -------------------------------------------------------------------------
 * Impresión
 * ---------------------------------------------------------------------- */
@media print {
    .sidebar,
    .topbar,
    .panel-actions,
    .filters,
    .pagination,
    .actions-col,
    .app-footer,
    .toast-stack {
        display: none !important;
    }

    .app-main {
        margin-left: 0;
    }

    .content {
        padding: 0;
        max-width: none;
    }

    .panel {
        border: 0;
        box-shadow: none;
    }

    .table-wrap {
        max-height: none;
        overflow: visible;
    }

    .data-table {
        min-width: 0;
        font-size: 10px;
    }

    .data-table thead th {
        position: static;
    }
}

/* -------------------------------------------------------------------------
 * Altas y Bajas: ampliaciones sobre el estilo corporativo
 * ---------------------------------------------------------------------- */
.icon { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
.icon-sm { width: .95rem; height: .95rem; flex: 0 0 auto; }
.icon-xs { width: .72rem; height: .72rem; flex: 0 0 auto; }
.flash-icon { width: 1.05rem; height: 1.05rem; margin-top: 1px; flex: 0 0 auto; }
.sort-indicator { margin-left: .15rem; font-size: .62rem; opacity: .72; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
}

.topbar-user {
    position: relative;
    padding: 0;
    border: 0;
    background: transparent;
}

.topbar-user-summary {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .3rem .5rem .3rem .3rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.topbar-user-summary::-webkit-details-marker { display: none; }

.topbar-user[open] .topbar-user-summary {
    border-color: #f3c49f;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .1);
}

.topbar-user-menu {
    position: absolute;
    top: calc(100% + .5rem);
    right: 0;
    z-index: 120;
    min-width: 220px;
    padding: .55rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.topbar-user-meta {
    display: flex;
    flex-direction: column;
    gap: .12rem;
    padding: .5rem .55rem .6rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .35rem;
}

.topbar-user-meta strong { font-size: .82rem; }
.topbar-user-meta span { color: var(--muted); font-size: .72rem; }

.topbar-user-menu a {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .55rem;
    border-radius: 9px;
    color: var(--text-soft);
    font-size: .82rem;
    text-decoration: none;
}

.topbar-user-menu a:hover {
    background: var(--bg-soft);
    color: var(--text);
    text-decoration: none;
}

.icon-btn-danger { color: var(--danger); }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #f3c2c2; }

.app-footer {
    padding: 1rem clamp(1rem, 2.4vw, 2.25rem) 1.3rem;
    color: #8a96a6;
    font-size: .7rem;
    letter-spacing: .04em;
    text-align: center;
    text-transform: uppercase;
}

/* Formularios de registro y mantenimiento */
.record-form { padding: 1.25rem; }
.form-section { margin-bottom: 1.4rem; }
.form-section:last-of-type { margin-bottom: .4rem; }
.form-section-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .75rem;
    color: var(--text-soft);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
.form-grid .field-span-2 { grid-column: span 2; }
.form-grid .field-span-3 { grid-column: span 3; }
.form-grid .field-span-4 { grid-column: 1 / -1; }
.form-actions {
    display: flex;
    align-items: center;
    gap: .55rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.form-actions .btn { min-height: 40px; }
.form-actions .form-actions-right { margin-left: auto; display: flex; gap: .5rem; }
.form-error-box {
    margin-bottom: 1rem;
    padding: .75rem .9rem;
    border: 1px solid #f3c2c2;
    border-radius: 11px;
    background: var(--danger-soft);
    color: #7f1d1d;
    font-size: .84rem;
}
.form-error-box ul { margin: .3rem 0 0 1.1rem; }
.form-error-box li { margin: .12rem 0; }
.field-hint { margin-top: .25rem; color: var(--muted); font-size: .7rem; line-height: 1.35; }
.required { color: var(--danger); }
.checkbox-row { display: flex; align-items: center; gap: .45rem; font-size: .82rem; }
.checkbox-row input { width: 1rem; height: 1rem; accent-color: var(--brand); }

/* Tabla: utilidades */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .8rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: #fff;
}
.table-toolbar-text { color: var(--muted); font-size: .78rem; }
.table-toolbar-actions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .73rem; }
.w-full { width: 100%; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Mantenimiento */
.master-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.master-card { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.master-card-head { padding: .85rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.master-card-head h2 { font-size: .92rem; font-weight: 750; }
.master-card-head p { margin-top: .15rem; color: var(--muted); font-size: .72rem; }
.master-form { display: flex; gap: .4rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.master-form .field { flex: 1; }
.master-list { max-height: 420px; overflow: auto; padding: .35rem 0; }
.master-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem 1rem; font-size: .8rem; }
.master-item:hover { background: var(--bg-soft); }
.master-item form { margin: 0; }
.master-item .master-count { color: var(--muted); font-size: .68rem; }
.master-empty { padding: 1rem; color: var(--muted); font-size: .78rem; text-align: center; }

/* Informes */
.report-page { background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); overflow: hidden; }
.report-header { padding: 1.4rem 1.5rem; border-bottom: 2px solid var(--navy); background: linear-gradient(180deg, #fff, #f8fafc); }
.report-header .eyebrow { margin-bottom: .35rem; }
.report-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; }
.report-subtitle { margin-top: .25rem; color: var(--muted); font-size: .82rem; }
.report-meta { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: .75rem; color: var(--text-soft); font-size: .78rem; }
.report-body { padding: 1.25rem 1.5rem 1.5rem; }
.report-section { margin-bottom: 1.6rem; }
.report-section:last-child { margin-bottom: 0; }
.report-section h2 { margin-bottom: .55rem; font-size: .95rem; font-weight: 750; }
.report-section h3 { margin: 1rem 0 .45rem; font-size: .86rem; font-weight: 750; }
.report-table-wrap { width: 100%; overflow-x: auto; }
.report-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: .76rem; }
.report-table th, .report-table td { padding: .45rem .5rem; border: 1px solid #dbe3ec; vertical-align: top; }
.report-table th { background: #eef3f9; color: #334155; font-size: .66rem; font-weight: 800; letter-spacing: .03em; text-align: center; text-transform: uppercase; }
.report-table td.num, .report-table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-table tr.is-group td { background: #f8fafc; font-weight: 700; }
.report-table tr.is-total td { background: #e8eef7; font-weight: 800; border-top: 2px solid var(--navy); }
.report-table .service-name { min-width: 180px; }
.report-totals { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.report-chip { display: inline-flex; align-items: baseline; gap: .35rem; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font-size: .75rem; }
.report-chip strong { font-size: .9rem; }
.report-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.print-only { display: none; }

/* Formulario de correo */
.mail-form { padding: 1.25rem; }
.mail-preview { margin-top: 1rem; padding: .9rem 1rem; border: 1px dashed #c9d6e5; border-radius: 11px; background: var(--surface-2); color: var(--muted); font-size: .8rem; }

/* Login */
.auth-form .password-wrap { position: relative; }
.auth-form .password-wrap input { padding-right: 2.6rem; }
.password-toggle { position: absolute; right: .45rem; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.password-toggle:hover { background: var(--bg-soft); color: var(--text); }
.auth-note { margin-top: .9rem; padding: .65rem .75rem; border: 1px solid #c9d9fa; border-radius: 10px; background: var(--info-soft); color: #1e3a8a; font-size: .76rem; line-height: 1.45; }

/* Responsive */
@media (max-width: 1280px) {
    .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .master-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    .topbar-actions .btn span { display: none; }
    .topbar-user-text { display: none; }
}

@media (max-width: 760px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .field-span-2, .form-grid .field-span-3, .form-grid .field-span-4 { grid-column: auto; }
    .master-grid { grid-template-columns: 1fr; }
    .topbar-actions { gap: .3rem; }
    .topbar-actions .btn { padding: .45rem .55rem; }
    .report-header, .report-body { padding-left: 1rem; padding-right: 1rem; }
    .record-form, .mail-form { padding: 1rem; }
    .form-actions .form-actions-right { width: 100%; margin-left: 0; }
    .form-actions .form-actions-right .btn { flex: 1; }
}

/* Impresión: informes limpios y sin controles */
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    body { background: #fff !important; }
    .sidebar, .sidebar-overlay, .topbar, .app-footer, .flash, .no-print, .report-actions, .filters, .pagination, .table-toolbar { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .content { max-width: none !important; padding: 0 !important; }
    .report-page { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
    .report-header { border-bottom: 2px solid #000 !important; background: #fff !important; }
    .report-body { padding: 0 !important; }
    .report-table-wrap { overflow: visible !important; }
    .report-table { min-width: 0 !important; width: 100% !important; font-size: 8pt !important; }
    .report-table th, .report-table td { padding: 2pt 3pt !important; border-color: #777 !important; }
    .report-table th { background: #e8e8e8 !important; color: #000 !important; }
    .print-only { display: block !important; }
    .panel { break-inside: avoid; }
}
