:root {
    /* 미니멀 화이트용 팔레트 */
    --brand: #0c5a2a;
    --ink: #111;
    --muted: #6b7280;
    --line: #eaeaea;
    --line-strong: #e5e7eb;
    --bg: #ffffff;         /* 화면 배경도 화이트 */
    --panel: #ffffff;      /* 카드/패널 배경 */
    --btn: #0f766e;
    --btn-del: #b91c1c;
}

/* ===== 기본 세팅 ===== */
* { box-sizing: border-box; }
html, body { height: auto; }
body {
    font-family: "Pretendard Variable","Noto Sans KR",system-ui,-apple-system,Segoe UI,Roboto,"Malgun Gothic",sans-serif;
    color: var(--ink);
    background: var(--bg);
    margin: 0;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;

    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "lnum" 1;
    line-height: 1.5;
}

/* ===== 헤더: 미니멀 화이트 =====
   (현재 <header> 그대로 사용해도 깔끔하게 보임)
*/
header {
    background: #fff;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-weight: 700;
    letter-spacing: -0.2px;
    font-size: 16px;
}

/* (선택) 인스타 감성의 심플 탑바 레이아웃을 원할 경우, header 대신 .topbar 사용 가능 */
.topbar {
    position: sticky; top: 0; z-index: 10;
    background: #fff;
    border-bottom: 1px solid var(--line);
    height: 56px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
}
.topbar .brand {
    font-weight: 800; letter-spacing: -0.3px; font-size: 16px;
}
.topbar .actions { display: flex; gap: 8px; }

/* ===== 레이아웃 & 카드 ===== */
.container {
    max-width: 1000px;
    margin: 24px auto 32px;
    padding: 0 16px;
}
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}
.grid { display: grid; gap: 10px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.mt8 { margin-top: 8px; }

/* ===== 라벨 ===== */
.label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 500;
}

/* ===== 입력 필드 ===== */
input[type="text"],
input[type="date"],
input[type="email"],
textarea,
select {
    width: 100%;
    height: 36px;
    border: 1px solid var(--line-strong);
    background: #fff;
    border-radius: 8px;
    padding: 0 10px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    transition: box-shadow .15s, border-color .15s;
}
textarea { height: auto; min-height: 80px; padding: 8px 10px; }
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #cbd5e1;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .08);
}

/* ===== 행 구성 ===== */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-right { justify-content: flex-end; }

/* ===== 버튼 ===== */
.toolbar { display: flex; gap: 8px; margin-bottom: 8px; }
.btn {
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn.primary {
    background: #0f766e;
    border-color: #0f766e;
    color: #fff;
}
.btn.primary:hover { background: #0d5a58; border-color: #0d5a58; }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.danger:hover { background: #991b1b; border-color: #991b1b; }

/* ===== 테이블 ===== */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
}
thead th {
    background: #fbfbfb;
    font-weight: 700;
    text-align: center;
    color: #222;
}
th, td {
    border-bottom: 1px solid var(--line);
    padding: 10px 10px;
    text-align: left;
    font-size: 14px;
    line-height: 1.4;
}
td.num, th.num { text-align: right; }

/* 합계 라인 */
.sumline {
    display: grid;
    grid-template-columns: 1.2fr .8fr 1fr;
    gap: 10px;
    margin-top: 8px;
}
.sumline input[readonly] { background: #f6f7f9; }

/* 품목 테이블(에디터 셀) */
#grid td[contenteditable="true"] {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 8px;
    background: #fff;
    min-height: 30px;
}
#grid td[contenteditable="true"]:focus {
    outline: 0;
    border-color: #cbd5e1;
    box-shadow: inset 0 0 0 2px rgba(15,118,110,.12);
    background: #fcfffd;
}

/* ===== 모달 ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(17, 24, 39, 0.45);
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal-content {
    width: min(950px, 96vw);
    max-height: 92vh;
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    padding: 16px 16px 12px;
    box-shadow: 0 24px 80px rgba(0,0,0,.16);
    border: 1px solid var(--line);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 4px 12px;
    border-bottom: 1px solid var(--line);
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    margin-top: 12px;
}
.close {
    background: none;
    border: 0;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
}

/* ===== 프리뷰 표(가독성만 살짝) ===== */
#billPreviewArea .items table td { height: 28px; padding: 10px 8px; }
#billPreviewArea .items table th { padding: 10px 8px; }

/* ===== 비고란 ===== */
.remarks3 {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    max-width: 100%;
    font-size: 13px;
}
.remarks3 .row { display: grid; gap: 0; }
.remarks3 .row-top {
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--line);
}
.remarks3 .row-bottom { grid-template-columns: 1fr; }
.remarks3 .cell {
    padding: 8px 10px;
    border-right: 1px solid var(--line);
}
.remarks3 .row-top .cell:last-child { border-right: 0; }
.remarks3 .cell.fixed .text {
    font-weight: 600;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.35;
    word-break: keep-all;
}
.remarks3 .label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 6px;
}
.remarks3 input[type="text"],
.remarks3 textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.35;
    background: #fff;
    transition: box-shadow .15s, border-color .15s;
}
.remarks3 input[type="text"]::placeholder,
.remarks3 textarea::placeholder { color: #9aa0a6; }
.remarks3 input[type="text"]:focus,
.remarks3 textarea:focus {
    outline: none;
    border-color: #cbd5e1;
    box-shadow: 0 0 0 3px rgba(15,118,110,.08);
}
.remarks3 textarea { min-height: 40px; resize: vertical; }

/* 모바일 */
@media (max-width: 680px) {
    .container { padding: 0 12px; }
    .grid.cols-2 { grid-template-columns: 1fr; }
    .remarks3 .row-top { grid-template-columns: 1fr; }
    .remarks3 .row-top .cell {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .remarks3 .row-top .cell:last-child { border-bottom: 0; }
}

/* ===== 인쇄 전용 ===== */
@media print {
    header, .container { display: none !important; }
    .modal {
        display: block !important;
        position: static !important;
        inset: auto !important;
        background: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .modal-content {
        position: static !important;
        width: 210mm !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 auto !important;
        box-shadow: none !important;
        border: 0;
    }
    .modal-header, .modal-footer { display: none !important; }
}
