/* ============================================================
   SITUADO DE PUERTO JACK E IP — SISTEMA DE DISEÑO
   1. Tokens
   2. Base y utilidades
   3. Encabezado y menús
   4. Acceso (login)
   5. Contenido principal
   6. KPIs, captura y formularios
   7. Registros y tabla
   8. Modales, toasts y loader
   9. Diseño responsivo
   ============================================================ */

/* ============================================================
   0. TIPOGRAFÍA AUTOALOJADA (Inter variable, latin)
   ============================================================ */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/inter-latin-variable.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================================
   1. TOKENS DE DISEÑO
   ============================================================ */
:root {
    /* Marca: verde azulado profundo, en armonía con el logo */
    --brand-50: #effcf9;
    --brand-100: #d7f5ee;
    --brand-200: #b0e9df;
    --brand-300: #7dd8ca;
    --brand-400: #45bfb0;
    --brand-500: #1fa393;
    --brand-600: #0f8276;
    --brand-700: #0f675f;
    --brand-800: #11524c;
    --brand-900: #123f3b;
    --brand-950: #082623;

    /* Acento cálido: guiño al detalle amarillo del logo */
    --accent-400: #fbbf24;
    --accent-500: #f59e0b;
    --accent-600: #d97706;

    /* Tinta y neutros */
    --ink-950: #071018;
    --ink-900: #0f172a;
    --ink-800: #1e293b;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #5b6b80;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-50: #f8fafc;

    /* Semánticos */
    --success-50: #ecfdf5;
    --success-100: #d1fae5;
    --success-500: #10b981;
    --success-600: #059669;
    --success-700: #047857;
    --danger-50: #fef2f2;
    --danger-100: #fee2e2;
    --danger-500: #ef4444;
    --danger-600: #dc2626;
    --danger-700: #b91c1c;
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;

    /* Superficies, bordes y texto */
    --bg: #f4f7f6;
    --surface: #ffffff;
    --surface-soft: #fbfcfc;
    --border: #e2e8e7;
    --border-soft: #edf2f1;
    --border-strong: #cbd5d3;
    --text: var(--ink-700);
    --text-soft: var(--ink-500);
    --text-muted: var(--ink-400);
    --heading: var(--ink-900);
    --primary: var(--brand-600);
    --primary-hover: var(--brand-700);
    --primary-soft: var(--brand-50);
    --color-focus: rgba(15, 130, 118, 0.28);
    --ring: 0 0 0 3px var(--color-focus);

    /* Tipografía */
    --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --text-xs: 11px;
    --text-sm: 12px;
    --text-base: 13px;
    --text-md: 14px;
    --text-lg: 16px;
    --text-xl: 18px;
    --text-2xl: 22px;

    /* Espaciado */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Radios */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* Sombras */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 24px 60px rgba(2, 20, 25, 0.18);
    --shadow-primary: 0 10px 24px rgba(15, 130, 118, 0.22);

    /* Movimiento */
    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
    --transition-fast: 130ms var(--ease);
    --transition: 200ms var(--ease);

    /* Estructura */
    --container: 1320px;
    --header-height: 68px;

    /* Capas */
    --z-header: 100;
    --z-dropdown: 150;
    --z-modal: 200;
    --z-toast: 300;
}

/* ============================================================
   2. BASE Y UTILIDADES
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 8% -10%, rgba(31, 163, 147, 0.06), transparent 32%),
        radial-gradient(circle at 96% -4%, rgba(245, 158, 11, 0.05), transparent 26%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
}

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

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

button.is-busy {
    pointer-events: none;
}

body.modal-open {
    overflow: hidden;
}

:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

::selection {
    background: var(--brand-200);
    color: var(--brand-900);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.icon {
    display: inline-block;
    flex-shrink: 0;
    vertical-align: middle;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

.spinner-lg {
    width: 38px;
    height: 38px;
    border-width: 3px;
    color: var(--brand-600);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   3. ENCABEZADO Y MENÚS
   ============================================================ */
.app-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    width: 100%;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px) saturate(1.35);
    -webkit-backdrop-filter: blur(16px) saturate(1.35);
}

.app-header__inner {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    width: 100%;
    max-width: var(--container);
    min-height: var(--header-height);
    margin: 0 auto;
    padding: 0 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand__logo {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--brand-100);
    border-radius: 12px;
    background: var(--brand-50);
}

.brand__logo .appLogo {
    width: auto;
    max-width: 32px;
    max-height: 30px;
    object-fit: contain;
}

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

.brand__name {
    color: var(--ink-900);
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 0.07em;
    white-space: nowrap;
}

.brand__sub {
    color: var(--ink-500);
    font-size: 11px;
    font-weight: 500;
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    min-width: 0;
}

.user-panel {
    display: none;
    position: relative;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink-600);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast),
                transform var(--transition-fast);
}

.header-btn:hover {
    border-color: var(--brand-200);
    background: var(--brand-50);
    color: var(--brand-800);
}

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

.header-btn--primary {
    border-color: var(--brand-600);
    background: var(--brand-600);
    color: #fff;
    box-shadow: 0 7px 16px rgba(15, 130, 118, 0.20);
}

.header-btn--primary:hover {
    border-color: var(--brand-700);
    background: var(--brand-700);
    color: #fff;
}

.header-btn:focus-visible,
.user-chip:focus-visible,
.btn-change-logo:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 4px 10px 4px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink-700);
    text-align: left;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
                background var(--transition-fast);
}

.user-chip:hover {
    border-color: var(--brand-200);
    background: var(--surface-soft);
    box-shadow: var(--shadow-sm);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

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

.user-chip__text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.2;
}

#userDisplay {
    max-width: 160px;
    overflow: hidden;
    color: var(--ink-900);
    font-size: 12.5px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#userRole {
    color: var(--ink-500);
    font-size: 10.5px;
    font-weight: 600;
}

.user-chip__chevron {
    display: inline-flex;
    align-items: center;
    margin-left: 2px;
    color: var(--ink-400);
}

.btn-change-logo {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink-500);
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), transform var(--transition-fast);
}

.btn-change-logo:hover {
    border-color: var(--brand-200);
    background: var(--brand-50);
    color: var(--brand-700);
    transform: scale(1.04);
}

/* ---------- menús desplegables ---------- */
.dropdown-session {
    position: relative;
    display: inline-block;
}

.dropdown-menu-session {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: var(--z-dropdown);
    min-width: min(200px, calc(100vw - 40px));
    max-width: calc(100vw - 40px);
    max-height: 70vh;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.dropdown-menu-session button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 11px;
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--ink-700);
    font-size: 12.5px;
    font-weight: 500;
    text-align: left;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.dropdown-menu-session button:hover {
    background: var(--brand-50);
    color: var(--brand-800);
}

.dropdown-menu-session button.danger-option {
    color: var(--danger-600);
}

.dropdown-menu-session button.danger-option:hover {
    background: var(--danger-50);
    color: var(--danger-700);
}

.new-user-menu {
    top: calc(100% + 10px);
    right: 0;
    left: auto;
    width: min(330px, calc(100vw - 40px));
    min-width: min(280px, calc(100vw - 40px));
    padding: 18px;
}

.new-user-titulo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--ink-900);
    font-size: 13px;
    font-weight: 700;
}

.new-user-menu .field-group {
    margin-bottom: 10px;
}

.new-user-menu .field-group label {
    font-size: 10.5px;
}

.new-user-menu .actions-row {
    margin-top: 14px;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: var(--z-dropdown);
    width: min(410px, calc(100vw - 40px));
    max-width: calc(100vw - 40px);
    max-height: 72vh;
    overflow-y: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.user-dropdown__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-soft);
}

.user-dropdown__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--brand-50);
    color: var(--brand-700);
}

.user-dropdown__head h4 {
    color: var(--ink-900);
    font-size: 12.5px;
    font-weight: 700;
}

.user-dropdown__head p {
    color: var(--ink-500);
    font-size: 10.5px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 7px;
    border-radius: 10px;
    transition: background var(--transition-fast);
}

.user-item:hover {
    background: var(--ink-50);
}

.user-item-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.user-item-main strong {
    overflow-wrap: anywhere;
    color: var(--ink-900);
    font-size: 12.5px;
    font-weight: 700;
}

.user-item-sub {
    overflow-wrap: anywhere;
    color: var(--ink-500);
    font-size: 10.5px;
}

.user-item-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 5px;
    margin-left: auto;
    flex-shrink: 0;
}

.user-item-actions select {
    max-width: 118px;
    min-height: 32px;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink-700);
    font-size: 11px;
}

.badge-role {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--ink-50);
    color: var(--ink-600);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-role-admin {
    border-color: var(--brand-100);
    background: var(--brand-50);
    color: var(--brand-700);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-400);
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), transform var(--transition-fast);
}

.btn-icon:hover {
    border-color: var(--brand-100);
    background: var(--brand-50);
    color: var(--brand-700);
}

.btn-icon-danger:hover {
    border-color: var(--danger-100);
    background: var(--danger-50);
    color: var(--danger-600);
}

.btn-icon:active {
    transform: scale(0.96);
}

.user-empty {
    padding: 18px 6px;
    color: var(--ink-500);
    font-size: 12px;
    text-align: center;
}

.user-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 22px 12px;
    color: var(--ink-500);
    font-size: 12px;
    text-align: center;
}

.user-state .spinner {
    color: var(--brand-600);
}

.user-state-error {
    color: var(--danger-600);
}

.user-state-error p {
    max-width: 280px;
    line-height: 1.5;
}

.user-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 9px 10px;
    border: 1px solid var(--warning-100);
    border-radius: 10px;
    background: var(--warning-50);
    color: var(--warning-600);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.user-warning svg {
    flex-shrink: 0;
}

.user-warning span {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.user-warning button {
    flex-shrink: 0;
    padding: 3px 8px;
    border: 1px solid var(--warning-500);
    border-radius: 7px;
    background: var(--surface);
    color: var(--warning-600);
    font-size: 10.5px;
    font-weight: 700;
}

.user-warning button:hover {
    background: var(--warning-100);
}

/* ============================================================
   4. ACCESO (LOGIN)
   ============================================================ */
.app-loader {
    display: none;
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) + 1);
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

html.has-session .app-loader {
    display: flex;
}

html.has-session #loginWrapper {
    display: none !important;
}

.app-loader__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--ink-500);
    font-size: 13px;
    font-weight: 600;
}

.login-wrapper {
    display: flex;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 32px 24px;
    overflow: hidden;
    background:
        radial-gradient(circle at 10% 6%, rgba(31, 163, 147, 0.24), transparent 36%),
        radial-gradient(circle at 90% 0%, rgba(245, 158, 11, 0.13), transparent 30%),
        linear-gradient(135deg, #061b1a 0%, #092c2a 52%, #0d3b37 100%);
}

.login-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: radial-gradient(circle at center, #000 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(circle at center, #000 0%, transparent 78%);
    pointer-events: none;
}

.login-shell {
    display: flex;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1080px;
    min-height: 630px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 26px;
    background: var(--surface);
    box-shadow: 0 34px 90px rgba(0, 10, 12, 0.38);
    animation: card-in 260ms var(--ease);
}

.login-brand {
    display: flex;
    position: relative;
    isolation: isolate;
    flex: 1 1 52%;
    flex-direction: column;
    justify-content: space-between;
    gap: 34px;
    overflow: hidden;
    padding: 48px 46px;
    background:
        radial-gradient(circle at 85% 12%, rgba(245, 158, 11, 0.20), transparent 30%),
        radial-gradient(circle at 10% 90%, rgba(31, 163, 147, 0.22), transparent 36%),
        linear-gradient(155deg, #082623 0%, #0b3936 48%, #0f514a 100%);
    color: #fff;
}

.login-brand__watermark {
    position: absolute;
    z-index: 0;
    top: 50%;
    right: 0;
    width: 64%;
    max-width: 400px;
    height: 88%;
    object-fit: contain;
    opacity: 0.12;
    mix-blend-mode: multiply;
    pointer-events: none;
    user-select: none;
    transform: translateY(-50%);
}

.login-brand::after {
    content: "";
    position: absolute;
    right: -80px;
    bottom: -90px;
    width: 280px;
    height: 280px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 50%;
    box-shadow: 0 0 0 42px rgba(255, 255, 255, 0.025), 0 0 0 84px rgba(255, 255, 255, 0.018);
    pointer-events: none;
}

.login-brand__top {
    display: flex;
    position: relative;
    z-index: 1;
    align-items: center;
    gap: 10px;
}

.logo-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 84px;
    flex-shrink: 0;
    padding: 9px;
    aspect-ratio: 1 / 1;
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

.logo-tile .appLogo {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.login-brand__badge {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    padding: 7px 11px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.82);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.login-brand__body {
    position: relative;
    z-index: 1;
    max-width: 430px;
}

.eyebrow {
    margin-bottom: 9px;
    color: var(--brand-700);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.eyebrow--light {
    color: var(--brand-300);
}

.login-brand__title {
    margin-bottom: 14px;
    color: #fff;
    font-size: clamp(25px, 2.9vw, 35px);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.025em;
}

.login-brand__text {
    max-width: 390px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 13.5px;
    line-height: 1.6;
}

.login-brand__points {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 28px;
    list-style: none;
}

.login-brand__points li {
    display: flex;
    align-items: center;
    gap: 11px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 12px;
    line-height: 1.45;
}

.login-brand__point-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--brand-300);
}

.login-brand__foot {
    position: relative;
    z-index: 1;
    color: rgba(255, 255, 255, 0.82);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.login-panel {
    display: flex;
    flex: 1 1 48%;
    align-items: center;
    justify-content: center;
    padding: 48px 44px;
    background:
        radial-gradient(circle at 100% 0%, rgba(31, 163, 147, 0.05), transparent 32%),
        var(--surface);
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    text-align: left;
    animation: card-in 240ms var(--ease);
}

.login-card h2 {
    margin-bottom: 6px;
    overflow-wrap: anywhere;
    color: var(--ink-900);
    font-size: clamp(24px, 2.6vw, 29px);
    font-weight: 800;
    line-height: 1.14;
    letter-spacing: -0.025em;
}

.login-sub {
    margin-bottom: 26px;
    color: var(--ink-500);
    font-size: 12.5px;
    line-height: 1.5;
}

.login-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--ink-700);
    text-align: left;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                box-shadow var(--transition-fast), transform var(--transition-fast);
}

.login-option:hover {
    border-color: var(--brand-200);
    background: var(--brand-50);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.login-option:active {
    transform: translateY(0);
}

.login-option-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 1px solid var(--brand-100);
    border-radius: 12px;
    background: var(--brand-50);
    color: var(--brand-700);
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast);
}

.login-option:hover .login-option-icon {
    border-color: var(--brand-600);
    background: var(--brand-600);
    color: #fff;
}

.login-option-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.login-option-text strong {
    color: var(--ink-900);
    font-size: 12.5px;
    font-weight: 700;
}

.login-option-text small {
    color: var(--ink-500);
    font-size: 10.5px;
}

.login-option-arrow {
    display: inline-flex;
    align-items: center;
    color: var(--ink-400);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.login-option:hover .login-option-arrow {
    color: var(--brand-700);
    transform: translateX(2px);
}

.login-help {
    margin-top: 20px;
    color: var(--ink-500);
    font-size: 10.5px;
    line-height: 1.5;
    text-align: center;
}

.login-back {
    position: absolute;
    top: -6px;
    left: -6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--ink-400);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.login-back:hover {
    background: var(--ink-100);
    color: var(--brand-700);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.form-group-login {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group-login label {
    color: var(--ink-600);
    font-size: 11px;
    font-weight: 700;
}

.form-group-login input {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    background: var(--surface-soft);
    color: var(--ink-800);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
                background var(--transition-fast);
}

.form-group-login input::placeholder {
    color: var(--ink-400);
}

.form-group-login input:focus {
    border-color: var(--brand-400);
    background: var(--surface);
    box-shadow: var(--ring);
}

.btn-login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    margin-top: 2px;
    padding: 12px 16px;
    border: 1px solid var(--brand-600);
    border-radius: 11px;
    background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    box-shadow: var(--shadow-primary);
    transition: background var(--transition-fast), transform var(--transition-fast),
                box-shadow var(--transition-fast);
}

.btn-login:hover {
    background: linear-gradient(180deg, var(--brand-600), var(--brand-700));
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(15, 130, 118, 0.28);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* ---------- campos de contraseña ---------- */
.password-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-field-wrapper input {
    padding-right: 44px !important;
}

.pass-masked {
    -webkit-text-security: disc;
    text-security: disc;
}

.toggle-password-btn {
    position: absolute;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink-400);
    font-size: var(--text-md);
    user-select: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.toggle-password-btn:hover {
    background: var(--ink-100);
    color: var(--brand-700);
}

.password-field-wrapper--inside-toggle {
    gap: 0;
}

.password-field-wrapper--inside-toggle input {
    flex: 1 1 0;
    min-width: 0;
    padding-right: 48px !important;
}

.password-field-wrapper--inside-toggle .toggle-password-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 32px;
    min-width: 32px;
    flex: none;
    gap: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: var(--text-md);
    text-align: center;
}

.password-field-wrapper--inside-toggle .toggle-password-btn:hover {
    background: var(--ink-100);
    color: var(--brand-700);
}

/* ============================================================
   5. CONTENIDO PRINCIPAL
   ============================================================ */
.app-main {
    display: none;
    flex-direction: column;
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 32px 28px 64px;
    gap: 22px;
}

/* ---------- tarjetas base ---------- */
.card {
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

/* ============================================================
   6. KPIS, CAPTURA Y FORMULARIOS
   ============================================================ */
.kpi-container {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.kpi-card {
    display: flex;
    position: relative;
    align-items: center;
    gap: 9px;
    min-width: 0;
    padding: 10px 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    text-align: left;
    user-select: none;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast),
                border-color var(--transition-fast);
}

.kpi-card:hover {
    border-color: var(--brand-200);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kpi-card:focus-visible {
    outline: none;
    box-shadow: var(--ring), var(--shadow-md);
}

.kpi-card-active {
    border-color: var(--brand-300);
    background: linear-gradient(180deg, #ffffff 0%, var(--brand-50) 180%);
    box-shadow: 0 0 0 3px rgba(15, 130, 118, 0.07), var(--shadow-sm);
}

.kpi-card-active::before {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 0;
    width: 3px;
    border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
    background: var(--brand-600);
}

.kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 9px;
}

.kpi-blue   { background: var(--brand-50); color: var(--brand-700); }
.kpi-green  { background: var(--success-50); color: var(--success-600); }
.kpi-red    { background: var(--danger-50); color: var(--danger-600); }
.kpi-orange { background: var(--warning-50); color: var(--warning-600); }

.kpi-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kpi-value {
    color: var(--ink-900);
    font-size: 21px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.kpi-label {
    margin-top: 2px;
    overflow-wrap: anywhere;
    color: var(--ink-500);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- tarjeta de captura con pestañas ---------- */
.capture {
    padding: 24px;
    scroll-margin-top: 92px;
}

.capture__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-soft);
}

.capture__intro {
    min-width: 0;
}

.capture__title {
    color: var(--ink-900);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.capture__hint {
    margin-top: 5px;
    color: var(--ink-500);
    font-size: 12px;
    line-height: 1.5;
}

.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--ink-100);
}

.segmented__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink-500);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast),
                box-shadow var(--transition-fast);
}

.segmented__btn:hover {
    color: var(--ink-800);
}

.segmented__btn.is-active {
    background: var(--surface);
    color: var(--brand-800);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.segmented__btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.form-panel {
    min-width: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

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

.field-group label {
    color: var(--ink-600);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.field-group input,
.field-group select,
.field-group textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
    color: var(--ink-800);
    font-size: 12.5px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
                background var(--transition-fast);
}

.field-group input::placeholder,
.field-group textarea::placeholder {
    color: var(--ink-400);
}

.field-group textarea {
    font-family: inherit;
    resize: vertical;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
    border-color: var(--brand-400);
    background: var(--surface);
    box-shadow: var(--ring);
}

.form-error {
    margin: 12px 0 0;
    padding: 10px 12px;
    border: 1px solid var(--danger-100);
    border-radius: 9px;
    background: var(--danger-50);
    color: var(--danger-700);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.45;
    text-align: left;
}

.form-error[hidden] {
    display: none;
}

.actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
    min-width: 0;
}

.actions-row--spread {
    justify-content: space-between;
}

/* ---------- botones reutilizables ---------- */
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast),
                transform var(--transition-fast);
}

.btn-primary {
    border-color: var(--brand-600);
    background: var(--brand-600);
    color: #fff;
    box-shadow: 0 5px 14px rgba(15, 130, 118, 0.16);
}

.btn-primary:hover {
    border-color: var(--brand-700);
    background: var(--brand-700);
    box-shadow: var(--shadow-sm);
}

.btn-primary:active {
    background: var(--brand-800);
    border-color: var(--brand-800);
    transform: translateY(1px);
}

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

.btn-secondary:hover {
    border-color: var(--ink-400);
    background: var(--ink-50);
    color: var(--ink-800);
}

.btn-outline {
    border-color: var(--brand-200);
    background: var(--surface);
    color: var(--brand-700);
}

.btn-outline:hover {
    border-color: var(--brand-300);
    background: var(--brand-50);
    color: var(--brand-800);
}

.btn-danger {
    border-color: var(--danger-600);
    background: var(--danger-600);
    color: #fff;
    box-shadow: 0 5px 14px rgba(220, 38, 38, 0.16);
}

.btn-danger:hover {
    border-color: var(--danger-700);
    background: var(--danger-700);
    box-shadow: var(--shadow-sm);
}

.btn-sm {
    min-height: 32px;
    padding: 0 11px;
    border-radius: 8px;
    font-size: 11px;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-outline:focus-visible,
.btn-danger:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.btn-primary.is-busy,
.btn-secondary.is-busy,
.btn-outline.is-busy,
.btn-danger.is-busy,
.btn-login.is-busy {
    gap: 8px;
}

/* ============================================================
   7. REGISTROS Y TABLA
   ============================================================ */
.records {
    min-width: 0;
}

.records__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-soft);
}

.records__title-wrap {
    min-width: 0;
}

.records__title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-900);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.records__title .icon {
    color: var(--brand-600);
}

.records__summary {
    margin-top: 3px;
    color: var(--ink-500);
    font-size: 11.5px;
}

.piso-filtros {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.btn-piso {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink-600);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-piso:hover {
    border-color: var(--brand-300);
    background: var(--brand-50);
    color: var(--brand-800);
}

.btn-piso-active {
    border-color: var(--brand-600);
    background: var(--brand-600);
    color: #fff;
    box-shadow: 0 3px 8px rgba(15, 130, 118, 0.20);
}

.btn-piso-active:hover {
    border-color: var(--brand-700);
    background: var(--brand-700);
    color: #fff;
}

.records__toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-soft);
}

.search-field {
    position: relative;
    flex: 1 1 260px;
    max-width: 430px;
    min-width: 0;
}

.search-input {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px 8px 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: var(--surface);
    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='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    color: var(--ink-800);
    font-size: 12.5px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input::placeholder {
    color: var(--ink-400);
}

.search-input:focus {
    border-color: var(--brand-400);
    box-shadow: var(--ring);
}

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

/* ---------- tabla ---------- */
.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
}

#recordsTable {
    min-width: 1040px;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 11.5px;
    text-align: left;
}

th {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--ink-50);
    color: var(--ink-500);
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--ink-600);
    text-align: left;
    vertical-align: middle;
    overflow-wrap: break-word;
    word-break: break-word;
}

tbody tr[data-idx]:hover {
    background: #f7fbfa;
}

tbody tr[data-idx]:last-child td {
    border-bottom: 0;
}

#recordsTable th:nth-child(1)  { width: 4%; }
#recordsTable th:nth-child(2)  { width: 9%; }
#recordsTable th:nth-child(3)  { width: 10%; }
#recordsTable th:nth-child(4)  { width: 9%; }
#recordsTable th:nth-child(5)  { width: 7%; }
#recordsTable th:nth-child(6)  { width: 11%; }
#recordsTable th:nth-child(7)  { width: 10%; }
#recordsTable th:nth-child(8)  { width: 8%; }
#recordsTable th:nth-child(9)  { width: 11%; }
#recordsTable th:nth-child(10) { width: 14%; }
#recordsTable th:nth-child(11) { width: 7%; }

#recordsTable td.col-acc {
    text-align: right;
    white-space: nowrap;
}

#recordsTable th.col-acc {
    text-align: right;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.row-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 5px;
    border-radius: 7px;
    background: var(--ink-100);
    color: var(--ink-600);
    font-size: 10.5px;
    font-weight: 700;
}

.cell-strong {
    color: var(--ink-900);
    font-weight: 700;
}

.cell-mono {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: -0.01em;
}

.cell-note {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.type-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border: 1px solid var(--ink-200);
    border-radius: 6px;
    background: var(--ink-50);
    color: var(--ink-600);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: var(--radius-pill);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-si {
    border: 1px solid var(--success-100);
    background: var(--success-50);
    color: var(--success-700);
}

.badge-si::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success-500);
}

.badge-no {
    border: 1px solid var(--danger-100);
    background: var(--danger-50);
    color: var(--danger-700);
}

.badge-no::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--danger-500);
}

.port-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.port-svg {
    flex-shrink: 0;
    vertical-align: middle;
}

.btn-action-edit,
.btn-action-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-400);
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), transform var(--transition-fast);
}

.btn-action-edit:hover {
    border-color: var(--brand-100);
    background: var(--brand-50);
    color: var(--brand-700);
}

.btn-action-delete:hover {
    border-color: var(--danger-100);
    background: var(--danger-50);
    color: var(--danger-600);
}

.btn-action-edit:active,
.btn-action-delete:active {
    transform: scale(0.94);
}

.btn-action-edit:focus-visible,
.btn-action-delete:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

.grupo-depto td,
.grupo-depto-cell {
    padding: 9px 12px !important;
    border-top: 1px solid var(--brand-200);
    border-bottom: 1px solid var(--brand-100);
    background: var(--brand-50);
    color: var(--brand-800);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.grupo-depto-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    margin-left: 8px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: rgba(15, 130, 118, 0.12);
    color: var(--brand-800);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
}

/* ---------- estados vacíos ---------- */
.empty-box {
    margin: 20px 24px;
    padding: 46px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: 14px;
    background: var(--ink-50);
    color: var(--ink-500);
    text-align: center;
}

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin-bottom: 14px;
    border: 1px solid var(--brand-100);
    border-radius: 16px;
    background: var(--brand-50);
    color: var(--brand-600);
}

.empty-icon-error {
    border-color: var(--danger-100);
    background: var(--danger-50);
    color: var(--danger-600);
}

.empty-icon-search {
    border-color: var(--ink-200);
    background: var(--surface);
    color: var(--ink-500);
}

.empty-icon-loading .spinner {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

.empty-box h4 {
    margin-bottom: 4px;
    color: var(--ink-900);
    font-size: 14px;
    font-weight: 700;
}

.empty-box p {
    max-width: 460px;
    margin: 0 auto;
    font-size: 12px;
    line-height: 1.55;
}

.empty-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

/* ============================================================
   8. MODALES, TOASTS Y LOADER
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 20px;
    overflow-y: auto;
    background: rgba(5, 22, 24, 0.56);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    max-height: calc(100dvh - 32px);
    padding: 28px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: modal-in 200ms var(--ease);
}

.modal-content h3 {
    margin-bottom: 16px;
    padding-right: 28px;
    overflow-wrap: anywhere;
    color: var(--ink-900);
    font-size: 19px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-400);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.modal-close:hover {
    background: var(--ink-100);
    color: var(--ink-700);
}

.modal-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-text {
    margin-bottom: 16px;
    color: var(--ink-500);
    font-size: 12.5px;
    line-height: 1.6;
}

.modal-title-danger {
    color: var(--danger-600) !important;
}

.reset-target {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--ink-50);
    color: var(--ink-600);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.55;
    white-space: pre-line;
}

.priv-group {
    margin-bottom: 4px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
}

.check-inline {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--ink-700);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}

.check-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--brand-600);
    cursor: pointer;
}

.check-inline span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.check-inline strong {
    color: var(--ink-800);
    font-size: 12px;
    font-weight: 700;
}

.check-inline small {
    color: var(--ink-500);
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.45;
}

.eliminar-lista {
    max-height: min(260px, 40vh);
    margin-bottom: 12px;
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
}

.eliminar-lista label {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 7px;
    color: var(--ink-700);
    font-size: 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.eliminar-lista label:hover {
    background: var(--brand-50);
}

.eliminar-lista input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--danger-600);
    cursor: pointer;
}

.eliminar-contador {
    margin-bottom: 12px;
    color: var(--danger-600);
    font-size: 11.5px;
    font-weight: 600;
}

/* ---------- notificaciones ---------- */
.toast-notification {
    display: none;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: var(--z-toast);
    align-items: flex-start;
    gap: 11px;
    width: min(390px, calc(100vw - 32px));
    padding: 14px 15px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 14px;
    background: var(--ink-900);
    color: #fff;
    box-shadow: 0 22px 48px rgba(2, 20, 25, 0.28);
    animation: toast-in 180ms var(--ease);
}

.toast-icon {
    display: inline-flex;
    align-items: center;
    margin-top: 1px;
    color: var(--accent-400);
}

.toast-success .toast-icon { color: #34d399; }
.toast-error .toast-icon   { color: #f87171; }
.toast-info .toast-icon    { color: var(--accent-400); }

.toast-message {
    flex: 1;
    overflow-wrap: anywhere;
    font-size: 12px;
    line-height: 1.5;
}

.toast-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: rgba(255, 255, 255, 0.50);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
}

/* ---------- animaciones ---------- */
@keyframes card-in {
    from { opacity: 0; transform: translateY(10px) scale(0.995); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

/* ============================================================
   9. DISEÑO RESPONSIVO
   ============================================================ */

/* ---------- PORTÁTILES Y TABLET HORIZONTAL ---------- */
@media (max-width: 640px) {
    .app-header__inner {
        padding: 0 22px;
    }

    .app-main {
        padding: 28px 22px 56px;
    }

    .header-btn__label {
        display: none;
    }

    .header-btn {
        width: 38px;
        min-width: 38px;
        padding: 0;
    }

    .new-user-menu {
        width: min(320px, calc(100vw - 40px));
    }
}

/* ---------- TABLET ---------- */
@media (max-width: 640px) {
    .kpi-container {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 7px;
    }

    .kpi-card {
        gap: 7px;
        padding: 9px;
    }

    .kpi-icon {
        width: 29px;
        height: 29px;
    }

    .kpi-value {
        font-size: 19px;
    }

    .kpi-label {
        font-size: 8px;
    }

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

    .records__head {
        align-items: flex-start;
    }

    .piso-filtros {
        width: 100%;
    }

    .btn-piso {
        flex: 1 0 auto;
        min-height: 38px;
        text-align: center;
    }

    .records__toolbar {
        align-items: stretch;
    }

    .search-field {
        flex: 1 1 100%;
        max-width: none;
    }

    .records__actions {
        width: 100%;
        margin-left: 0;
    }

    .records__actions .btn-outline,
    .records__actions .btn-primary {
        flex: 1 1 0;
        min-height: 42px;
    }

    .field-group input,
    .field-group select,
    .field-group textarea,
    .form-group-login input,
    .user-item-actions select {
        font-size: 16px;
    }

    .toggle-password-btn {
        width: 36px;
        height: 36px;
    }

    /* La tabla se convierte en tarjetas */
    .table-container {
        overflow: visible;
        padding: 4px 20px 20px;
        background: transparent;
    }

    #recordsTable {
        display: block;
        width: 100%;
        min-width: 0;
        table-layout: auto;
        font-size: var(--text-base);
    }

    #recordsTable,
    #recordsTable tbody,
    #recordsTable tr,
    #recordsTable td {
        display: block;
        width: 100%;
    }

    #recordsTable thead {
        display: none;
    }

    #recordsTable tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    #recordsTable tr[data-idx] {
        padding: 0;
        overflow: hidden;
        border: 1px solid var(--border);
        border-radius: 13px;
        background: var(--surface);
        box-shadow: var(--shadow-xs);
    }

    #recordsTable td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 14px;
        min-width: 0;
        padding: 9px 13px;
        border-bottom: 1px dashed var(--border-soft);
        color: var(--ink-700);
        text-align: right;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    #recordsTable td:last-child {
        border-bottom: 0;
    }

    #recordsTable td::before {
        content: attr(data-label);
        max-width: 45%;
        flex-shrink: 0;
        color: var(--brand-700);
        font-size: 9.5px;
        font-weight: 800;
        line-height: 1.6;
        letter-spacing: 0.06em;
        text-align: left;
        text-transform: uppercase;
    }

    #recordsTable td:first-child {
        background: var(--ink-50);
        border-bottom: 1px solid var(--border);
    }

    #recordsTable td:first-child::before {
        color: var(--ink-500);
    }

    #recordsTable td.col-acc {
        justify-content: flex-end;
        gap: 8px;
        padding: 10px 13px;
    }

    #recordsTable td.col-acc::before {
        content: none;
    }

    #recordsTable .btn-action-edit,
    #recordsTable .btn-action-delete {
        width: 38px;
        height: 38px;
        border-color: var(--border);
        background: var(--surface);
        color: var(--ink-500);
    }

    #recordsTable tr.grupo-depto {
        margin-top: 4px;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    #recordsTable tr.grupo-depto td,
    #recordsTable tr.grupo-depto td.grupo-depto-cell {
        display: block;
        width: 100%;
        padding: 9px 13px !important;
        border: 1px solid var(--brand-200);
        border-radius: 9px;
        background: var(--brand-50);
        color: var(--brand-800);
        font-size: 10.5px !important;
        font-weight: 800;
        text-align: left;
    }

    #recordsTable tr.grupo-depto td::before {
        content: none;
    }

    .port-cell {
        justify-content: flex-end;
        text-align: right;
    }

    .empty-box {
        margin: 16px 20px;
    }
}

/* ---------- TABLET VERTICAL / MÓVIL GRANDE ---------- */
@media (max-width: 600px) {
    .login-shell {
        flex-direction: column;
        max-width: 480px;
        min-height: 0;
    }

    .login-brand {
        flex: none;
        gap: 16px;
        padding: 28px 26px;
    }

    .login-brand__watermark {
        right: 0;
        width: 170px;
        height: 90%;
        opacity: 0.06;
    }

    .login-brand__body {
        max-width: none;
    }

    .login-brand__title {
        max-width: 360px;
        font-size: 24px;
    }

    .login-brand__text {
        max-width: 380px;
        font-size: 12.5px;
    }

    .login-brand__points,
    .login-brand__foot {
        display: none;
    }

    .login-panel {
        padding: 32px 26px 36px;
    }

    .login-card {
        max-width: 100%;
    }

    .brand__sub {
        display: none;
    }

}

/* ---------- MÓVIL ---------- */
@media (max-width: 600px) {
    .app-header__inner {
        gap: 12px;
        padding: 0 16px;
    }

    .brand__logo {
        width: 38px;
        height: 38px;
    }

    .brand__logo .appLogo {
        max-width: 29px;
        max-height: 27px;
    }

    .brand__name {
        font-size: 11.5px;
        letter-spacing: 0.05em;
        white-space: normal;
    }

    .app-header__actions {
        gap: 7px;
    }

    .user-panel {
        gap: 6px;
    }

    .user-chip {
        min-height: 40px;
        padding: 4px 8px 4px 4px;
    }

    .user-chip__text {
        display: none;
    }

    .avatar-sm {
        width: 30px;
        height: 30px;
        font-size: 10.5px;
    }

    .user-chip__chevron {
        margin-left: 0;
    }

    .btn-change-logo {
        width: 36px;
        height: 36px;
    }

    .app-main {
        padding: 24px 16px 48px;
        gap: 18px;
    }

    .capture {
        padding: 18px;
    }

    .capture__head {
        gap: 14px;
    }

    .segmented {
        width: 100%;
    }

    .segmented__btn {
        flex: 1;
    }

    .records__head {
        padding: 18px;
    }

    .records__toolbar {
        padding: 14px 18px;
    }

    .table-container {
        padding: 4px 14px 16px;
    }

    .empty-box {
        margin: 14px;
        padding: 36px 18px;
    }

    .modal-content {
        padding: 24px 20px;
    }

    .toast-notification {
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
    }
}

/* ---------- MÓVIL PEQUEÑO ---------- */
@media (max-width: 600px) {
    .login-wrapper {
        align-items: flex-start;
        padding: 14px 12px;
    }

    .login-shell {
        border-radius: 20px;
    }

    .login-brand {
        padding: 24px 20px;
    }

    .logo-tile {
        width: 76px;
        height: 76px;
        border-radius: 14px;
        padding: 8px;
    }

    .login-brand__title {
        font-size: 21px;
    }

    .login-brand__text {
        display: none;
    }

    .login-panel {
        padding: 26px 20px 30px;
    }

    .login-card h2 {
        font-size: 23px;
    }

    .login-sub {
        margin-bottom: 20px;
    }

    .app-header__inner {
        min-height: 60px;
        padding: 0 12px;
    }

    .brand {
        gap: 9px;
    }

    .brand__name {
        max-width: 140px;
        font-size: 10.5px;
        line-height: 1.25;
    }

    .app-main {
        padding: 20px 12px 40px;
        gap: 16px;
    }

    .kpi-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .kpi-card {
        gap: 8px;
        padding: 8px 10px;
    }

    .kpi-icon {
        width: 28px;
        height: 28px;
        border-radius: 8px;
    }

    .kpi-value {
        font-size: 18px;
    }

    .kpi-label {
        font-size: 8px;
    }

    .capture {
        padding: 16px 14px;
    }

    .capture__title {
        font-size: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .field-group.full-width {
        grid-column: auto;
    }

    .actions-row {
        flex-direction: column;
        align-items: stretch;
    }

    .actions-row > button {
        width: 100%;
        min-height: 44px;
    }

    .actions-row--spread {
        flex-direction: row;
    }

    .actions-row--spread > button {
        width: auto;
        flex: 1;
    }

    .records__head {
        padding: 16px 14px;
    }

    .records__toolbar {
        padding: 12px 14px;
    }

    .records__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .records__actions .btn-outline,
    .records__actions .btn-primary {
        width: 100%;
    }

    .table-container {
        padding: 4px 10px 14px;
    }

    .empty-box {
        margin: 12px;
        padding: 32px 16px;
    }

    .modal {
        align-items: flex-start;
        padding: 12px;
    }

    .modal-content {
        max-height: calc(100dvh - 24px);
        padding: 22px 18px;
        border-radius: 16px;
    }

    .modal-content h3 {
        font-size: 17px;
    }

    .eliminar-lista {
        max-height: 34vh;
    }
}

/* ---------- MÓVILES MUY PEQUEÑOS ---------- */
@media (max-width: 380px) {
    .brand__text {
        display: none;
    }
}

@media (max-width: 390px) {
    .brand__name {
        max-width: 104px;
        font-size: 9.5px;
    }

    .header-btn {
        width: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .user-chip {
        min-height: 36px;
        padding: 3px 6px 3px 3px;
    }

    .avatar-sm {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }

    .kpi-card {
        gap: 7px;
        padding: 7px 8px;
    }

    .kpi-value {
        font-size: 17px;
    }

    .kpi-label {
        font-size: 8.5px;
        letter-spacing: 0.05em;
    }

    .segmented__btn {
        padding: 0 9px;
        font-size: 11px;
    }

    .login-brand {
        padding: 20px 16px;
    }

    .login-panel {
        padding: 22px 16px 26px;
    }

    .login-card h2 {
        font-size: 21px;
    }
}

/* ---------- PANTALLAS BAJAS (móvil horizontal) ---------- */
@media (max-height: 560px) and (orientation: landscape) {
    .login-wrapper {
        align-items: flex-start;
        padding-top: 12px;
    }

    .login-shell {
        min-height: 0;
    }

    .login-brand {
        padding: 16px 20px;
    }

    .login-brand__points,
    .login-brand__text,
    .login-brand__foot {
        display: none;
    }

    .login-brand__title {
        font-size: 19px;
    }

    .login-panel {
        padding: 20px;
    }

    .login-card h2 {
        font-size: 21px;
    }
}

/* ---------- ACCESIBILIDAD: MOVIMIENTO REDUCIDO ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
