:root {
    --skeleton-base: #e3e2e7;
    --skeleton-highlight: #f5f5f8;
    --skeleton-head-bg: #f6f7fb;
    --skeleton-stripe-bg: #fafafc;
    --skeleton-border: var(--bs-gray-200, #d5d4d8);
    --skeleton-surface: #fff;
}

.skeleton {
    display: block;
    background-color: var(--skeleton-base);
    background-image: linear-gradient(90deg, transparent 0%, var(--skeleton-highlight) 50%, transparent 100%);
    background-size: 220% 100%;
    background-repeat: no-repeat;
    border-radius: 4px;
    animation: skeleton-shimmer 1.5s linear infinite;
}

@keyframes skeleton-shimmer {
    from { background-position: 180% 0; }
    to { background-position: -80% 0; }
}

.skeleton-line {
    height: 0.85rem;
}

.skeleton-line + .skeleton-line {
    margin-top: 10px;
}

.skeleton-heading {
    height: 1.75rem;
    margin-bottom: 19px;
}

.skeleton-subheading {
    height: 1.1rem;
    margin-bottom: 12px;
}

.skeleton-badge {
    height: 1.5rem;
    width: 5.5rem;
    border-radius: 999px;
}

.skeleton-btn {
    height: 2.25rem;
    width: 6rem;
    border-radius: 0.25rem;
}

.skeleton-btn-sm {
    height: 1.9rem;
    width: 5rem;
}

.skeleton-input {
    height: 2.4rem;
    border-radius: 0.25rem;
}

.skeleton-w-15 { width: 15%; }
.skeleton-w-25 { width: 25%; }
.skeleton-w-35 { width: 35%; }
.skeleton-w-50 { width: 50%; }
.skeleton-w-65 { width: 65%; }
.skeleton-w-75 { width: 75%; }
.skeleton-w-90 { width: 90%; }
.skeleton-w-100 { width: 100%; }

.skeleton-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.skeleton-stack > * + * {
    margin-top: 12px;
}

.skeleton-fill {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Tables ── */
.skeleton-table {
    border: 1px solid var(--skeleton-border);
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--skeleton-surface);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.skeleton-table-head,
.skeleton-table-row {
    display: flex;
    align-items: center;
    padding: 16px 20px;
}

.skeleton-table-head {
    padding-top: 28px;
    padding-bottom: 28px;
    background-color: var(--skeleton-head-bg);
}

.skeleton-table-head .skeleton {
    --skeleton-base: #d5d4d8;
}

.skeleton-table-row {
    border-top: 1px solid var(--bs-gray-100, #eae9ec);
}

.skeleton-table-row:nth-child(even) {
    background-color: var(--skeleton-stripe-bg);
}

.skeleton-cell {
    display: block;
    padding-right: 20px;
}

.skeleton-cell:last-child {
    padding-right: 0;
}

.skeleton-table .skeleton-line {
    width: 85%;
}

.skeleton-table-row:nth-child(2n) .skeleton-cell:nth-child(2n) .skeleton-line { width: 60%; }
.skeleton-table-row:nth-child(3n) .skeleton-cell:nth-child(3n) .skeleton-line { width: 70%; }
.skeleton-table-row:nth-child(4n) .skeleton-cell:nth-child(2n) .skeleton-line { width: 75%; }

/* ── Charts ── */
.skeleton-chart {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    height: 320px;
    padding: 16px 0;
    border-bottom: 1px solid var(--skeleton-border);
}

.skeleton-chart-sm {
    height: 150px;
}

.skeleton-chart .skeleton {
    flex: 1;
    border-radius: 4px 4px 0 0;
}

.skeleton-chart .skeleton:nth-child(1) { height: 55%; }
.skeleton-chart .skeleton:nth-child(2) { height: 80%; }
.skeleton-chart .skeleton:nth-child(3) { height: 40%; }
.skeleton-chart .skeleton:nth-child(4) { height: 95%; }
.skeleton-chart .skeleton:nth-child(5) { height: 65%; }
.skeleton-chart .skeleton:nth-child(6) { height: 30%; }
.skeleton-chart .skeleton:nth-child(7) { height: 70%; }

.skeleton-chart-bar {
    display: block;
    height: 34px;
    border-radius: 4px;
}

.skeleton.status-step-marker {
    border-radius: 50%;
}

.skeleton-circle {
    border-radius: 50%;
    width: 220px;
    height: 220px;
    margin: 0 auto;
}

/* ── Page overlay ── */
.skeleton-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1020;
    overflow: hidden;
    background-color: var(--bs-body-bg, #fff);
}

.skeleton-overlay > .container-fluid {
    height: 100%;
}

.skeleton-overlay .settings-nav-card {
    position: static;
}

/* ── Turbo frame overlay ── */
.skeleton-frame-loading {
    position: relative;
}

.skeleton-frame-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    overflow: hidden;
    background-color: var(--skeleton-surface);
}

@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
    }
}
