/* =====================================================
       PAGE HEADER
    ===================================================== */

.anomaly-page {
    padding-bottom: 1rem;
}

.page-icon-badge {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #B91C1C 0%, #EF4444 100%);
    box-shadow: 0 10px 22px rgba(220, 38, 38, .28);
    flex-shrink: 0;
}

.page-title {
    font-weight: 800;
    letter-spacing: -.4px;
    color: var(--text-main, #0f172a);
    font-size: 1.45rem;
}

.page-subtitle {
    color: var(--text-muted, #64748b);
    font-size: .88rem;
    max-width: 720px;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: .55rem 1rem;
    border-radius: 12px;
    background: #FEF2F2;
    color: #B91C1C;
    border: 1px solid #FECACA;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .3px;
}

.meta-chip i {
    font-size: .95rem;
}

/* =====================================================
       KPI CARD
    ===================================================== */

.kpi-card {
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
    transition: all .25s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.kpi-card.accent-success::before {
    background: #16A34A;
}

.kpi-card.accent-danger::before {
    background: #DC2626;
}

.kpi-card.accent-primary::before {
    background: #6366F1;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(15, 23, 42, .10);
}

.kpi-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: #94A3B8;
}

.kpi-value {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -.5px;
    color: #0f172a;
}

.kpi-hint {
    font-size: .74rem;
    color: #94A3B8;
    font-weight: 500;
}

.kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* =====================================================
       FORM CARD & SECTION CARD
    ===================================================== */

.form-card,
.section-card {
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .05);
}

.form-card-header {
    background: #F8FAFC;
    border-bottom: 1px solid #E2E8F0;
    padding: 1rem 1.25rem;
}

.form-card-header h5 {
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -.3px;
}

/* =====================================================
       BUTTON
    ===================================================== */

.btn-gradient {
    background: linear-gradient(135deg, #0F766E 0%, #14B8A6 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: .88rem;
    padding: .7rem 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    box-shadow: 0 8px 20px rgba(15, 118, 110, .28);
    transition: all .2s ease;
}

.btn-gradient:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(15, 118, 110, .35);
}

.btn-gradient-danger {
    background: linear-gradient(135deg, #B91C1C 0%, #EF4444 100%);
    box-shadow: 0 8px 20px rgba(220, 38, 38, .28);
}

.btn-gradient-danger:hover {
    box-shadow: 0 12px 26px rgba(220, 38, 38, .35);
}

.btn-gradient:disabled {
    opacity: .7;
    transform: none;
}

.btn-reset {
    border-radius: 12px;
    font-weight: 600;
    font-size: .88rem;
    padding: .7rem 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    transition: all .2s ease;
}

/* =====================================================
       EMPTY STATE
    ===================================================== */

.empty-state {
    text-align: center;
    color: #94A3B8;
    padding: 2.5rem 1rem;
}

.empty-state i {
    color: #CBD5E1;
}

/* =====================================================
       RESULT CARD
    ===================================================== */

#anomalyResult .result-card {
    border-radius: 16px;
    border: 1px solid #E2E8F0;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .06);
}

#anomalyResult .result-header {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    font-weight: 700;
    letter-spacing: -.2px;
}

#anomalyResult .result-body {
    padding: 1.5rem;
}

#anomalyResult .result-icon {
    font-size: 4rem;
    line-height: 1;
}

#anomalyResult .result-status {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.5px;
}

.confidence-bar {
    height: 20px;
    border-radius: 999px;
    background: #E2E8F0;
    overflow: hidden;
}

.confidence-bar .progress-bar {
    font-weight: 700;
    font-size: .78rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Detail table */
#anomalyResult .detail-table {
    width: 100%;
    font-size: .86rem;
}

#anomalyResult .detail-table th {
    color: #64748B;
    font-weight: 600;
    padding: .55rem 0;
    width: 180px;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

#anomalyResult .detail-table td {
    padding: .55rem 0;
    color: #334155;
    font-weight: 500;
}

/* Insight cards */
.insight-card {
    border-radius: 14px;
    padding: 1.1rem 1.25rem;
    height: 100%;
    border: 1px solid transparent;
}

.insight-card h6 {
    font-weight: 800;
    letter-spacing: .3px;
    font-size: .8rem;
    text-transform: uppercase;
    margin-bottom: .55rem;
}

.insight-card p {
    margin: 0;
    font-size: .88rem;
    line-height: 1.5;
}

.insight-danger {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #7F1D1D;
}

.insight-danger h6 {
    color: #B91C1C;
}

.insight-success {
    background: #ECFDF5;
    border-color: #BBF7D0;
    color: #064E3B;
}

.insight-success h6 {
    color: #047857;
}

/* Meta row */
.result-meta {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    text-align: center;
    padding-top: .5rem;
}

.result-meta .meta-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: #94A3B8;
    margin-bottom: .25rem;
}

.result-meta .meta-value {
    font-weight: 800;
    font-size: 1.05rem;
    color: #0f172a;
    letter-spacing: -.3px;
}

.result-meta .meta-sub {
    font-size: .72rem;
    font-weight: 600;
    color: #64748B;
    margin-top: 2px;
    letter-spacing: .2px;
}

body.dark-mode .result-meta .meta-sub {
    color: #94A3B8;
}

@media (max-width: 575.98px) {
    .result-meta {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =====================================================
       DARK MODE
    ===================================================== */

body.dark-mode .kpi-card,
body.dark-mode .form-card,
body.dark-mode .section-card,
body.dark-mode #anomalyResult .result-card {
    background: #1E293B;
    border-color: #334155;
}

body.dark-mode .kpi-value,
body.dark-mode .page-title,
body.dark-mode .form-card-header h5,
body.dark-mode #anomalyResult .result-status,
body.dark-mode .result-meta .meta-value {
    color: #F1F5F9;
}

body.dark-mode .form-card-header {
    background: #0F172A;
    border-bottom-color: #334155;
}

body.dark-mode .kpi-card:hover {
    box-shadow: 0 12px 28px rgba(0, 0, 0, .35);
}

body.dark-mode .meta-chip {
    background: #2A0E0E;
    color: #FCA5A5;
    border-color: #7F1D1D;
}

body.dark-mode .empty-state {
    color: #64748B;
}

body.dark-mode .empty-state i {
    color: #475569;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background: #0F172A;
    border-color: #334155;
    color: #F1F5F9;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    background: #0F172A;
    border-color: #EF4444;
    color: #F1F5F9;
    box-shadow: 0 0 0 .2rem rgba(239, 68, 68, .25);
}

body.dark-mode #anomalyResult .detail-table td {
    color: #CBD5E1;
}

body.dark-mode #anomalyResult .detail-table th {
    color: #94A3B8;
}

body.dark-mode .confidence-bar {
    background: #334155;
}

body.dark-mode .insight-danger {
    background: #2A0E0E;
    border-color: #7F1D1D;
    color: #FCA5A5;
}

body.dark-mode .insight-danger h6 {
    color: #F87171;
}

body.dark-mode .insight-success {
    background: #052E2B;
    border-color: #0F766E;
    color: #A7F3D0;
}

body.dark-mode .insight-success h6 {
    color: #2DD4BF;
}

/* =====================================================
       RESPONSIVE
    ===================================================== */

@media (max-width: 575.98px) {
    .page-icon-badge {
        width: 46px;
        height: 46px;
        font-size: 1.25rem;
    }

    .page-title {
        font-size: 1.15rem;
    }

    .kpi-value {
        font-size: 1.3rem;
    }

    .btn-gradient,
    .btn-reset {
        width: 100%;
    }

    #anomalyResult .result-icon {
        font-size: 3rem;
    }

    #anomalyResult .result-status {
        font-size: 1.35rem;
    }
}