/* 원가 관리 화면 (작업지시별 원가 · 원가 상세 · 품목별 원가 · LOT 추적의 원가 칸). 바탕 틀은 analytics.css(an-*)를 같이 쓴다 */

.cost-search {
    min-width: 0;
    width: 13rem;
    max-width: 100%;
}

.cost-back {
    margin-bottom: 0.5rem;
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text);
    cursor: pointer;
}

.cost-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.cost-status {
    display: inline-block;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid currentColor;
}

    .cost-status.done { color: #3fb27f; }
    .cost-status.doing { color: #f29d38; }
    .cost-status.todo { color: var(--app-muted); }

.cost-neg {
    color: var(--app-danger);
    font-weight: 700;
}

.cost-warn {
    color: #f29d38;
    font-weight: 700;
    cursor: help;
    white-space: nowrap;
}

.cost-warnings ul {
    margin: 0.3rem 0 0;
    padding-left: 1.2rem;
}

/* 원가 구성 막대 (재료비 / 외주비) */
.cost-bar {
    display: flex;
    height: 1.6rem;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: var(--app-border-soft);
}

    .cost-bar > div {
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        overflow: hidden;
        min-width: 0;
    }

    .cost-bar .mat { background: #4c8df6; }
    .cost-bar .out { background: #a86bf0; }

.an-table tr.cost-missing td {
    background: rgba(255, 107, 107, 0.08);
}

.an-table tr.cost-selected td {
    background: var(--app-hover);
    font-weight: 700;
}

.cost-sub-head {
    margin: 0.9rem 0 0.4rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: #f29d38;
}

.cost-src {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}

.cost-flag {
    padding: 0 0.4rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
}

    .cost-flag.miss { background: rgba(255, 107, 107, 0.18); color: var(--app-danger); }
    .cost-flag.est { background: rgba(242, 157, 56, 0.18); color: #f29d38; }

.cost-lots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
    margin-top: 0.6rem;
}

.cost-lot {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.5rem 0.7rem;
    border-radius: 10px;
    border: 1px solid var(--app-border-soft);
    background: var(--app-bg);
    color: var(--app-text);
    text-decoration: none;
    font-size: 0.85rem;
}

    .cost-lot:hover {
        border-color: var(--app-accent);
        color: var(--app-text);
    }

.cost-lot .muted, .cost-src .muted, .an-head .muted {
    color: var(--app-muted);
    font-weight: 500;
}

/* LOT 추적 화면의 원가 칸 */
.lt-cost {
    margin: 0 0 0.9rem;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    border: 1px solid var(--app-border-soft);
    background: var(--app-surface);
}

.lt-cost-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

    .lt-cost-head > span:first-child {
        font-weight: 800;
    }

    .lt-cost-head b {
        font-size: 1.15rem;
    }

        .lt-cost-head b small {
            font-size: 0.75rem;
            color: var(--app-muted);
            margin-left: 0.15rem;
        }

    .lt-cost-head .lt-open {
        margin-left: auto;
    }

.lt-cost-stock {
    color: var(--app-muted);
    font-size: 0.85rem;
}

.lt-cost-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
    font-size: 0.8rem;
}

.lt-cost-step {
    display: inline-flex;
    gap: 0.3rem;
    align-items: center;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--app-hover);
}

    .lt-cost-step + .lt-cost-step::before {
        content: "←";
        color: var(--app-muted);
        margin-right: 0.2rem;
    }

    .lt-cost-step small {
        color: var(--app-muted);
    }

@media (max-width: 640px) {
    .cost-search {
        width: 100%;
    }

    .cost-lots {
        grid-template-columns: 1fr;
    }
}

/* 원가 마감 */
.cost-close-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.cost-close-btn {
    padding: 0.35rem 0.9rem;
    border-radius: 8px;
    border: none;
    background: #d9534f;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

    .cost-close-btn:disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

.cost-confirm {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.cost-sub-head.plain {
    color: var(--app-text);
}

.cost-pre {
    white-space: pre-line;
}

.an-table tr.muted td {
    color: var(--app-muted);
}

.cost-locked {
    font-size: 0.75rem;
    white-space: nowrap;
}
