/* ---- 시각화(분석) 화면: 수주현황 · 출하현황 · 생산추이 ---- */
.an-page {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0.25rem 0 2.5rem;
}

.an-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

    .an-head h3 {
        margin: 0;
        font-weight: 800;
        letter-spacing: -0.02em;
    }

.an-sub {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: var(--app-muted);
}

.an-loading, .an-empty {
    padding: 2.5rem 0;
    text-align: center;
    color: var(--app-muted);
    font-size: 0.9rem;
}

    .an-empty.good {
        color: #22c55e;
    }

/* 조건 바 */
.an-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.7rem;
    padding: 0.65rem 0.8rem;
    border-radius: 14px;
    border: 1px solid var(--app-border-soft);
    background: var(--app-surface);
    margin-bottom: 0.6rem;
}

.an-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.an-chip {
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--app-border);
    background: transparent;
    color: var(--app-text);
    font-size: 0.82rem;
    cursor: pointer;
}

    .an-chip:hover {
        background: var(--app-hover);
    }

    .an-chip.on {
        background: #3b82f6;
        border-color: #3b82f6;
        color: #fff;
        font-weight: 700;
    }

.an-range {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--app-muted);
}

    .an-range input, .an-select {
        padding: 0.25rem 0.5rem;
        border-radius: 8px;
        border: 1px solid var(--app-border);
        background: var(--app-bg);
        color: var(--app-text);
        font-size: 0.85rem;
        color-scheme: light dark;
    }

.an-select {
    max-width: 180px;
    max-width: 220px;
}

.an-seg {
    display: inline-flex;
    border: 1px solid var(--app-border);
    border-radius: 9px;
    overflow: hidden;
}

    .an-seg button {
        border: none;
        background: transparent;
        color: var(--app-muted);
        padding: 0.28rem 0.65rem;
        font-size: 0.82rem;
        cursor: pointer;
    }

        .an-seg button + button {
            border-left: 1px solid var(--app-border);
        }

        .an-seg button.on {
            background: var(--app-hover);
            color: var(--app-text);
            font-weight: 700;
        }

    .an-seg.strong button.on {
        background: #8b5cf6;
        color: #fff;
    }

    .an-seg.small button {
        padding: 0.18rem 0.55rem;
        font-size: 0.75rem;
    }

.an-refresh {
    margin-left: auto;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid var(--app-border);
    background: transparent;
    color: var(--app-text);
    cursor: pointer;
}

    .an-refresh:hover {
        background: var(--app-hover);
    }

.an-active {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.6rem 0.2rem;
    font-size: 0.8rem;
    color: var(--app-muted);
}

.an-tag {
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid #3b82f6;
    background: color-mix(in srgb, #3b82f6 15%, transparent);
    color: var(--app-text);
    font-size: 0.8rem;
    cursor: pointer;
}

/* KPI 카드 */
.an-kpis {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.7rem;
    margin-bottom: 0.8rem;
}

.an-kpi {
    --c: #3b82f6;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.85rem 1rem 0.8rem;
    border-radius: 16px;
    border: 1px solid var(--app-border-soft);
    background: linear-gradient(160deg, color-mix(in srgb, var(--c) 17%, var(--app-surface)) 0%, var(--app-surface) 72%);
}

    .an-kpi::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background: var(--c);
    }

    .an-kpi .lbl {
        font-size: 0.78rem;
        font-weight: 700;
        color: var(--app-muted);
    }

    .an-kpi b {
        font-size: 1.7rem;
        font-weight: 800;
        letter-spacing: -0.03em;
        line-height: 1.15;
    }

        .an-kpi b small {
            font-size: 0.85rem;
            font-weight: 600;
            margin-left: 0.15rem;
            color: var(--app-muted);
        }

    .an-kpi .sub {
        font-size: 0.74rem;
        color: var(--app-muted);
    }

    .an-kpi.attention {
        animation: an-pulse 2.2s ease-in-out infinite;
    }

@keyframes an-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 0%, transparent); }
    50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent); }
}

.an-kpi.c-blue { --c: #3b82f6; }
.an-kpi.c-purple { --c: #8b5cf6; }
.an-kpi.c-teal { --c: #14b8a6; }
.an-kpi.c-orange { --c: #f59e0b; }
.an-kpi.c-green { --c: #22c55e; }
.an-kpi.c-red { --c: #ef4444; }
.an-kpi.c-gray { --c: #94a3b8; }

.an-mini-bar {
    height: 6px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--app-text) 10%, transparent);
    overflow: hidden;
    margin: 0.15rem 0;
}

    .an-mini-bar > div {
        height: 100%;
        border-radius: 99px;
        background: var(--c);
    }

/* 카드 */
.an-grid {
    display: grid;
    gap: 0.8rem;
}

    .an-grid.two {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

.an-card {
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--app-border-soft);
    background: var(--app-surface);
    margin-bottom: 0.8rem;
    min-width: 0;
}

.an-grid .an-card {
    margin-bottom: 0;
}

.an-grid {
    margin-bottom: 0.8rem;
}

.an-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-weight: 800;
    margin-bottom: 0.6rem;
}

    .an-card-head small {
        font-weight: 500;
        font-size: 0.75rem;
        color: var(--app-muted);
        margin-left: 0.3rem;
    }

/* 도넛 + 범례 */
.an-donut-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.an-donut {
    position: relative;
    flex-shrink: 0;
}

.an-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

    .an-donut-center small {
        font-size: 0.75rem;
        color: var(--app-muted);
    }

    .an-donut-center b {
        font-size: 1.15rem;
        font-weight: 800;
    }

.an-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
}

    .an-legend li {
        display: flex;
        align-items: center;
        gap: 0.45rem;
    }

    .an-legend .dot {
        width: 10px;
        height: 10px;
        border-radius: 3px;
        flex-shrink: 0;
    }

    .an-legend .name {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .an-legend .val {
        font-weight: 700;
    }

.an-tip {
    font-size: 0.82rem;
    line-height: 1.4;
}

/* 표 */
.an-table-wrap {
    overflow: auto;
    max-height: 420px;
}

    .an-table-wrap.tall {
        max-height: 520px;
    }

.an-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

    .an-table th {
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--app-surface);
        color: var(--app-muted);
        font-weight: 700;
        text-align: left;
        padding: 0.45rem 0.55rem;
        border-bottom: 1px solid var(--app-border);
        white-space: nowrap;
    }

    .an-table td {
        padding: 0.45rem 0.55rem;
        border-bottom: 1px solid var(--app-border-soft);
        white-space: nowrap;
    }

    .an-table .num {
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .an-table .rank {
        width: 3rem;
        text-align: center;
    }

    .an-table .share {
        width: 170px;
    }

        .an-table .share > span {
            font-size: 0.78rem;
            color: var(--app-muted);
        }

    .an-table tr.click {
        cursor: pointer;
    }

        .an-table tr.click:hover td {
            background: var(--app-hover);
        }

    .an-table .muted {
        color: var(--app-muted);
    }

.an-bar {
    display: inline-block;
    width: 100px;
    height: 7px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--app-text) 9%, transparent);
    overflow: hidden;
    vertical-align: middle;
    margin-right: 0.4rem;
}

    .an-bar > div {
        height: 100%;
        border-radius: 99px;
        background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    }

.an-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 800;
    background: color-mix(in srgb, var(--app-text) 8%, transparent);
}

    .an-rank.r1 { background: #f59e0b; color: #fff; }
    .an-rank.r2 { background: #94a3b8; color: #fff; }
    .an-rank.r3 { background: #b45309; color: #fff; }

.an-pill {
    display: inline-block;
    padding: 0.08rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

    .an-pill.good { background: color-mix(in srgb, #22c55e 20%, transparent); color: #16a34a; }
    .an-pill.mid { background: color-mix(in srgb, #f59e0b 22%, transparent); color: #d97706; }
    .an-pill.bad { background: color-mix(in srgb, #ef4444 20%, transparent); color: #dc2626; }

.an-status {
    display: inline-block;
    padding: 0.08rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--app-text) 9%, transparent);
}

    .an-status.s-출하완료 { background: color-mix(in srgb, #22c55e 20%, transparent); color: #16a34a; }
    .an-status.s-부분출하 { background: color-mix(in srgb, #3b82f6 20%, transparent); color: #2563eb; }
    .an-status.s-납기지연 { background: color-mix(in srgb, #ef4444 20%, transparent); color: #dc2626; }
    .an-status.s-미출하 { background: color-mix(in srgb, #94a3b8 22%, transparent); }

/* 반응형 */
@media (max-width: 1280px) {
    .an-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .an-grid.two {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .an-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .an-kpi b {
        font-size: 1.35rem;
    }

    .an-refresh {
        margin-left: 0;
    }
}

.an-table small.muted {
    margin-left: 0.35rem;
}

/* 차트 글자/격자를 앱 테마(다크·화이트) 색으로 - 차트는 그릴 때의 색을 SVG에 고정하므로 테마를 바꿔도 따라오게 */
.an-card .dxc-val-elements text,
.an-card .dxc-arg-elements text {
    fill: var(--app-muted) !important;
}

.an-card .dxc-val-title text,
.an-card .dxc-arg-title text,
.an-card .dxc-legend text,
.an-card .dxc-title text {
    fill: var(--app-text) !important;
}

.an-card .dxc-val-grid path,
.an-card .dxc-arg-grid path {
    stroke: color-mix(in srgb, var(--app-text) 12%, transparent) !important;
}

.an-card .dxc-val-line path,
.an-card .dxc-arg-line path,
.an-card .dxc-val-elements path,
.an-card .dxc-arg-elements path {
    stroke: var(--app-border) !important;
}

.an-now {
    font-size: 0.85rem;
    color: var(--app-muted);
    padding: 0.25rem 0.4rem;
}

/* 공통 보고서 화면 */
.an-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

    .an-charts .an-card {
        margin-bottom: 0;
    }

    .an-charts .an-card.wide {
        grid-column: 1 / -1;
    }

.an-notes {
    margin: 0.2rem 0 1rem;
    padding-left: 1.1rem;
    font-size: 0.8rem;
    color: var(--app-muted);
}

.an-days {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

    .an-days.late { color: #ef4444; }
    .an-days.soon { color: #f59e0b; }

.an-cellbar {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

    .an-cellbar .an-bar {
        width: 80px;
        margin: 0;
    }

    .an-cellbar span {
        font-size: 0.78rem;
        color: var(--app-muted);
        min-width: 3rem;
        text-align: right;
    }

/* 배지 색 (상태 글자로 자동) */
.an-badge {
    display: inline-block;
    padding: 0.08rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--app-text) 9%, transparent);
    white-space: nowrap;
}

    .an-badge.good { background: color-mix(in srgb, #22c55e 20%, transparent); color: #16a34a; }
    .an-badge.info { background: color-mix(in srgb, #3b82f6 20%, transparent); color: #2563eb; }
    .an-badge.warn { background: color-mix(in srgb, #f59e0b 22%, transparent); color: #d97706; }
    .an-badge.bad { background: color-mix(in srgb, #ef4444 20%, transparent); color: #dc2626; }
    .an-badge.gradeA { background: #ef4444; color: #fff; }
    .an-badge.gradeB { background: #f59e0b; color: #fff; }
    .an-badge.gradeC { background: #94a3b8; color: #fff; }

@media (max-width: 900px) {
    .an-charts {
        grid-template-columns: 1fr;
    }
}

/* 분석 메뉴 첫 화면 (현황 모음) */
.an-hub {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.7rem;
    margin-bottom: 1.2rem;
}

.an-hub-card {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--app-border-soft);
    background: var(--app-surface);
    color: var(--app-text);
    text-decoration: none;
    transition: transform 0.12s, border-color 0.12s;
}

    .an-hub-card:hover {
        transform: translateY(-2px);
        border-color: #3b82f6;
        color: var(--app-text);
    }

    .an-hub-card .ic {
        font-size: 1.6rem;
        line-height: 1;
    }

    .an-hub-card b {
        display: block;
        font-size: 0.98rem;
    }

    .an-hub-card small {
        color: var(--app-muted);
        font-size: 0.78rem;
    }

.an-hub-title {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--app-muted);
    margin: 0.4rem 0 0.5rem 0.2rem;
}

/* ---- AI 모아보기 - 설비 예지보전 ---- */
.an-chip:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.ai-days {
    width: 5.5rem;
}

.ai-items {
    margin: 0.6rem 0 0.8rem;
}
