@property --num {
    syntax: "<integer>";
    initial-value: 0;
    inherits: false;
}

@keyframes count {
    from {
        --num: 0;
    }

    to {
        --num: var(--target-num, 0);
    }
}

:root {
    /* Tier 1 & 2: IWCO / CLARA Core Design Tokens */
    --color-primary: #000d33;
    --color-primary-container: #002060;
    --color-data-blue: #1e88e5;
    --color-data-purple: #8e24aa;
    --color-secondary: #843ab4;
    --color-secondary-fixed: #f4d9ff;
    --color-tertiary-accent: #e56700;
    --color-accent-orange-light: #fff3e0;
    --color-error: #ba1a1a;
    --color-error-container: #ffdad6;
    --color-on-error-container: #93000a;

    /* Surface & Neutral Tokens */
    --color-surface: #f3faff;
    --color-surface-sky: #f8fafc;
    --color-surface-lowest: #ffffff;
    --color-surface-low: #e6f6ff;
    --color-surface-container: #dbf1fe;
    --color-surface-highest: #cfe6f2;
    --color-on-surface: #071e27;
    --color-on-surface-variant: #444650;
    --color-outline: #757681;
    --color-outline-variant: #c5c6d2;

    /* Elevation & Motion Tokens */
    --shadow-card: 0px 10px 30px rgba(0, 32, 96, 0.05);
    --shadow-card-hover: 0px 15px 40px rgba(0, 32, 96, 0.09);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

    /* Dynamic Distribution Bar Defaults */
    --bar-active-width: 35%;
    --bar-stale-width: 50%;
    --bar-dup-width: 15%;
}

/* Base Elements */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 450, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

dialog:modal {
    overscroll-behavior: contain;
}

dialog::backdrop {
    overflow: hidden;
    overscroll-behavior: contain;
    background-color: rgba(0, 13, 51, 0.48);
    backdrop-filter: blur(4px);
}

/* Hero & Surface Backgrounds */
.hero-gradient {
    background:
        radial-gradient(circle at 100% 0%, rgba(204, 128, 253, 0.14) 0%, rgba(243, 250, 255, 0) 55%),
        radial-gradient(circle at 0% 100%, rgba(30, 136, 229, 0.08) 0%, rgba(243, 250, 255, 0) 55%);
}

.card-shadow {
    box-shadow: var(--shadow-card);
}

.card-hover {
    transition: transform 0.2s var(--ease-out-expo), box-shadow 0.2s var(--ease-out-expo), border-color 0.2s var(--ease-out-expo);

    &:hover {
        box-shadow: var(--shadow-card-hover);
        border-color: rgba(0, 13, 51, 0.18);
        transform: translateY(-2px);
    }
}

/* Deferred Below-the-Fold Heavy Sections */
.section-deferred {
    content-visibility: auto;
    contain-intrinsic-size: auto none auto 540px;
}

/* Executive Informational KPI Cards */
.kpi-card {
    cursor: default;
    text-align: start;
    background-color: var(--color-surface-lowest);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(197, 198, 210, 0.3);
}

.kpi-icon-box {
    block-size: 2.25rem;
    inline-size: 2.25rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Animated Integer Counter (.stat via @property --num) */
.stat {
    --target-num: 0;
    counter-reset: n var(--num);
    animation: count 2s forwards;

    @media (prefers-reduced-motion: reduce) {
        animation: none;
        --num: var(--target-num, 0);
    }

    &::after {
        content: counter(n);
        content: counter(n) / "";
    }
}

/* Distribution Bar Segments */
.dist-bar-active {
    inline-size: var(--bar-active-width);
    background-color: var(--color-data-blue);
    block-size: 100%;
    transition: inline-size 0.5s var(--ease-out-expo);
}

.dist-bar-stale {
    inline-size: var(--bar-stale-width);
    background-color: var(--color-tertiary-accent);
    block-size: 100%;
    transition: inline-size 0.5s var(--ease-out-expo);
}

.dist-bar-duplicates {
    inline-size: var(--bar-dup-width);
    background-color: var(--color-data-purple);
    block-size: 100%;
    transition: inline-size 0.5s var(--ease-out-expo);
}

/* Tactile Platform Buttons (.btn) */
:is(.btn, .btn-primary) {
    background: linear-gradient(#7c7cff, #5b5bf0);
    box-shadow:
        inset 0 1px 0 #ffffff59,
        inset 0 -2px 0 #0003,
        0 1px 2px #0006,
        0 8px 24px -6px #5b5bf099;
    color: #ffffff;
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: filter 0.15s ease, opacity 0.15s ease;

    &:hover:not(:disabled) {
        filter: brightness(1.06);
    }

    &:active:not(:disabled) {
        translate: 0 1px;
        box-shadow: inset 0 2px 4px #0004;
    }

    &:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }
}

/* Category Filter Pills */
.cat-pill {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid rgba(197, 198, 210, 0.45);
    background-color: var(--color-surface-sky);
    color: var(--color-on-surface-variant);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;

    &:hover:not(.is-active) {
        border-color: var(--color-primary);
        color: var(--color-primary);
    }

    &.is-active {
        background-color: var(--color-primary);
        color: #ffffff;
        border-color: var(--color-primary);
    }
}

/* Filter Form Controls */
.filter-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-on-surface-variant);
    margin-block-end: 0.25rem;
}

.filter-control {
    inline-size: 100%;
    padding-block: 0.5rem;
    padding-inline: 0.75rem 2rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(197, 198, 210, 0.6);
    background-color: var(--color-surface-lowest);
    color: var(--color-primary);

    &:focus {
        border-color: var(--color-data-blue);
        outline: none;
        box-shadow: 0 0 0 1px var(--color-data-blue);
    }
}

/* SharePoint Site & Library Cards */
.site-card {
    cursor: pointer;
    text-align: start;
    padding: 1.25rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(197, 198, 210, 0.35);
    background-color: var(--color-surface-sky);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;

    &.is-selected {
        background-color: rgba(230, 246, 255, 0.85);
        border-color: var(--color-data-blue);
        box-shadow: 0 0 0 2px var(--color-data-blue), var(--shadow-card);
    }

    &.is-failed {
        cursor: default;
        background-color: rgba(255, 218, 214, 0.22);
        border-color: rgba(186, 26, 26, 0.4);
    }
}

/* Progress Bars */
.progress-track {
    inline-size: 100%;
    block-size: 0.375rem;
    background-color: var(--color-surface-container);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill-blue {
    inline-size: var(--progress-pct, 2%);
    block-size: 100%;
    background-color: var(--color-data-blue);
    border-radius: 9999px;
}

.progress-fill-purple {
    inline-size: var(--progress-pct, 2%);
    block-size: 100%;
    background-color: var(--color-data-purple);
    border-radius: 9999px;
}

/* CLARA Pro Feature Cards */
.pro-card {
    background-color: var(--color-surface-sky);
    border-radius: 0.75rem;
    padding: 1.75rem;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(197, 198, 210, 0.3);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Responsive Table with Sticky Headers and Container Queries */
.table-wrapper {
    overflow: auto;
    max-inline-size: 100%;
    max-block-size: min(680px, 78vh);
    container-type: inline-size;

    & table {
        border-collapse: separate;
        border-spacing: 0;
        inline-size: 100%;
        --label-2: "Sitio / Biblioteca";
        --label-3: "Tipo";
        --label-4: "Tamaño";
        --label-5: "Modificado";
        --label-6: "Acciones";
    }

    & thead {
        position: sticky;
        inset-block-start: 0;
        z-index: 2;
    }

    & tbody th {
        position: sticky;
        inset-inline-start: 0;
        z-index: 1;
        background-color: var(--color-surface-lowest);
    }

    & tbody tr:hover th {
        background-color: var(--color-surface);
    }
}

@container (width < 680px) {
    .table-wrapper :is(table, thead, tbody, tr, th, td) {
        display: block;
    }

    .table-wrapper thead {
        display: none;
    }

    .table-wrapper tbody tr {
        margin-block-end: 1rem;
        border: 1px solid var(--color-outline-variant);
        border-radius: 0.75rem;
        overflow: hidden;
        background-color: var(--color-surface-lowest);
    }

    .table-wrapper tbody th {
        position: sticky;
        inset-block-start: 0;
        z-index: 2;
        background-color: var(--color-surface-low);
        border-block-end: 1px solid var(--color-surface-highest);
    }

    .table-wrapper td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.65rem 1rem;

        &:not(:last-child) {
            border-block-end: 1px solid #f1f5f9;
        }

        &:is(:nth-child(2), :nth-child(3), :nth-child(4), :nth-child(5), :nth-child(6))::before {
            font-weight: 600;
            color: var(--color-on-surface-variant);
            font-size: 0.75rem;
            text-transform: uppercase;
        }

        &:nth-child(2)::before {
            content: var(--label-2) ": ";
        }

        &:nth-child(3)::before {
            content: var(--label-3) ": ";
        }

        &:nth-child(4)::before {
            content: var(--label-4) ": ";
        }

        &:nth-child(5)::before {
            content: var(--label-5) ": ";
        }

        &:nth-child(6)::before {
            content: var(--label-6) ": ";
        }
    }
}

/* Custom Overrides */
.text-xs {
    padding-right: 10px;
}


/* Custom Overrides */
.text-xs {
    padding-right: 10px;
}