* {
    box-sizing: border-box;
}

body {
    margin: 0;

    background: #f8f6f5;

    color: #222;

    font-family: var(--font-sans);
}

/* =========================
   페이지
========================= */

.grid-page {

    width: 100%;

    max-width: 1400px;

    margin: 0 auto;

    padding: 30px;
}


/* =========================
   Header
========================= */

.grid-header {

    display: flex;

    justify-content: space-between;

    align-items: flex-start;

    gap: 20px;

    margin-top: 20px;
    margin-bottom: 20px;
}

.grid-header h1 {

    margin: 0;

    font-size: 26px;

    font-weight: 700;

    letter-spacing: -0.01em;
}

.grid-header p {

    margin: 7px 0 0;

    color: #6E6762;

    font-size: 14px;

    line-height: 1.6;
}

/* 샘플 상단 안내 문구 강조 */
.grid-header p.sample-notice {

    display: inline-block;

    margin-top: 10px;

    padding: 10px 14px;

    border-left: 4px solid #FF4700;

    border-radius: 0 8px 8px 0;

    background: #FFEDE5;

    color: #4A3A33;

    font-size: 14px;

    line-height: 1.6;
}

.grid-header p.sample-notice strong {

    color: #C43A00;

    font-weight: 700;
}


/* =========================

   Toolbar
========================= */

.grid-toolbar {

    display: flex;

    flex-wrap: wrap;

    gap: 6px;
}

.grid-toolbar button {

    height: 36px;

    padding: 0 14px;

    border: 1px solid #E7E1DC;

    border-radius: 999px;

    background: #fff;

    color: #333;

    cursor: pointer;

    font-size: 13px;

    font-weight: 600;

    white-space: nowrap;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.grid-toolbar button:hover {

    background: #F7F4F1;

    border-color: #D9D2CC;
}

.grid-toolbar .primary {

    border-color: #FF4700;

    background: #FF4700;

    color: #fff;
}

.grid-toolbar .primary:hover {

    background: #E03E00;

    border-color: #E03E00;
}

.grid-toolbar .unmerge {

    border-color: #F1B9A8;

    background: #FFF1EB;

    color: #C43A00;
}

.grid-toolbar .unmerge:hover {

    background: #FFE3D8;
}

.grid-toolbar .save {

    border-color: #2f9e44;

    background: #2f9e44;

    color: #fff;
}


/* =========================
   Grid Wrapper (카드)
========================= */

.grid-wrapper {

    width: 100%;

    overflow: auto;

    padding: 6px;

    border: 1px solid #E7E1DC;

    border-radius: 16px;

    background: #fff;

    box-shadow: 0 8px 28px rgba(20, 17, 16, 0.06);
}


/* =========================
   Table
========================= */

.gridTable {

    border-collapse: separate;

    border-spacing: 0;

    table-layout: fixed;

    min-width: 100%;

    width: max-content;

    user-select: none;
}

.gridTable td {

    min-width: 130px;

    width: 130px;

    height: 52px;

    padding: 0;

    border: 0;

    border-right: 1px solid #F1ECE8;

    border-bottom: 1px solid #EDE7E2;

    background: #fff;

    position: relative;

    vertical-align: middle;

    transition: background-color 0.12s ease;
}

.gridTable tr > td:last-child {

    border-right: 0;
}

.gridTable tr:last-child > td {

    border-bottom: 0;
}

/* 모서리 둥글게 */
.gridTable td[data-row="0"][data-column="0"] {
    border-top-left-radius: 10px;
}
.gridTable tr:first-child > td:last-child {
    border-top-right-radius: 10px;
}
.gridTable tr:last-child > td:first-child {
    border-bottom-left-radius: 10px;
}
.gridTable tr:last-child > td:last-child {
    border-bottom-right-radius: 10px;
}

/* 지브라 (읽기 전용 샘플) */
#sampleBody tr:nth-child(even) > td {

    background: #FCFAF9;
}

/* 첫 열: 라벨 느낌 */
.gridTable td[data-column="0"],
.gridTable td[data-column="0"].merged {

    background: #F7F4F1;
}

.gridTable td[data-column="0"] .grid-cell-input {

    font-weight: 600;

    color: #141110;
}

/* 첫 행: 헤더 느낌 (지브라/첫 열보다 뒤에 두어 우선 적용) */
.gridTable td[data-row="0"],
.gridTable td[data-row="0"].merged {

    background: #FFEDE5;

    border-bottom: 1px solid #FFD5C2;
}

.gridTable td[data-row="0"] .grid-cell-input {

    font-weight: 700;

    color: #B83300;

    letter-spacing: -0.01em;
}

/* 읽기 전용 샘플 행 hover */
#sampleBody tr:hover > td {

    background: #FFF7F2;
}

#sampleBody tr:hover > td[data-row="0"] {

    background: #FFEDE5;
}


/* =========================
   Cell input
========================= */

.grid-cell-input {

    display: block;

    width: 100%;

    height: auto;   /* 세로 병합 셀에서 td의 vertical-align: middle 로 가운데 정렬되도록 */

    min-height: 52px;

    padding: 14px 12px;

    border: 0;

    outline: none;

    resize: none;

    background: transparent;

    color: #2B2624;

    font-family: inherit;

    font-variant-numeric: tabular-nums;

    font-size: 14px;

    line-height: 1.5;

    text-align: center;

    overflow: hidden;
}

.grid-cell-input::placeholder {

    color: #C9C1BB;
}

#sampleBody .grid-cell-input {

    cursor: default;
}

.grid-cell-input:focus {

    background: #FFF7F2;
}


/* =========================
   선택된 셀
========================= */

.gridTable td.selected {

    background: #FFEDE5;

    box-shadow:
        inset 0 0 0 2px #FF4700;

    z-index: 2;
}


/* =========================
   병합 셀
========================= */

.gridTable td.merged {

    background: #FFFDFC;
}

/* =========================
   셀 드래그
========================= */
#gridBody td {
    touch-action: none;
    user-select: none;
}
#gridBody td.selected {
    background: #FFEDE5;
    box-shadow: inset 0 0 0 2px #FF4700;
}

#gridBody td.selected textarea {
    background: transparent;
}


/* =========================
   수정화면 가리기
========================= */
#grid-active.hidden {
    display: none;
}


/* =========================
   옵션 선택
========================= */
.grid-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;

    margin-top: 20px;
}

/* 체크박스 버튼 */
.option-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;

    min-height: 45px;
    padding: 8px 12px;

    box-sizing: border-box;

    border: 1px solid #E7E1DC;
    border-radius: 10px;

    background: #fff;

    cursor: pointer;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease;
}

/* 실제 체크박스는 표시 */
.option-item input[type="checkbox"] {
    width: 17px;
    height: 17px;

    margin: 0;

    cursor: pointer;

    accent-color: #FF4700;
}

/* 체크된 버튼 */
.option-item:has(input:checked) {
    background: #FFF7F2;
    border-color: #FF4700;
}

/* 기타 입력 영역 */
.other-input-wrap {
    grid-column: 1 / -1;

    display: none;

    width: 100%;

    padding: 12px 16px;

    box-sizing: border-box;

    border: 1px solid #E7E1DC;
    border-radius: 10px;

    background: #FAF8F6;
}

/* 기타 input */
.other-input-wrap input {
    display: block;

    width: 100%;
    height: 40px;

    padding: 0 12px;

    box-sizing: border-box;

    border: 1px solid #D9D2CC;
    border-radius: 6px;

    background: #fff;

    font-size: 14px;
    color: #333;

    outline: none;
}

.other-input-wrap input:focus {
    border-color: #FF4700;
}

/* =========================
   모바일
========================= */

@media (max-width: 768px) {

    .grid-page {

        padding: 16px;
    }

    .grid-header {

        flex-direction: column;
    }

    .grid-toolbar {

        width: 100%;
    }

    .grid-toolbar button {

        flex: 1;
    }

    /* "마케팅 플랜 만들기" 버튼이 있는 헤더는 모바일에서도 가로 배치 유지 → 항상 우측 상단 */
    .grid-header:has(#show-btn) {

        flex-direction: row;

        align-items: flex-start;

        gap: 12px;
    }

    .grid-header:has(#show-btn) > div:first-child {

        flex: 1 1 auto;

        min-width: 0;
    }

    .grid-header:has(#show-btn) .grid-toolbar {

        width: auto;

        flex: 0 0 auto;
    }

    #show-btn {

        flex: 0 0 auto;

        height: 40px;

        padding: 0 14px;

        font-size: 13px;
    }

    .gridTable td {

        min-width: 110px;

        width: 110px;
    }

    #inquiry-submit {
        pointer-events: none;
        opacity: 0.5;
    }

    .grid-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .option-item {
        justify-content: flex-start;
        padding: 8px 12px;
        font-size: 14px;
    }

    .option-other {
        grid-column: span 1;
    }

}
