/* ===== 기본 리셋 & 변수 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:      #3B82F6;
    --primary-d:    #2563EB;
    --danger:       #EF4444;
    --danger-d:     #DC2626;
    --success:      #10B981;
    --bg:           #F3F4F6;
    --white:        #FFFFFF;
    --border:       #E5E7EB;
    --text:         #111827;
    --text-light:   #6B7280;
    --shadow:       0 1px 3px rgba(0,0,0,.10);
    --shadow-lg:    0 8px 24px rgba(0,0,0,.14);
    --radius:       8px;
}

body {
    font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

.hidden { display: none !important; }

/* ===== 로그인 ===== */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.login-wrap { width: 100%; padding: 20px; }

.login-box {
    background: var(--white);
    border-radius: 16px;
    padding: 40px 36px;
    max-width: 420px;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
}

.login-box h1 {
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 6px;
}

.login-sub {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 28px;
}

/* ===== 헤더 ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 13px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.header h1 { font-size: 17px; font-weight: 700; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-email {
    font-size: 12px;
    color: var(--text-light);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== 메인 ===== */
.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ===== 통계 바 ===== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.stat-value.blue { color: var(--primary); }
.stat-value.red  { color: var(--danger); }

/* ===== 툴바 ===== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.search-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.select-sm {
    padding: 0 10px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--white);
    transition: border-color .15s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

/* ===== 테이블 ===== */
.table-wrap {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.table th {
    background: #F9FAFB;
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid #F3F4F6;
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FAFAFA; }

.empty-row {
    text-align: center;
    color: var(--text-light);
    padding: 48px 0 !important;
    font-size: 14px;
}

/* 고객명 링크 */
.name-link {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
    background: none;
    border: none;
    padding: 0;
    font-size: 14px;
    font-family: inherit;
}
.name-link:hover { text-decoration: underline; }

/* 상품 뱃지 */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-card   { background: #EFF6FF; color: #1D4ED8; }
.badge-small  { background: #F0FDF4; color: #15803D; }
.badge-gift   { background: #FFF7ED; color: #C2410C; }

.amount {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.col-writer { min-width: 80px; }

/* 작성자 표시 */
.writer-tag {
    font-size: 11px;
    color: var(--text-light);
    background: #F3F4F6;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
}

/* ===== 버튼 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 36px;
    padding: 0 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled { opacity: .5; cursor: default; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover  { background: var(--primary-d); }

.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:not(:disabled):hover { background: #F9FAFB; }

.btn-ghost { background: transparent; color: var(--text-light); }
.btn-ghost:not(:disabled):hover { background: #F3F4F6; color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:not(:disabled):hover { background: var(--danger-d); }

.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-full { width: 100%; }

.action-btns { display: flex; gap: 6px; }

/* ===== 폼 ===== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.req { color: var(--danger); margin-left: 1px; }

.form-group input,
.form-group select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--white);
    transition: border-color .15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-suffix {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--white);
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}

.input-suffix:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.input-suffix input {
    flex: 1;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0;
    text-align: right;
}

.input-suffix span {
    padding: 0 10px;
    color: var(--text-light);
    font-size: 14px;
    white-space: nowrap;
    background: #F9FAFB;
    border-left: 1px solid var(--border);
    height: 40px;
    display: flex;
    align-items: center;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
    padding-top: 4px;
}

.error-text {
    color: var(--danger);
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
    min-height: 20px;
}

/* ===== 모달 ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-box {
    background: var(--white);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modal-in .15s ease;
}

.modal-lg { max-width: 760px; }
.modal-sm { max-width: 380px; }

@keyframes modal-in {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.modal-head h2 { font-size: 17px; font-weight: 700; }
.modal-sub { font-size: 13px; color: var(--text-light); margin-top: 3px; }

.close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-light);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
    transition: background .15s;
}
.close-btn:hover { background: #F3F4F6; color: var(--text); }

.modal-body { padding: 20px 24px 24px; }

/* ===== 고객 내역 모달 ===== */
.history-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #EFF6FF;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.history-stats .hs-item span { color: var(--text-light); }
.history-stats .hs-item strong { color: var(--primary); margin-left: 4px; font-size: 15px; }

/* ===== 삭제 모달 ===== */
.confirm-text {
    text-align: center;
    line-height: 1.7;
    margin-bottom: 20px;
    color: var(--text);
}

/* ===== 토스트 ===== */
.toast {
    position: fixed;
    bottom: 28px;
    right: 24px;
    z-index: 9999;
    padding: 11px 20px;
    border-radius: 8px;
    background: #1F2937;
    color: #fff;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: toast-in .2s ease;
    max-width: 320px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* ===== 반응형 ===== */
@media (max-width: 760px) {
    .main { padding: 16px 12px; }
    .stats-bar { grid-template-columns: 1fr; gap: 10px; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-group { flex-wrap: wrap; }
    .search-input { min-width: 0; flex: 1 1 120px; }
    .form-row { grid-template-columns: 1fr; }
    .col-writer { display: none; }
    .modal-box { border-radius: 10px; }
    .header { padding: 12px 16px; }
}
