:root {
    --primary: #6D3DF5;
    --primary-dark: #4A24C7;
    --dark: #151522;
    --gray: #6B7280;
    --light: #F5F7FB;
    --white: #FFFFFF;
    --border: #E5E7EB;
    --success: #22C55E;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--light);
    color: var(--dark);
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #6D3DF5, #151522);
}

.auth-card {
    width: 380px;
    background: var(--white);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.25);
}

.auth-card.wide {
    width: 460px;
}

.auth-card h1 {
    margin: 0 0 8px;
}

.auth-card p {
    color: var(--gray);
}

form {
    display: grid;
    gap: 14px;
}

label {
    font-weight: 600;
    font-size: 14px;
}

input,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px;
    outline: none;
}

button {
    border: none;
    border-radius: 14px;
    padding: 13px 18px;
    background: var(--primary);
    color: white;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    background: var(--primary-dark);
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--dark);
    color: white;
    padding: 12px 10px 10px;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.brand-only-logo {
    justify-content: center;
    padding: 0 0 4px;
    margin-bottom: 8px;
}

.brand-logo-full {
    width: 100%;
    max-width: 130px;
    height: auto;
    object-fit: contain;
    display: block;
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    padding: 4px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--primary);
}

.user-chip {
    text-decoration: none;
    color: inherit;
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    text-align: center;
}

.auth-brand img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.auth-logo-large {
    width: 120px !important;
    height: 120px !important;
    object-fit: contain;
}

.auth-brand h1 {
    margin: 0;
}

.flash-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

.puntos-disponibles {
    margin-top: 6px;
    color: var(--primary);
}

.canje-form {
    margin-top: 12px;
    display: grid;
    gap: 8px;
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: #16a34a;
}

.estado-badge.autorizado,
.estado-badge.firmado,
.estado-badge.enviado {
    background: #dcfce7;
    color: #166534;
}

.estado-badge.devuelto,
.estado-badge.error {
    background: #fee2e2;
    color: #991b1b;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.sidebar a {
    color: #D1D5DB;
    text-decoration: none;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.25;
}

.sidebar a:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.sidebar .logout {
    color: #FCA5A5;
}

.sidebar .logout-fixed {
    flex-shrink: 0;
    display: block;
    margin-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
}

.mobile-overlay {
    display: none;
}

.main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-btn {
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 14px;
    font-size: 22px;
    background: var(--primary);
    color: white;
}

.topbar h1 {
    margin: 0;
}

.topbar p {
    color: var(--gray);
    margin: 6px 0 0;
}

.user-chip {
    background: white;
    padding: 12px 18px;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
}

.stats-grid,
.module-grid,
.reward-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.stat-card,
.panel,
.reward-card,
.module-card {
    background: white;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.stat-card strong {
    font-size: 32px;
    color: var(--primary);
}

.stat-card p {
    color: var(--gray);
}

.panel {
    margin-top: 22px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 18px;
}

th,
td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    color: var(--gray);
    font-size: 14px;
}

.badge {
    background: #EEE7FF;
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 700;
}

.card-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

.loyalty-card {
    width: 520px;
    min-height: 290px;
    border-radius: 32px;
    padding: 30px;
    color: white;
    background: linear-gradient(135deg, #151522, #6D3DF5);
    box-shadow: 0 30px 80px rgba(109, 61, 245, 0.35);
}

.loyalty-card h2 {
    font-size: 30px;
    margin-bottom: 4px;
}

.qr-box {
    width: 90px;
    height: 90px;
    background: white;
    color: var(--dark);
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-weight: bold;
    margin: 22px 0;
}

.loyalty-footer {
    display: flex;
    justify-content: space-between;
}

.loyalty-footer strong {
    display: block;
    font-size: 22px;
}

.form-panel {
    max-width: 560px;
}

.reward-card span {
    display: inline-block;
    background: #DCFCE7;
    color: #15803D;
    padding: 7px 12px;
    border-radius: 999px;
    margin-bottom: 14px;
}

.module-card {
    font-weight: 700;
    min-height: 110px;
    display: flex;
    align-items: center;
    border-left: 5px solid var(--primary);
}

@media (max-width: 1100px) {
    .stats-grid,
    .module-grid,
    .reward-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 20px 0 60px rgba(0,0,0,0.25);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .mobile-overlay.active {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 900;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 18px;
    }

    .menu-btn {
        display: block;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-left {
        align-items: flex-start;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .topbar p {
        font-size: 14px;
    }

    .user-chip {
        display: none;
    }

    .stats-grid,
    .module-grid,
    .reward-grid {
        grid-template-columns: 1fr;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .auth-card,
    .auth-card.wide {
        width: 92%;
    }

    .loyalty-card {
        width: 100%;
    }

    .loyalty-footer {
        gap: 16px;
        flex-wrap: wrap;
    }
}


.config-card {
    cursor: pointer;
    background: linear-gradient(135deg, #151522, #6D3DF5);
    color: white;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.config-card small {
    font-size: 13px;
    font-weight: 400;
    opacity: 0.85;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 25, 0.55);
    backdrop-filter: blur(6px);
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: grid;
    place-items: center;
}

.modal-box {
    width: 100%;
    max-width: 850px;
    background: white;
    border-radius: 28px;
    padding: 28px;
    box-shadow: 0 30px 90px rgba(0,0,0,0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.modal-header h2 {
    margin: 0;
}

.modal-header p {
    margin: 6px 0 0;
    color: var(--gray);
}

.modal-close {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    padding: 0;
    font-size: 26px;
    background: #F3F4F6;
    color: var(--dark);
}

.config-form {
    display: grid;
    gap: 22px;
}

.form-section {
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 20px;
}

.form-section h3 {
    margin-top: 0;
}

.radio-grid,
.sequence-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.radio-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    cursor: pointer;
}

.radio-card span {
    display: block;
    font-weight: 800;
    margin-bottom: 4px;
}

.radio-card small {
    color: var(--gray);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-light {
    background: #F3F4F6;
    color: var(--dark);
}

a.btn-light,
.action-row a.btn-light,
.action-row button.btn-light {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 14px;
    font-weight: 700;
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    background: #F3F4F6;
    color: var(--dark);
    line-height: 1.2;
}

a.btn-light:hover,
.action-row a.btn-light:hover,
.action-row button.btn-light:hover {
    background: #E5E7EB;
}

.auth-logo-large {
    width: 120px !important;
    height: 120px !important;
    object-fit: contain;
}

.product-search-wrap {
    position: relative;
}

.product-search-results {
    margin-top: 8px;
    display: grid;
    gap: 8px;
    max-height: 240px;
    overflow: auto;
}

.product-result-item {
    text-align: left;
    background: #F8F9FC;
    color: var(--dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}

.product-result-item strong {
    display: block;
}

.product-result-item small {
    color: var(--gray);
}

@media (max-width: 700px) {
    .modal-box {
        padding: 20px;
        border-radius: 22px;
    }

    .radio-grid,
    .sequence-grid {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        flex-direction: column;
    }
}


.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 22px 0;
}

textarea {
    width: 100%;
    min-height: 82px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px;
    outline: none;
    resize: vertical;
    font-family: Arial, Helvetica, sans-serif;
}

.large-modal {
    max-width: 980px;
}

#tablaInventario {
    min-width: 1500px;
}

#tablaInventario th,
#tablaInventario td {
    white-space: nowrap;
}

@media (max-width: 800px) {
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .large-modal {
        max-width: 100%;
    }
}

.module-link {
    text-decoration: none;
    color: var(--dark);
}

.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.factura-panel {
    margin-top: 0;
}

.factura-filtros {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 22px 0;
}

.filter-actions {
    display: flex;
    align-items: end;
    gap: 10px;
}

.estado-badge {
    display: inline-block;
    min-width: 130px;
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 13px;
}

.estado-badge.pendiente {
    background: #FEF3C7;
    color: #92400E;
}

.estado-badge.anulado {
    background: #FEE2E2;
    color: #B91C1C;
}

.estado-badge.pagado,
.estado-badge.autorizado {
    background: #DCFCE7;
    color: #166534;
}

.alert-box {
    margin: 0 0 18px;
    padding: 14px 18px;
    border-radius: 10px;
    border: 1px solid #CBD5E1;
    background: #F8FAFC;
}

.alert-box.alert-success {
    border-color: #86EFAC;
    background: #F0FDF4;
}

.alert-box.alert-warning {
    border-color: #FCD34D;
    background: #FFFBEB;
}

.alert-box.alert-info {
    border-color: #93C5FD;
    background: #EFF6FF;
}

.sri-status-list {
    margin: 8px 0 0;
    padding-left: 18px;
}

.sri-status-list li {
    margin-bottom: 4px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    font-weight: 600;
}

.checkbox-row input {
    width: auto;
}

.btn-table {
    background: white;
    color: #1E3A5F;
    border: 1px solid #93A8C7;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 3px;
    font-size: 13px;
}

.factura-modal {
    max-width: 1180px;
}

.product-search-row {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 12px;
    margin-bottom: 14px;
}

.mini-table {
    min-width: 1050px;
}

.mini-table th {
    background: #1450A3;
    color: white;
}

.factura-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.payment-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.totales-list {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.totales-list div {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 6px;
}

.btn-success {
    background: #15803D;
}

@media (max-width: 800px) {
    .product-search-row,
    .factura-bottom-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .rewards-grid {
        grid-template-columns: 1fr;
    }
}


.rewards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.reward-card {
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.reward-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.reward-image-placeholder {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #EEE7FF, #F5F7FB);
    color: var(--primary);
    font-size: 42px;
}

.reward-body {
    padding: 20px;
}

.reward-body h3 {
    margin: 8px 0;
}

.reward-body p {
    color: var(--gray);
    margin: 0 0 10px;
}

.sequence-grid .full-width {
    grid-column: 1 / -1;
}

.actions-cell {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-danger-table {
    background: #fee2e2 !important;
    color: #991b1b !important;
}

.client-hero {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 20px;
    margin-bottom: 20px;
    padding: 28px;
    border-radius: 28px;
    color: white;
    background:
        radial-gradient(circle at top right, rgba(255,255,255,0.18), transparent 40%),
        linear-gradient(135deg, #1b1535 0%, #4a24c7 55%, #6d3df5 100%);
    box-shadow: 0 20px 50px rgba(74, 36, 199, 0.25);
}

.client-hero .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    opacity: 0.8;
    margin: 0 0 8px;
}

.client-hero h2 {
    margin: 0 0 8px;
    font-size: 32px;
}

.client-hero p {
    margin: 0;
    opacity: 0.9;
}

.client-hero-points {
    display: grid;
    align-content: center;
    justify-items: end;
    text-align: right;
}

.client-hero-points span,
.client-hero-points small {
    opacity: 0.85;
}

.client-hero-points strong {
    font-size: 48px;
    line-height: 1.1;
}

.client-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.client-stats article {
    background: white;
    border-radius: 20px;
    padding: 18px 20px;
    box-shadow: 0 10px 30px rgba(21, 21, 34, 0.05);
}

.client-stats span {
    color: var(--gray);
    font-size: 13px;
}

.client-stats strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
}

.client-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.client-card-panel {
    background: white;
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 10px 30px rgba(21, 21, 34, 0.05);
}

.client-card-panel .panel-header {
    margin-bottom: 16px;
}

.client-card-panel h3 {
    margin: 0 0 4px;
}

.mini-card {
    min-height: 180px;
}

.client-rewards {
    display: grid;
    gap: 12px;
}

.client-reward-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: 16px;
    background: var(--light);
}

.client-reward-row small {
    display: block;
    color: var(--gray);
}

.client-reward-row span {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.client-purchases .panel-header {
    margin-bottom: 16px;
}

.perfil-form {
    margin-top: 10px;
}

@media (max-width: 980px) {
    .client-hero,
    .client-grid,
    .client-stats {
        grid-template-columns: 1fr;
    }

    .client-hero-points {
        justify-items: start;
        text-align: left;
    }
}

a,
a:link,
a:visited,
a:hover,
a:active,
.auth-link,
.sidebar a,
.module-link {
    text-decoration: none !important;
}

.auth-link {
    display: inline-flex;
    margin-top: 16px;
    color: var(--primary);
    font-weight: 700;
}

.auth-card-modern {
    border: 1px solid rgba(255,255,255,0.12);
}

.account-type-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.account-type-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    background: #fafafa;
}

.account-type-option input {
    width: auto;
    margin-top: 4px;
}

.account-type-option strong {
    display: block;
}

.account-type-option small {
    color: var(--gray);
}

.account-type-option:has(input:checked) {
    border-color: var(--primary);
    background: #f3eeff;
}

.demo-creds {
    margin-top: 18px;
    display: grid;
    gap: 4px;
    color: var(--gray);
    font-size: 12px;
}

.input-with-action {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    padding: 0;
    font-size: 18px;
}

.scan-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.hint-text {
    color: var(--gray);
    font-size: 13px;
}

.barcode-box {
    background: rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 12px;
    text-align: center;
}

.barcode-box small {
    display: block;
    margin-top: 6px;
    letter-spacing: 0.08em;
}

.qr-box {
    display: none;
}

@media (max-width: 720px) {
    .account-type-picker,
    .scan-row,
    .input-with-action {
        grid-template-columns: 1fr;
    }

    .auth-card,
    .auth-card.wide {
        width: calc(100% - 28px);
        margin: 14px;
    }

    .main-content {
        padding: 16px;
    }
}
