:root {
    --primary: #111827;
    --primary-soft: #1f2937;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;

    --bg: #f5f7fb;
    --card: #ffffff;

    --text: #334155;
    --text-dark: #0f172a;
    --muted: #64748b;

    --border: #e2e8f0;
    --border-dark: #cbd5e1;

    --success: #16a34a;
    --success-light: #dcfce7;

    --warning: #d97706;
    --warning-light: #fef3c7;

    --danger: #dc2626;
    --danger-light: #fee2e2;

    --sidebar-width: 238px;
}


/* =========================================================
   GENERAL
========================================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family:
        "Segoe UI",
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a {
    color: var(--accent);
}

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


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);

    position: relative;

    background:
        linear-gradient(
            180deg,
            #031b3a 0%,
            #042552 48%,
            #052f68 100%
        );

    color: #ffffff;

    display: flex;
    flex-direction: column;

    padding: 0 10px 28px;

    overflow-y: auto;
    overflow-x: hidden;

    scrollbar-width: thin;
    scrollbar-color:
        rgba(255, 255, 255, 0.16)
        transparent;

    box-shadow:
        4px 0 18px rgba(15, 23, 42, 0.10);
}


/* Línea decorativa inferior */

.sidebar::after {
    content: "";

    position: absolute;

    left: -60px;
    right: -60px;
    bottom: -85px;

    height: 210px;

    border-radius: 50%;

    background:
        radial-gradient(
            ellipse at center,
            rgba(0, 102, 255, 0.28) 0%,
            rgba(0, 102, 255, 0.08) 42%,
            transparent 72%
        );

    pointer-events: none;
}


/* =========================================================
   MARCA / LOGO
========================================================= */

.sidebar-brand {
    min-height: 88px;

    display: flex;
    align-items: center;

    gap: 12px;

    padding: 16px 10px 15px;

    border-bottom:
        1px solid rgba(148, 163, 184, 0.13);

    margin-bottom: 12px;

    position: relative;
    z-index: 2;
}


.sidebar-logo-box {
    width: 42px;
    height: 42px;

    border-radius: 11px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    background:
        linear-gradient(
            145deg,
            rgba(16, 88, 175, 0.32),
            rgba(6, 39, 83, 0.55)
        );

    border:
        1px solid rgba(120, 180, 255, 0.12);

    box-shadow:
        0 5px 14px rgba(0, 0, 0, 0.16);
}


.sidebar-logo {
    width: 31px;
    height: 31px;

    object-fit: contain;
}


.sidebar-brand-text {
    min-width: 0;

    display: flex;
    flex-direction: column;
}


.sidebar-brand-text strong {
    color: #ffffff;

    font-size: 0.93rem;
    font-weight: 750;

    letter-spacing: 0.5px;

    line-height: 1.2;
}


.sidebar-brand-text span {
    color: #78a9dc;

    font-size: 0.66rem;

    margin-top: 4px;

    letter-spacing: 0.2px;
}


/* =========================================================
   NAVEGACIÓN
========================================================= */

.sidebar-navigation {
    position: relative;
    z-index: 2;

    display: flex;
    flex-direction: column;

    gap: 2px;
}


.menu-section {
    margin-bottom: 9px;
}


.menu-section-title {
    padding: 11px 10px 6px;

    font-size: 0.59rem;
    font-weight: 700;

    letter-spacing: 1.5px;

    color: #6991bd;

    text-transform: uppercase;
}


.menu {
    list-style: none;

    display: flex;
    flex-direction: column;

    gap: 3px;
}


.menu-item {
    position: relative;
}


.menu-item a {
    position: relative;

    display: flex;
    align-items: center;

    gap: 11px;

    width: 100%;

    min-height: 41px;

    padding: 9px 11px;

    border-radius: 7px;

    color: #bad0e7;

    font-size: 0.82rem;
    font-weight: 500;

    line-height: 1;

    text-decoration: none;

    transition:
        background 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}


.menu-icon {
    width: 21px;
    height: 21px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    color: #9bb9d8;

    transition:
        color 0.18s ease,
        transform 0.18s ease;
}


.menu-icon svg {
    width: 18px;
    height: 18px;
}


/* =========================================================
   HOVER
========================================================= */

.menu-item:not(.active):hover a {
    color: #ffffff;

    background:
        rgba(65, 132, 214, 0.12);

    transform:
        translateX(2px);
}


.menu-item:not(.active):hover .menu-icon {
    color: #dcecff;
}


/* =========================================================
   OPCIÓN ACTIVA
========================================================= */

.menu-item.active a {
    color: #ffffff;

    background:
        linear-gradient(
            90deg,
            #0868ec 0%,
            #087bff 100%
        );

    font-weight: 600;

    box-shadow:
        0 5px 14px rgba(8, 105, 238, 0.26),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);

    transform: none;
}


.menu-item.active .menu-icon {
    color: #ffffff;
}


.menu-item.active a::before {
    display: none;
}


/* Pequeño brillo para el activo */

.menu-item.active a::after {
    content: "";

    position: absolute;

    inset: 0;

    border-radius: inherit;

    pointer-events: none;

    box-shadow:
        inset 0 0 0 1px
        rgba(255, 255, 255, 0.06);
}


/* =========================================================
   BADGE DE SUPER ADMIN
========================================================= */

.menu-item a > span:last-child {
    min-width: 0;
}


/* =========================================================
   SCROLLBAR
========================================================= */

.sidebar::-webkit-scrollbar {
    width: 5px;
}


.sidebar::-webkit-scrollbar-track {
    background: transparent;
}


.sidebar::-webkit-scrollbar-thumb {
    background:
        rgba(148, 184, 220, 0.20);

    border-radius: 999px;
}


.sidebar::-webkit-scrollbar-thumb:hover {
    background:
        rgba(148, 184, 220, 0.34);
}

/* =========================================================
   MAIN
========================================================= */

.main-content {
    flex: 1;

    min-width: 0;

    display: flex;
    flex-direction: column;
}


/* =========================================================
   NAVBAR
========================================================= */

.navbar {
    min-height: 70px;

    padding: 12px 28px;

    background: #fff;

    border-bottom:
        1px solid var(--border);

    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 20px;
}

.navbar-page {
    display: flex;
    flex-direction: column;
}

.page-title {
    color: var(--text-dark);

    font-size: 1.12rem;
    font-weight: 700;
}

.page-subtitle {
    margin-top: 2px;

    color: #94a3b8;

    font-size: 0.72rem;
}

.navbar-right {
    display: flex;
    align-items: center;

    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;

    gap: 9px;
}

.user-avatar {
    width: 36px;
    height: 36px;

    border-radius: 50%;

    background: var(--accent-light);

    color: var(--accent);

    display: flex;
    align-items: center;
    justify-content: center;

    font-weight: 700;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details strong {
    color: var(--text-dark);

    font-size: 0.79rem;
}

.user-details span {
    color: #94a3b8;

    font-size: 0.68rem;

    text-transform: capitalize;
}

.logout-button {
    background: transparent;

    color: var(--danger);

    border: 1px solid #fecaca;

    padding: 7px 12px;

    border-radius: 6px;

    font-size: 0.78rem;
}

.logout-button:hover {
    background: var(--danger-light);

    opacity: 1;
}


/* =========================================================
   CONTENT
========================================================= */

.content-area {
    padding: 26px;

    display: flex;
    flex-direction: column;

    gap: 20px;

    width: 100%;
}

.login-content {
    min-height: 100vh;

    align-items: center;
    justify-content: center;

    padding: 16px 20px;

    background:
        radial-gradient(
            circle at 50% 0%,
            #e4edff 0%,
            #f5f7fb 55%
        );
}

.login-content > .alert {
    width: 100%;
    max-width: 420px;

    margin: 0;
}


/* =========================================================
   PANELS
========================================================= */

.panel {
    background: var(--card);

    border:
        1px solid var(--border);

    border-radius: 10px;

    padding: 21px;
}

.panel-header {
    color: var(--text-dark);

    font-size: 1rem;
    font-weight: 650;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    margin-bottom: 18px;

    padding-bottom: 13px;

    border-bottom:
        1px solid var(--border);
}


/* =========================================================
   MÉTRICAS DASHBOARD
========================================================= */

.metrics-grid {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(190px, 1fr)
        );

    gap: 16px;
}

.metric-card {
    background: var(--card);

    border:
        1px solid var(--border);

    border-radius: 10px;

    padding: 20px;

    transition:
        transform 0.2s ease,
        border-color 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);

    border-color: var(--border-dark);
}

.metric-card h4 {
    color: var(--muted);

    text-transform: uppercase;

    font-size: 0.72rem;

    letter-spacing: 0.5px;

    margin-bottom: 10px;
}

.metric-card .number {
    color: var(--text-dark);

    font-size: 1.7rem;
    font-weight: 750;
}

.metric-card.warning .number {
    color: var(--warning);
}


/* =========================================================
   BOTONES
========================================================= */

.btn,
button,
.btn-primary,
.btn-success {
    border: none;

    border-radius: 6px;

    cursor: pointer;

    padding: 9px 16px;

    font-size: 0.84rem;

    font-weight: 600;

    text-decoration: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 6px;

    transition:
        background 0.2s ease,
        opacity 0.2s ease;
}

.btn,
.btn-primary,
button {
    background: var(--accent);

    color: #fff;
}

.btn:hover,
.btn-primary:hover,
button:hover {
    background: var(--accent-hover);

    opacity: 1;
}

.btn-success {
    background: var(--success);

    color: #fff;
}

.btn-success:hover {
    background: #15803d;
}

.link-button {
    background: none;

    color: var(--danger);

    border: none;

    padding: 0;

    text-decoration: underline;

    cursor: pointer;

    font-size: 0.84rem;
}


/* =========================================================
   TABLAS
========================================================= */

table {
    width: 100%;

    border-collapse: separate;
    border-spacing: 0;

    background: #fff;

    font-size: 0.86rem;
}

th {
    background: #f8fafc;

    color: #475569;

    font-size: 0.74rem;

    text-transform: uppercase;

    letter-spacing: 0.3px;

    font-weight: 650;
}

th,
td {
    padding: 12px 13px;

    border-bottom:
        1px solid var(--border);
}

tbody tr {
    transition:
        background 0.15s ease;
}

tbody tr:hover {
    background: #fafcff;
}


/* =========================================================
   BADGES
========================================================= */

.badge {
    padding: 4px 8px;

    border-radius: 20px;

    font-size: 0.7rem;

    font-weight: 650;

    display: inline-flex;
}

.badge-success {
    background: var(--success-light);

    color: #15803d;
}

.badge-warning {
    background: var(--warning-light);

    color: #b45309;
}

.badge-danger {
    background: var(--danger-light);

    color: #b91c1c;
}


/* =========================================================
   FORMULARIOS BASE
========================================================= */

.form-group {
    display: flex;
    flex-direction: column;

    gap: 6px;

    margin-bottom: 15px;
}

.form-group label {
    color: #374151;

    font-size: 0.81rem;

    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;

    min-height: 41px;

    padding: 9px 11px;

    border:
        1px solid var(--border-dark);

    border-radius: 6px;

    background: #fff;

    color: var(--text-dark);

    font-size: 0.86rem;

    outline: none;

    transition:
        border 0.2s ease,
        box-shadow 0.2s ease;
}

textarea {
    min-height: 95px;

    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #60a5fa;

    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.10);
}

input::placeholder,
textarea::placeholder {
    color: #a1aab8;
}

.form-grid {
    display: grid;

    grid-template-columns:
        repeat(
            2,
            minmax(0, 1fr)
        );

    gap: 16px;
}


/* =========================================================
   FORMULARIO MODERNO REUTILIZABLE
========================================================= */

.entity-form-panel {
    max-width: 920px;

    margin: 0 auto;
}

.entity-form-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;

    padding-bottom: 18px;

    margin-bottom: 22px;

    border-bottom:
        1px solid var(--border);
}

.entity-form-header h2 {
    color: var(--text-dark);

    font-size: 1.42rem;

    margin-bottom: 5px;
}

.entity-form-header p {
    color: var(--muted);

    font-size: 0.85rem;

    line-height: 1.5;

    max-width: 600px;
}

.entity-form {
    display: flex;
    flex-direction: column;

    gap: 20px;
}

.entity-form-section {
    border:
        1px solid var(--border);

    border-radius: 9px;

    padding: 20px;

    background: #fbfcfe;
}

.entity-section-header {
    display: flex;
    align-items: center;

    gap: 11px;

    margin-bottom: 18px;
}

.entity-section-number {
    width: 31px;
    height: 31px;

    border-radius: 7px;

    background: var(--accent-light);

    color: var(--accent);

    font-weight: 700;

    display: flex;
    align-items: center;
    justify-content: center;
}

.entity-section-header h3 {
    color: var(--text-dark);

    font-size: 0.94rem;
}

.entity-section-header p {
    margin-top: 2px;

    color: var(--muted);

    font-size: 0.76rem;
}

.entity-form-actions {
    display: flex;
    justify-content: flex-end;

    gap: 10px;

    padding-top: 4px;
}

.btn-secondary {
    background: #fff;

    color: #475569;

    border:
        1px solid var(--border-dark);
}

.btn-secondary:hover {
    background: #f1f5f9;

    color: #334155;
}

.field-help {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 0.73rem;

    line-height: 1.4;
}

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


/* =========================================================
   SEARCH
========================================================= */

.search-form {
    display: flex;

    gap: 8px;

    align-items: center;
}

.search-form input {
    flex: 1;
}


/* =========================================================
   ALERTAS
========================================================= */

.alert {
    padding: 12px 14px;

    border-radius: 7px;

    border: 1px solid transparent;

    font-size: 0.83rem;
}

.alert-error {
    background: #fef2f2;

    color: #b91c1c;

    border-color: #fecaca;
}

.alert-success {
    background: #f0fdf4;

    color: #15803d;

    border-color: #bbf7d0;
}

.hint {
    color: var(--muted);

    font-size: 0.76rem;

    margin-top: 5px;
}


/* =========================================================
   VENTAS / COMPRAS
========================================================= */

.venta-item-row {
    display: grid;

    grid-template-columns:
        2fr 1fr auto;

    gap: 10px;

    align-items: end;

    margin-bottom: 10px;
}


/* =========================================================
   PAGINACIÓN
========================================================= */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 6px;

    margin-top: 18px;

    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    min-width: 34px;

    padding: 7px 10px;

    border-radius: 6px;

    font-size: 0.8rem;

    text-align: center;

    text-decoration: none;

    color: var(--primary);

    border:
        1px solid var(--border);
}

.pagination a:hover {
    background: #f1f5f9;
}

.pagination .pagina-activa {
    background: var(--accent);

    color: #fff;

    border-color: var(--accent);

    font-weight: 650;
}

.pagination .pagina-disabled {
    color: #cbd5e1;

    cursor: not-allowed;
}

.pagination-info {
    margin-top: 7px;

    text-align: center;

    color: var(--muted);

    font-size: 0.75rem;
}


/* =========================================================
   LOGIN
========================================================= */

.login-box {
    width: 100%;

    max-width: 420px;

    margin: 0 auto;

    background: #fff;

    padding: 28px 32px 24px;

    border:
        1px solid var(--border);

    border-radius: 22px;

    box-shadow:
        0 24px 60px -24px rgba(15, 42, 100, 0.28),
        0 4px 14px rgba(15, 23, 42, 0.05);
}

.login-logo {
    display: flex;
    justify-content: center;

    margin-bottom: 14px;
}

.login-logo img {
    width: 92px;
    height: 92px;

    object-fit: cover;

    border-radius: 22px;

    box-shadow:
        0 14px 30px -10px rgba(3, 27, 58, 0.55);
}

.login-box h1 {
    margin: 0 0 4px;

    text-align: center;

    color: var(--text-dark);

    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.login-subtitle {
    margin: 0 0 18px;

    text-align: center;

    color: var(--muted);

    font-size: 0.9rem;
}

.login-box .hint {
    margin: 10px 0 0;

    text-align: center;

    color: var(--muted);

    font-size: 0.8rem;
    line-height: 1.5;
}

.login-box label {
    display: block;

    margin: 0 0 6px;

    color: var(--text);

    font-size: 0.8rem;
    font-weight: 650;
}

.login-box input {
    min-height: 44px;

    margin-bottom: 12px;

    border-radius: 11px;

    font-size: 0.95rem;
}

.login-box .password-wrapper {
    margin-bottom: 12px;
}

.login-box .password-wrapper input {
    margin-bottom: 0;
}

.login-box button[type="submit"] {
    width: 100%;

    min-height: 46px;

    margin-top: 4px;

    border-radius: 11px;

    font-size: 1rem;
    font-weight: 700;

    box-shadow:
        0 10px 22px -10px rgba(37, 99, 235, 0.7);
}

/* Íconos dentro de los campos (solo la pantalla de iniciar sesión) */

.login-box.con-iconos input[type="email"],
.login-box.con-iconos input[type="password"],
.login-box.con-iconos .password-wrapper input[type="text"] {
    padding-left: 46px;

    background-repeat: no-repeat;
    background-position: 15px center;
    background-size: 20px;
}

.login-box.con-iconos input[type="email"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='m3 7 9 6 9-6'/%3E%3C/svg%3E");
}

.login-box.con-iconos .password-wrapper input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E");
}

@media (max-width: 520px) {

    .login-content {
        align-items: flex-start;

        padding: 20px 14px;
    }

    .login-box {
        padding: 26px 20px 22px;

        border-radius: 20px;
    }

    .login-logo img {
        width: 88px;
        height: 88px;
    }

}

/* Pantallas bajitas (laptops con la barra del navegador): se compacta más
   para que el login entre completo sin usar la rueda del mouse. */

@media (max-height: 640px) {

    .login-content {
        padding: 10px 20px;
    }

    .login-box {
        padding: 20px 28px 18px;
    }

    .login-logo {
        margin-bottom: 8px;
    }

    .login-logo img {
        width: 72px;
        height: 72px;
    }

    .login-subtitle {
        margin-bottom: 12px;
    }

    .login-box label {
        margin-bottom: 4px;
    }

    .login-box input {
        margin-bottom: 8px;
    }

    .login-box .password-wrapper {
        margin-bottom: 8px;
    }

    .login-box .hint {
        margin-top: 8px;
        font-size: 0.76rem;
    }

}


/* =========================================================
   PASSWORD
========================================================= */

.password-wrapper {
    position: relative;

    margin-bottom: 10px;
}

.password-wrapper input {
    padding-right: 42px;

    margin-bottom: 0;
}

.toggle-password {
    position: absolute;

    right: 5px;
    top: 50%;

    transform:
        translateY(-50%);

    background: none;

    border: none;

    color: #64748b;

    padding: 6px 8px;
}


/* =========================================================
   RESPONSIVE
========================================================= */

/* Botón hamburguesa y fondo del cajón: ocultos en PC */

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

.menu-toggle,
.sidebar-backdrop {
    display: none;
}

.menu-toggle {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;

    padding: 0;

    background: #fff;

    border: 1px solid var(--border-dark);
    border-radius: 10px;

    cursor: pointer;

    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.menu-toggle span {
    display: block;

    width: 20px;
    height: 2px;

    background: var(--text-dark);
    border-radius: 2px;
}


/* Tablet y celular: el menú lateral pasa a ser un cajón */

@media (max-width: 900px) {

    .menu-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1000;

        width: min(84vw, 300px);
        min-width: 0;

        padding-left: 12px;
        padding-right: 12px;

        transform: translateX(-102%);
        transition: transform 0.25s ease;

        box-shadow: none;

        -webkit-overflow-scrolling: touch;
    }

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

        box-shadow: 0 0 40px rgba(2, 6, 23, 0.45);
    }

    .sidebar-backdrop {
        display: block;

        position: fixed;
        inset: 0;
        z-index: 999;

        background: rgba(15, 23, 42, 0.55);

        opacity: 0;
        pointer-events: none;

        transition: opacity 0.25s ease;
    }

    body.menu-abierto .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.menu-abierto {
        overflow: hidden;
    }

    .navbar {
        position: sticky;
        top: 0;
        z-index: 50;

        padding: 10px 16px;
    }

}


@media (max-width: 760px) {

    .sidebar-brand {
        min-height: 60px;
    }

    .content-area {
        padding: 14px;
    }

    /* Barras de búsqueda/filtros: en dos columnas, buscador a todo el ancho */

    form[method="get"][style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
    }

    form[method="get"][style*="grid-template-columns"] > input[type="text"],
    form[method="get"][style*="grid-template-columns"] > input[type="search"],
    form[method="get"][style*="grid-template-columns"] > select,
    form[method="get"][style*="grid-template-columns"] > a[href*="crear"] {
        grid-column: 1 / -1;
    }

    form[method="get"][style*="grid-template-columns"] > a,
    form[method="get"][style*="grid-template-columns"] > button {
        text-align: center;
    }

    /* Tablas → tarjetas: cada fila es una tarjeta con "Etiqueta: valor".
       Las etiquetas las pone el script del pie de página (data-label). */

    table:not(.sin-tarjetas),
    table:not(.sin-tarjetas) tbody,
    table:not(.sin-tarjetas) tr,
    table:not(.sin-tarjetas) td {
        display: block;
    }

    table:not(.sin-tarjetas) {
        min-width: 0;
    }

    table:not(.sin-tarjetas) thead {
        display: none;
    }

    table:not(.sin-tarjetas) tbody tr {
        margin-bottom: 12px;

        background: #fff;

        border: 1px solid var(--border);
        border-radius: 12px;

        overflow: hidden;
    }

    table:not(.sin-tarjetas) td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 14px;

        padding: 10px 14px;

        text-align: right;

        border-bottom: 1px solid var(--border);
    }

    table:not(.sin-tarjetas) td:last-child {
        border-bottom: none;
    }

    table:not(.sin-tarjetas) td {
        padding-top: 8px;
        padding-bottom: 8px;

        font-size: 0.84rem;
    }

    /* Celda de acciones: botones grandes y fáciles de tocar */

    table:not(.sin-tarjetas) td[data-label="Acciones"] {
        justify-content: stretch;
        gap: 10px;

        padding: 10px 12px;

        background: #f8fafc;
    }

    table:not(.sin-tarjetas) td[data-label="Acciones"]::before {
        display: none;
    }

    table:not(.sin-tarjetas) td[data-label="Acciones"] > a,
    table:not(.sin-tarjetas) td[data-label="Acciones"] > form,
    table:not(.sin-tarjetas) td[data-label="Acciones"] > button {
        flex: 1 1 0;
    }

    table:not(.sin-tarjetas) td[data-label="Acciones"] a,
    table:not(.sin-tarjetas) td[data-label="Acciones"] button {
        display: block;

        width: 100%;

        padding: 10px 8px;

        text-align: center;
        text-decoration: none;
        font-weight: 650;

        border-radius: 9px;
    }

    table:not(.sin-tarjetas) td[data-label="Acciones"] a {
        background: #fff;

        border: 1px solid var(--border-dark);
    }

    table:not(.sin-tarjetas) td[data-label="Acciones"] form {
        margin: 0;
    }

    table:not(.sin-tarjetas) td[data-label="Acciones"] form button {
        background: #fff !important;

        color: var(--danger) !important;

        border: 1px solid #fecaca !important;

        text-decoration: none !important;
    }

    table:not(.sin-tarjetas) td[data-label]::before {
        content: attr(data-label);

        flex: 0 0 auto;

        max-width: 42%;

        color: #64748b;

        font-size: 0.72rem;
        font-weight: 650;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    table:not(.sin-tarjetas) td[colspan] {
        display: block;

        text-align: center;
    }

    /* Botón principal de un formulario (Guardar, Generar respaldo...): ancho completo */

    .content-area form:not([method="get"]) > button[type="submit"],
    .content-area form:not([method="get"]) > .btn-success {
        width: 100%;
    }

    /* Etiqueta de conteo (ej. "164 registros") con aire alrededor */

    .audit-summary-badge {
        display: inline-block;

        margin: 10px 0 16px;
    }

    /* Opciones de los buscadores de cliente/producto/proveedor: fáciles de tocar */

    .buscable-lista .buscable-item {
        min-height: 46px;

        padding: 12px 14px;

        display: flex;
        align-items: center;
    }

    /* Campos y botones cómodos para el dedo (16px evita el zoom de iPhone) */

    input,
    select,
    textarea {
        font-size: 16px;
    }

    button,
    .btn,
    input[type="submit"] {
        min-height: 44px;
    }

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

    .entity-form-header {
        flex-direction: column;
    }

    .entity-form-actions {
        flex-direction: column-reverse;
    }

    .entity-form-actions a,
    .entity-form-actions button {
        width: 100%;
    }

}


@media (max-width: 520px) {

    .navbar {
        gap: 10px;
    }

    .page-title {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

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

    .user-details {
        display: none;
    }

    .page-subtitle {
        display: none;
    }

}