:root {
    --color-bg: #f6f7fb;
    --color-surface: #ffffff;
    --color-surface-soft: #f3f5f9;
    --color-border: #edf0f6;
    --color-text: #303548;
    --color-muted: #8b95a7;
    --color-primary: #04a9f5;
    --color-primary-2: #038fce;
    --color-accent: #ffb64d;
    --color-success: #2ed8b6;
    --color-danger: #ff5370;
    --color-sidebar: #404e67;
    --color-sidebar-2: #404e67;
    --shadow-lg: 0 1px 20px rgba(69, 90, 100, .12);
    --shadow-md: 0 1px 20px rgba(69, 90, 100, .08);
    --radius-lg: 12px;
    --radius-md: 5px;
    --radius-sm: 5px;
}

body.app-shell {
    min-height: 100vh;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: "Open Sans", sans-serif;
    font-size: 14px;
}

.app-frame {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 264px;
    flex: 0 0 264px;
    background: #404e67 !important;
    color: #fff;
    padding: .75rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    box-shadow: 0 0 11px rgba(0, 0, 0, .13);
}

.sidebar-brand {
    padding: .7rem 1.2rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: .85rem;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: .9rem;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--color-primary);
    box-shadow: 0 8px 18px rgba(4, 169, 245, .25);
}

.brand-copy strong,
.brand-copy small {
    display: block;
}

.brand-copy small {
    color: rgba(255, 255, 255, .54);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding: 0 .65rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .68rem .85rem;
    border-radius: 3px;
    color: rgba(255, 255, 255, .72);
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
    font-size: .84rem;
    font-weight: 600;
}

.sidebar-link i {
    font-size: 1.05rem;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255, 255, 255, .14);
    color: #fff;
}

.sidebar-panel {
    margin: 1rem .8rem 0;
    padding: .85rem;
    border-radius: 5px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .72rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: rgba(255, 182, 77, .12);
    color: #ffcf84;
    margin-bottom: .5rem;
}

.sidebar-note {
    color: rgba(255, 255, 255, .72);
    font-size: .92rem;
    line-height: 1.35;
}

.app-content {
    flex: 1 1 auto;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    padding: .78rem 1.5rem;
    background: var(--color-surface);
    border: 0;
    border-radius: 0;
    box-shadow: var(--shadow-md);
    min-height: 58px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.topbar-toggle {
    color: var(--color-primary);
    font-size: 1.35rem;
    text-decoration: none;
}

.topbar-copy {
    min-width: 0;
}

.topbar-eyebrow {
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
    font-size: .64rem;
    font-weight: 700;
}

.topbar-title {
    margin: 0;
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    font-weight: 600;
    color: var(--color-text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar-action {
    border-radius: 6px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .75rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 700;
    background: rgba(4, 169, 245, .10);
    color: var(--color-primary);
}

.status-pill--danger {
    background: rgba(255, 83, 112, .12);
    color: var(--color-danger);
}

.app-main {
    padding: 1.3rem 1.5rem 1.5rem;
}

.app-main--public {
    padding-top: 1.5rem;
}

.flash-stack {
    display: grid;
    gap: .65rem;
    margin-bottom: 1rem;
}

.flash-card {
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.card,
.table,
.modal-content,
.offcanvas {
    border-color: var(--color-border);
}

.card {
    border-radius: 5px;
    box-shadow: var(--shadow-md);
    background: var(--color-surface);
    overflow: hidden;
    border: 0;
}

.card-header {
    font-weight: 600;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: .9rem;
    border-bottom-color: #f1f1f1;
}

.card-body {
    background: var(--color-surface);
}

.card .text-muted {
    color: var(--color-muted) !important;
}

.kpi-card,
.metric-card {
    position: relative;
    overflow: hidden;
}

.kpi-card {
    border-radius: 5px;
    box-shadow: var(--shadow-md);
    color: #fff;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: auto -20% -55% auto;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 138, 52, .18), transparent 65%);
    pointer-events: none;
}

.brand-copy strong {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: .02em;
}

.brand-copy small {
    display: block;
    color: #bfc8e2;
    font-size: .92rem;
    font-weight: 600;
    margin-top: -.2rem;
}

.kpi-card__main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.15rem 1.25rem .95rem;
}

.kpi-card__value {
    font-size: clamp(1.85rem, 2vw, 2rem);
    line-height: 1;
    font-weight: 700;
    letter-spacing: -.03em;
    margin-bottom: .25rem;
}

.kpi-card__title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .96;
}

.kpi-card__footer {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .62rem 1.25rem;
    font-size: .73rem;
    text-transform: lowercase;
    border-top: 1px solid rgba(255, 255, 255, .45);
    background: rgba(0, 0, 0, .05);
}

.kpi-spark {
    display: inline-flex;
    align-items: end;
    gap: 5px;
    min-width: 70px;
    justify-content: end;
}

.kpi-spark span {
    width: 9px;
    border-radius: 0;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .2);
}

.kpi-spark span:nth-child(1) {
    height: 12px;
}

.kpi-spark span:nth-child(2) {
    height: 28px;
}

.kpi-spark span:nth-child(3) {
    height: 36px;
}

.kpi-spark span:nth-child(4) {
    height: 20px;
}

.kpi-spark span:nth-child(5) {
    height: 10px;
}

.kpi-card__icon {
    min-width: 70px;
    text-align: end;
}

.kpi-card__icon span {
    display: inline-block;
    font-size: 3rem;
    line-height: 1;
    font-weight: 800;
    color: rgba(255, 255, 255, .92);
}

.kpi-card__icon i {
    font-size: 2.2rem;
    color: rgba(255, 255, 255, .92);
    display: inline-block;
}

.kpi-card--salmon {
    background: linear-gradient(to right, rgb(254, 147, 101), rgb(254, 183, 152));
}

.kpi-card--salmon .kpi-card__footer {
    background: rgba(236, 137, 104, .34);
}

.kpi-card--green {
    background: linear-gradient(to right, rgb(10, 194, 130), rgb(13, 243, 163));
}

.kpi-card--green .kpi-card__footer {
    background: rgba(18, 172, 112, .30);
}

.kpi-card--rose {
    background: linear-gradient(to right, rgb(254, 93, 112), rgb(254, 144, 157));
}

.kpi-card--rose .kpi-card__footer {
    background: rgba(223, 80, 109, .28);
}

.kpi-card--cyan {
    background: linear-gradient(to right, rgb(1, 169, 172), rgb(1, 219, 223));
}

.kpi-card--cyan .kpi-card__footer {
    background: rgba(10, 137, 149, .30);
}

.metric-label,
.kpi-label {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--color-muted);
    font-weight: 700;
}

.metric-value,
.kpi-value {
    font-size: clamp(1.9rem, 3vw, 2.8rem);
    font-weight: 800;
    line-height: 1;
}

.metric-subtext {
    font-size: .88rem;
    color: var(--color-muted);
}

.table-responsive {
    border-radius: 5px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    background: var(--color-surface);
    border: 0;
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
}

.table thead.table-light,
.table thead {
    background: #fafbfd;
    color: #616c7f;
}

.table thead th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
}

.table td,
.table th {
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: #fbfcfe;
}

.table-striped>tbody>tr:nth-of-type(odd)>* {
    --bs-table-bg-type: #fcfdff;
}

.btn {
    border-radius: 2px;
    font-weight: 600;
}

.btn-primary {
    --bs-btn-bg: var(--color-primary-2);
    --bs-btn-border-color: var(--color-primary-2);
    --bs-btn-hover-bg: var(--color-primary);
    --bs-btn-hover-border-color: var(--color-primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--color-primary-2);
    --bs-btn-border-color: #b8e8fb;
    --bs-btn-hover-bg: #ecfafe;
    --bs-btn-hover-border-color: #b8e8fb;
    --bs-btn-hover-color: var(--color-primary-2);
}

.btn-outline-secondary {
    border-color: #e5e9f2;
    color: #5e6a7d;
}

.btn-outline-secondary:hover {
    background: #f5f7fb;
    color: #303548;
}

.btn-success {
    --bs-btn-bg: var(--color-success);
    --bs-btn-border-color: var(--color-success);
    --bs-btn-hover-bg: #178557;
    --bs-btn-hover-border-color: #178557;
}

.btn-danger {
    --bs-btn-bg: var(--color-danger);
    --bs-btn-border-color: var(--color-danger);
    --bs-btn-hover-bg: #c63e3e;
    --bs-btn-hover-border-color: #c63e3e;
}

.form-control,
.form-select {
    border-radius: 2px;
    border-color: #dfe3eb;
    box-shadow: none;
    min-height: 38px;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(4, 169, 245, .55);
    box-shadow: 0 0 0 .2rem rgba(4, 169, 245, .10);
}

.badge {
    border-radius: 999px;
    padding: .35rem .6rem;
    font-weight: 700;
}

.badge.bg-success {
    background: rgba(32, 164, 106, .14) !important;
    color: #15804f !important;
}

.badge.bg-secondary {
    background: rgba(107, 114, 128, .12) !important;
    color: #4b5563 !important;
}

.badge.bg-warning {
    background: rgba(255, 138, 52, .16) !important;
    color: #a85a17 !important;
}

.modal-content {
    border-radius: 5px;
    border: 0;
    box-shadow: var(--shadow-lg);
    background: #fff;
}

.modal-header {
    border-bottom: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
}

.modal-header .btn-close {
    filter: none;
    opacity: .9;
}

.modal-body {
    color: var(--color-text);
}

.app-offcanvas {
    background: var(--color-sidebar);
    color: #fff;
}

.offcanvas .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-nav--mobile .sidebar-link {
    border-radius: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-nav--mobile .sidebar-link.active,
.sidebar-nav--mobile .sidebar-link:hover {
    transform: none;
}

#appConfirmModal .modal-dialog {
    max-width: 520px;
}

#appConfirmModal .modal-content {
    background: #fff;
}

#appConfirmModal .modal-header {
    background: #fff;
    color: var(--color-text);
}

#appConfirmModal .modal-footer {
    border-top: 1px solid var(--color-border);
}

#appConfirmModal .btn-outline-secondary {
    border-color: #bfd0e0;
}

#appConfirmModal .btn-outline-secondary:hover {
    background: #eaf2fb;
    color: #173a5d;
}

.navbar,
.navbar-brand {
    letter-spacing: .3px;
}

.navbar .nav-link {
    position: relative;
}

.navbar .nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 4px;
    height: 2px;
    width: 0;
    background: var(--color-accent);
    transition: width .25s;
}

.navbar .nav-link:hover::after {
    width: 100%;
}

.status-soft {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .7rem;
    border-radius: 4px;
    background: #ecfafe;
    color: #0294d6;
    font-size: .82rem;
    font-weight: 700;
}

.page-toolbar {
    background: #fff;
    border: 0;
    border-radius: 5px;
    box-shadow: var(--shadow-md);
    padding: .95rem 1.1rem;
}

.page-toolbar__eyebrow {
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .72rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

.page-toolbar__title {
    font-size: clamp(1.25rem, 2vw, 1.8rem);
    font-weight: 700;
    color: var(--color-text);
}

.chart-wrap {
    position: relative;
    width: 100%;
}

.chart-wrap--analytics {
    height: 280px;
}

.chart-wrap--products-small {
    height: 190px;
}

.dashboard-card-actions {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.dashboard-card-actions .btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border-color: #e8edf4;
}

.chart-wrap--device {
    width: 170px;
    height: 170px;
    margin: .25rem auto 1rem;
}

.device-analytics-list {
    display: grid;
    gap: .55rem;
}

.device-analytics-list li {
    display: grid;
    grid-template-columns: 12px 1fr auto auto;
    gap: .5rem;
    align-items: center;
    font-size: .82rem;
}

.device-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.device-dot--ingresadas {
    background: #04a9f5;
}

.device-dot--pagadas {
    background: #2ed8b6;
}

.device-dot--entregadas {
    background: #ff5370;
}

.device-label {
    color: #4a5568;
}

.device-pct {
    color: #7f8ca5;
    font-weight: 600;
}

.device-value {
    min-width: 28px;
    text-align: end;
    font-weight: 700;
    color: #2f3a4d;
}

.risk-score-block {
    text-align: center;
    padding: .4rem 0 .1rem;
}

.risk-score {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    color: #303548;
}

.risk-level {
    font-size: .85rem;
    color: var(--color-muted);
    margin-top: .3rem;
}

.risk-meter-list {
    display: grid;
    gap: .7rem;
}

.risk-meter-item span {
    font-size: .8rem;
}

.risk-meter-item .progress {
    height: 6px;
    margin-top: .3rem;
    background: #edf1f7;
}

.activity-list {
    display: grid;
    gap: .95rem;
}

.activity-list li {
    display: grid;
    grid-template-columns: 12px 1fr;
    gap: .75rem;
    align-items: start;
}

.activity-dot {
    width: 9px;
    height: 9px;
    margin-top: .42rem;
    border-radius: 50%;
    background: #04a9f5;
    box-shadow: 0 0 0 4px rgba(4, 169, 245, .15);
}

.update-feed {
    display: grid;
    gap: .85rem;
}

.update-feed li {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: .65rem;
    align-items: start;
}

.update-feed i {
    color: #04a9f5;
}

.profile-widget {
    overflow: hidden;
}

.profile-widget__banner {
    height: 84px;
    background: linear-gradient(120deg, #04a9f5, #01a9ac);
}

.profile-widget__avatar {
    width: 56px;
    height: 56px;
    margin: -42px auto 10px;
    border-radius: 50%;
    background: #fff;
    color: #04a9f5;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .12);
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    text-align: left;
}

.profile-grid span {
    font-size: .82rem;
    color: #475266;
}

.social-links-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .55rem;
}

.social-tile {
    border: 1px solid #edf0f6;
    border-radius: 5px;
    min-height: 54px;
    display: grid;
    place-items: center;
    gap: .2rem;
    text-decoration: none;
    color: #5f6c83;
    font-size: .74rem;
}

.social-tile i {
    color: #04a9f5;
}

.social-tile:hover {
    background: #f7fbff;
}

#formLinea .form-label-sm {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

#formLinea input.form-control-sm,
#formLinea select.form-select-sm {
    font-size: .75rem;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        display: none;
    }

    .topbar {
        margin: 0;
        padding-inline: 1rem;
    }

    .app-main {
        padding-inline: 1rem;
    }

    .topbar-actions .topbar-action {
        display: none;
    }

    .chart-wrap--analytics {
        height: 240px;
    }

    .chart-wrap--device {
        width: 148px;
        height: 148px;
    }

    .chart-wrap--products-small {
        height: 170px;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575.98px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

.select2-container .select2-selection--single {
    height: 31px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 31px;
    font-size: .8rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 31px;
}

/* Modern toasts */
.modern-toast {
    position: relative;
    overflow: hidden;
    color: #fff;
}

.modern-toast.toast-success {
    background: linear-gradient(135deg, #198754, #28a745);
}

.modern-toast.toast-danger {
    background: linear-gradient(135deg, #dc3545, #b02a37);
}

.modern-toast.toast-warning {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #212529;
}

.modern-toast.toast-info {
    background: linear-gradient(135deg, #0d6efd, #3b82f6);
}

.modern-toast .toast-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.modern-toast .btn-close {
    filter: invert(1) grayscale(1);
}

.modern-toast.toast-warning .btn-close {
    filter: none;
}

.modern-toast .toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, .5);
}

.modern-toast.toast-warning .toast-progress {
    background: rgba(0, 0, 0, .35);
}

.modern-toast.show {
    animation: popIn .25s ease;
}

@keyframes popIn {
    from {
        transform: translateY(-6px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Animación modal confirm */
#appConfirmIcon.app-confirm-anim {
    opacity: 0;
    transform: scale(.85) translateY(-4px);
    transition: all .25s ease;
}

#appConfirmIcon.app-confirm-anim.active {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Highlight fila agregada/actualizada */
@keyframes rowFlash {
    0% {
        background: #fff8e1;
    }

    60% {
        background: #fff8e1;
    }

    100% {
        background: transparent;
    }
}

tr.row-flash {
    animation: rowFlash 1.2s ease-out;
}