/* ==========================================================================
   KZ-JMS 기본 테마 및 레이아웃
   ========================================================================== */
:root {
    font-family: Arial, 'Yu Gothic', 'Meiryo', sans-serif;
    color: #172338;
    background: #f3f6fb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

.hidden {
    display: none !important;
}

/* 헤더 및 네비게이션 */
header {
    background: #14233c;
    color: #fff;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

header h1 {
    margin: 0;
    font-size: 22px;
}

header small {
    color: #b7c7dd;
}

main {
    max-width: 1440px;
    margin: auto;
    padding: 22px;
}

nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

h2 {
    font-size: 18px;
    margin: 0 0 14px;
}

h3 {
    font-size: 15px;
    margin: 0 0 10px;
}

footer {
    padding: 18px;
    text-align: center;
    color: #78879b;
    font-size: 12px;
}

/* 버튼 및 폼 컨트롤 */
button,
select,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 1px solid #93b9e8;
    background: #dbeafe;
    color: #174e92;
    border-radius: 9px;
    padding: 8px 13px;
}

button:hover:not(:disabled) {
    background: #c5defa;
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

button:focus-visible {
    outline: 2px solid #14233c;
    outline-offset: 2px;
}

button.primary,
nav button,
button.state-reverse {
    background: #2357ba;
    color: #fff;
    border-color: #2357ba;
}

button.primary:hover:not(:disabled),
nav button:hover:not(:disabled),
button.state-reverse:hover:not(:disabled) {
    background: #184493;
}

nav button.active {
    outline: 2px solid #14233c;
    outline-offset: 2px;
}

button.danger {
    color: #9b2929;
    background: #ffe8e8;
    border-color: #f0b6b6;
}

button.danger:hover:not(:disabled) {
    background: #ffd6d6;
}

/* 패널·그리드·카드 */
.panel {
    background: #fff;
    border: 1px solid #e0e6ef;
    border-radius: 13px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px #10223c08;
}

.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 13px;
    margin-bottom: 17px;
}

.metric {
    background: #fff;
    border: 1px solid #e0e6ef;
    border-radius: 12px;
    padding: 17px;
}

.metric small {
    color: #627188;
}

.metric strong {
    display: block;
    font-size: 26px;
    margin-top: 8px;
}

.flex {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.between {
    justify-content: space-between;
}

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.two {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
}

.muted {
    color: #66768b;
    font-size: 13px;
}

/* 배지·진행바·입력 필드 */
.pill {
    display: inline-block;
    border-radius: 20px;
    background: #edf1f7;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
}

.pill.ok {
    background: #e1f5e8;
    color: #16733b;
}

.pill.warn {
    background: #fff0d3;
    color: #8a5b00;
}

.pill.bad {
    background: #ffe5e5;
    color: #a52828;
}

.bar {
    height: 11px;
    background: #e8edf4;
    border-radius: 10px;
    overflow: hidden;
}

.bar > div {
    height: 100%;
    background: #2c67d5;
    transition: width 0.2s ease;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 150px;
    flex: 1;
}

.field label {
    font-size: 12px;
    color: #5c6b80;
}

.field input,
.field select,
.field textarea {
    padding: 10px;
    border: 1px solid #cfd9e7;
    border-radius: 8px;
    width: 100%;
    background: #fff;
}

/* 테이블·스텝·로그 */
.scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 12px 9px;
    border-bottom: 1px solid #e9edf4;
    text-align: left;
}

th {
    color: #65758b;
    font-size: 12px;
    background: #f8fafd;
}

tr.click {
    cursor: pointer;
}

tr.click:hover {
    background: #f4f8ff;
}

.step {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e8edf3;
    gap: 10px;
}

.step:last-child {
    border-bottom: 0;
}

.note {
    background: #fff9e9;
    border: 1px solid #f3e1ac;
    border-radius: 9px;
    padding: 12px;
    font-size: 13px;
    color: #705724;
}

.logs {
    max-height: 240px;
    overflow: auto;
}

.logs p {
    font-size: 12px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

/* 청구 대장·지연 차트 (2단계 연동 대비) */
.pay-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.paybox {
    background: #f7f9fd;
    border: 1px solid #e1e8f2;
    border-radius: 9px;
    padding: 12px;
}

.paybox small {
    display: block;
    color: #66768b;
}

.paybox b {
    font-size: 22px;
}

.chart-bars {
    display: flex;
    gap: 7px;
    align-items: flex-end;
    height: 155px;
    border-bottom: 1px solid #b7c4d6;
    padding: 12px 2px 0;
    overflow-x: auto;
}

.chart-col {
    min-width: 36px;
    flex: 1;
    text-align: center;
    font-size: 10px;
    color: #64748b;
}

.chart-col .vbar {
    background: #df7a47;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    margin: auto;
    width: 24px;
}

.chart-col .vbar.zero {
    background: #b8d9c4;
}

.chip {
    font-size: 11px;
    border-radius: 6px;
    padding: 3px 7px;
    background: #e9eef7;
    display: inline-block;
}

.chip.late {
    background: #fff0d3;
    color: #8a5b00;
}

.chip.due {
    background: #ffe2e2;
    color: #a52828;
}

.ledger-collapse {
    margin-top: 16px;
    border: 1px solid #d6deea;
    border-radius: 10px;
    overflow: hidden;
}

.ledger-collapse summary {
    cursor: pointer;
    padding: 14px 16px;
    background: #f0f5fd;
    font-weight: 700;
    color: #203c6b;
    list-style-position: inside;
}

.paid-row td {
    background: #eaf3ef;
}

/* 로그인 화면 전용 */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #14233c 0%, #234173 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
    color: #14233c;
}

.error-box {
    background: #ffe5e5;
    color: #a52828;
    border: 1px solid #f5bcbc;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

@media (max-width: 900px) {
    .cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .two,
    .grid2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .pay-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    main {
        padding: 12px;
    }
    header {
        padding: 14px;
    }
}

/* ==========================================================================
   2단계 추가: 통합 고객 카르테 · 입금 입력 박스
   ========================================================================== */
.install-save {
    width: auto;
    min-width: 68px;
    padding: 6px 14px;
    align-self: flex-start;
}

.pay-entry {
    border: 1px solid #e2e8f2;
    background: #f9fbff;
    padding: 10px;
    border-radius: 9px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pay-entry input {
    padding: 7px 8px;
    border: 1px solid #ccd6e5;
    border-radius: 7px;
    width: 100%;
    max-width: 190px;
}

.payment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 3px 0;
    font-size: 12px;
}

.ledger-input-due {
    width: 142px;
    padding: 6px;
    border: 1px solid #cfd9e7;
    border-radius: 6px;
}

.ledger-input-amount {
    width: 105px;
    padding: 6px;
    border: 1px solid #cfd9e7;
    border-radius: 6px;
}

/* ==========================================================================
   3단계 추가: 4열 KPI 카드(경영 분석용)
   ========================================================================== */
.cards-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 900px) {
    .cards-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}