:root {
    --brand-blue: rgb(55, 95, 145);
    --brand-orange: rgb(225, 126, 0);
    --panel-bg: #f0f2f5;
    --panel-border: #dde2e8;
}

html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin: 0;
    background: #fafbfc;
    color: #1f2933;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--brand-blue);
}

.app-header {
    background: #fff;
    border-bottom: 3px solid var(--brand-orange);
    box-shadow: 0 2px 8px rgba(55, 95, 145, 0.08);
    padding: 0.75rem 1rem;
}

.app-header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    max-width: none;
    margin: 0;
    padding: 0 1rem;
}

.app-header-logo img,
.brand-logo {
    height: 48px;
    width: auto;
    background: transparent;
}

.login-card .brand-logo {
    height: 72px;
    margin-bottom: 1rem;
}

.app-header-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--brand-blue);
    text-align: center;
}

.app-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.btn-header-icon,
.btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    background: var(--panel-bg);
    color: var(--brand-blue);
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}

.btn-header-icon:hover,
.btn-logout:hover {
    background: var(--brand-blue);
    color: #fff;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    background: var(--panel-bg);
    color: var(--brand-blue);
    padding: 0;
}

.btn-menu-toggle:hover {
    background: var(--brand-blue);
    color: #fff;
}

.app-shell {
    display: flex;
    min-height: calc(100vh - 70px);
}

.app-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--panel-bg);
    border-right: 1px solid var(--panel-border);
    padding: 1rem 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.75rem;
}

.sidebar-link {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--brand-blue);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.sidebar-link:hover {
    background: rgba(55, 95, 145, 0.1);
    color: var(--brand-blue);
}

.sidebar-link.active {
    background: var(--brand-blue);
    color: #fff;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: 70px;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1040;
}

.sidebar-backdrop.show {
    display: block;
}

.app-content {
    flex: 1;
    min-width: 0;
    padding: 1.25rem;
}

.text-brand-blue {
    color: var(--brand-blue);
}

.text-brand-orange {
    color: var(--brand-orange);
}

.app-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.panel-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-brand {
    background: var(--brand-blue);
    border-color: var(--brand-blue);
    color: #fff;
}

.btn-brand:hover, .btn-brand:focus {
    background: #2d4f78;
    border-color: #2d4f78;
    color: #fff;
}

.btn-accent {
    background: var(--brand-orange);
    border-color: var(--brand-orange);
    color: #fff;
}

.btn-accent:hover, .btn-accent:focus {
    background: #c46f00;
    border-color: #c46f00;
    color: #fff;
}

.table-facturas {
    margin-bottom: 0;
    background: #fff;
}

.table-facturas thead th {
    background: var(--brand-blue);
    color: #fff;
    border: none;
    white-space: nowrap;
}

.table-facturas tbody td {
    vertical-align: middle;
}

.table-responsive-panel {
    overflow-x: auto;
    border-radius: 0.5rem;
    background: #fff;
}

.badge-estado {
    background: rgba(55, 95, 145, 0.12);
    color: var(--brand-blue);
    font-weight: 600;
}

.badge-tipo {
    background: rgba(225, 126, 0, 0.15);
    color: #9a5200;
    font-weight: 600;
}

.badge-clickable {
    cursor: pointer;
}

.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, rgba(55, 95, 145, 0.08) 0%, rgba(225, 126, 0, 0.1) 100%);
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    box-shadow: 0 0.75rem 2rem rgba(55, 95, 145, 0.12);
}

.login-card .brand-title {
    color: var(--brand-blue);
    font-weight: 700;
}

.login-card .btn-primary {
    background: var(--brand-blue);
    border-color: var(--brand-blue);
}

.login-card .btn-primary:hover {
    background: #2d4f78;
    border-color: #2d4f78;
}

.login-card a {
    color: var(--brand-orange);
}

.login-card .validation-summary-errors ul {
    margin-bottom: 0;
    padding-left: 1.1rem;
    word-break: break-word;
}

.alert-app {
    border-radius: 0.5rem;
}

.modal-content.panel {
    border: 1px solid var(--panel-border);
    box-shadow: 0 1rem 2rem rgba(55, 95, 145, 0.15);
}

.factura-check,
.row-check {
    cursor: pointer;
    width: 1.1rem;
    height: 1.1rem;
}

@media (max-width: 991px) {
    .btn-menu-toggle {
        display: inline-flex;
    }

    .app-sidebar {
        position: fixed;
        top: 70px;
        left: 0;
        bottom: 0;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }
}

.factura-viewer-frame {
    min-height: 60vh;
    background: #fff;
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 0.5rem;
}

.factura-viewer-iframe {
    width: 100%;
    min-height: 60vh;
    border: 0;
    background: #fff;
}

.factura-viewer-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

@media (max-width: 767px) {
    .app-header-inner {
        grid-template-columns: auto 1fr auto;
    }

    .app-header-title {
        font-size: 1.1rem;
    }

    .panel-toolbar .btn {
        flex: 1 1 100%;
    }

    .modal-factura-viewer .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .factura-viewer-frame,
    .factura-viewer-iframe {
        min-height: 50vh;
    }

    #tablaFacturasRecibidas th,
    #tablaFacturasRecibidas td {
        white-space: nowrap;
    }
}
