:root {
  --bg: #f4f5f7; --card: #fff; --border: #d9dde3; --text: #1f2430; --muted: #6b7280;
  --primary: #2f5fd0; --primary-dark: #244ba8; --accent: #fbe5d0; --danger: #d33; --ok: #1f9d55;
  --head: #eef1f5;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; }
a { color: var(--primary); }

/* 로그인 */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card); padding: 36px 32px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.08); width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0 0 8px; font-size: 20px; text-align: center; line-height: 1.4; }
.login-card h1 span { font-size: 15px; color: var(--muted); font-weight: normal; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; text-align: center; }

/* 레이아웃 */
.topbar { background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; min-height: 56px; gap: 24px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.topbar .brand { white-space: nowrap; }
.tabs button { white-space: nowrap; }
@media (max-width: 720px) { .topbar { gap: 8px; padding: 6px 12px; } .tabs { order: 3; width: 100%; } .tabs button { padding: 10px 12px; } .topbar .user { margin-left: auto; } }
.topbar .brand { font-weight: 700; font-size: 16px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { background: none; border: none; padding: 18px 16px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 600; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.topbar .user { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; }
main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }
.tabpane { display: none; }
.tabpane.active { display: block; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > .card { flex: 1 1 380px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.notice { background: #fff8e6; border: 1px solid #f3d58a; color: #7a5a00; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.notice.ok { background: #e9f8ef; border-color: #a7e0bd; color: #14562e; }

.btn { border: 1px solid var(--border); background: var(--card); padding: 7px 12px; border-radius: 7px; cursor: pointer; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

/* 폼 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; }
.form-grid label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-grid .wide { grid-column: 1 / -1; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
.radio-group { display: flex; gap: 10px; align-items: center; padding: 6px 0; color: var(--text); }
.radio-group label { display: flex; gap: 4px; align-items: center; font-size: 13px; }

/* 테이블 */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { border-bottom: 1px solid var(--border); padding: 7px 8px; text-align: left; vertical-align: middle; }
table.list th { background: var(--head); font-weight: 600; font-size: 12px; color: var(--muted); }
table.list tr:hover td { background: #fafbfc; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; background: #eef1f5; color: #444; }
.tag.예약 { background: #e3ecff; color: #244ba8; }
.tag.완료, .tag.발송, .tag.결제완료 { background: #e2f6ea; color: #14562e; }
.tag.취소, .tag.노쇼, .tag.실패, .tag.등록취소 { background: #fde4e4; color: #9b1c1c; }
.tag.등록예정, .tag.예정 { background: #fff2d9; color: #7a4b00; }

/* 달력 */
.calendar { background: var(--card); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 16px; overflow: hidden; }
.cal-head { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 12px; border-bottom: 1px solid var(--border); }
.cal-head .title { font-size: 18px; font-weight: 700; min-width: 140px; text-align: center; }
.cal-head button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-grid .dow { text-align: center; padding: 8px 0; font-size: 12px; color: var(--muted); background: var(--head); border-bottom: 1px solid var(--border); }
.cal-grid .dow:first-child, .cal-grid .day.sun .num { color: #d33; }
.cal-grid .dow:last-child, .cal-grid .day.sat .num { color: #2f5fd0; }
.cal-grid .day { min-height: 82px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.cal-grid .day:nth-child(7n) { border-right: none; }
.cal-grid .day.other { background: #fafafa; color: #bbb; cursor: default; }
.cal-grid .day:not(.other):hover { background: #f3f6fc; }
.cal-grid .day.selected { background: #e8efff; outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-grid .day.today .num { background: var(--primary); color: #fff; border-radius: 50%; }
.cal-grid .num { font-weight: 600; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.cal-grid .badge { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #e3ecff; color: #244ba8; width: fit-content; }
.cal-grid .badge.inq { background: #fff2d9; color: #7a4b00; }
.cal-grid .badge.reg { background: #e2f6ea; color: #14562e; }
@media (max-width: 640px) { .cal-grid .day { min-height: 58px; padding: 3px; } .cal-grid .badge { font-size: 10px; padding: 0 4px; } }

/* 보고서 (이미지 양식 재현) */
.report { background: #fff; border: 2px solid #222; max-width: 560px; margin: 0 auto; font-size: 13px; }
.report .rtitle { text-align: center; font-size: 20px; font-weight: 700; padding: 10px; border-bottom: 2px solid #222; }
.report table { width: 100%; border-collapse: collapse; }
.report td, .report th { border: 1px solid #222; padding: 6px 8px; }
.report th { font-weight: 600; text-align: center; background: #fff; width: 64px; }
.report td.lbl { width: 130px; }
.report td.num { width: 48px; text-align: center; font-weight: 600; }
.report td.cum { background: var(--accent); text-align: center; font-weight: 600; width: 70px; }
.report .status-td { min-height: 36px; }
.report .summary { padding: 12px 10px; line-height: 1.9; border-top: 2px solid #222; }
.report .summary .ln { display: flex; gap: 8px; }
.report .summary .ln .k { flex: 1; }
.report .summary .ln .v { min-width: 36px; text-align: right; font-weight: 600; }
.report .summary .ln .g { min-width: 120px; text-align: right; }
.report .summary .names { color: #333; padding-left: 4px; }
.report .editable { cursor: pointer; border-bottom: 1px dashed var(--primary); }
.report .editable:hover { background: #eef3ff; }
.report textarea.note { width: 100%; border: none; min-height: 40px; padding: 2px; background: #fffdf5; }

@media print {
  .topbar, .toolbar, .calendar, .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .report { border-width: 1px; max-width: none; }
}

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* SMS */
.subtabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.subtabs button { border: 1px solid var(--border); background: #fff; padding: 7px 14px; border-radius: 20px; cursor: pointer; }
.subtabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.subpane { display: none; }
.subpane.active { display: block; }
.recipient-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 7px; }
.recipient-list label { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid #eee; cursor: pointer; }
.recipient-list label:hover { background: #f7f9fc; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: #e3ecff; color: #244ba8; padding: 3px 10px; border-radius: 14px; font-size: 12px; display: flex; gap: 6px; align-items: center; }
.chip button { background: none; border: none; cursor: pointer; color: inherit; padding: 0; font-size: 14px; }
.bytes { font-size: 12px; color: var(--muted); text-align: right; }
.sched-item { display: grid; grid-template-columns: 200px 180px 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
@media (max-width: 760px) { .sched-item { grid-template-columns: 1fr; } }
.pre { white-space: pre-wrap; word-break: break-all; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 99; }
.toast.show { opacity: 1; }
