* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6fb;
  --border: #e3e8f0;
  --text: #1f2937;
  --muted: #6b7280;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* 상단바 */
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand .logo { color: var(--primary); font-size: 22px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* 로딩 */
.app-loading { display: flex; align-items: center; justify-content: center; height: 100vh; color: var(--muted); }

/* 로그인 화면 */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6fb 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 32px;
  width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 10px 40px rgba(37,99,235,0.12);
}
.login-logo { font-size: 44px; color: var(--primary); line-height: 1; }
.login-title { font-size: 20px; font-weight: 800; margin-top: 10px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.login-msg {
  background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
  border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px;
}
.login-card .form-group { text-align: left; margin-bottom: 14px; }
.login-error { color: #dc2626; font-size: 13px; min-height: 18px; margin-bottom: 8px; text-align: left; }
.login-btn { width: 100%; padding: 12px; font-size: 15px; }

/* 레이아웃 */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 280px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  flex-shrink: 0;
}
.sidebar-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.content { flex: 1; padding: 28px; overflow-x: auto; }

/* 병원 목록 */
.site-list { list-style: none; }
.site-item {
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background .15s;
  border: 1px solid transparent;
}
.site-item:hover { background: #f1f5fd; }
.site-item.active { background: #e8f0ff; border-color: #c7dbff; }
.site-item .name { font-weight: 600; font-size: 15px; }
.site-item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 버튼 */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all .15s;
  background: #eef1f6;
  color: var(--text);
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); filter: none; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--muted); }

/* 빈 상태 */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--muted);
  font-size: 15px;
}

/* 병원 상세 헤더 */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.detail-header h1 { font-size: 22px; margin-bottom: 4px; }
.detail-header .sub { color: var(--muted); font-size: 14px; }

/* 삽입 코드 박스 */
.embed-box {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  margin: 16px 0 24px;
  position: relative;
  word-break: break-all;
}
.embed-box .copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: #334155; color: #fff; border: none; border-radius: 6px;
  padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.embed-box .copy-btn:hover { background: #475569; }
.embed-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }

/* 팝업 테이블 */
.popup-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); table-layout: fixed; }
.popup-table th, .popup-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.popup-table th { background: #f8fafc; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.popup-table tbody tr { transition: background .12s; }
.popup-table tbody tr:hover { background: #f8fafc; }
.popup-table tr:last-child td { border-bottom: none; }

/* 컬럼 정렬 */
.popup-table .col-title { text-align: left; }
.popup-table .col-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popup-table .col-center { text-align: center; }
.popup-table .col-actions { text-align: right; white-space: nowrap; }
.popup-table .muted-text { color: #94a3b8; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-on { background: #dcfce7; color: #16a34a; }
.badge-off { background: #f1f5f9; color: #94a3b8; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 14px; }
.section-head h2 { font-size: 17px; }

/* 모달 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; padding: 26px;
}
.modal h2 { font-size: 19px; margin-bottom: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit;
}
.form-group textarea { min-height: 90px; resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 이미지 업로드 영역 */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: #fafbfe;
  cursor: pointer;
  transition: all .15s;
  overflow: hidden;
}
.upload-area:hover { border-color: var(--primary); background: #f3f7ff; }
.upload-area.dragging { border-color: var(--primary); background: #e8f0ff; }
.upload-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 28px 16px; text-align: center; color: var(--muted);
}
.upload-placeholder span { font-size: 14px; font-weight: 600; color: #475569; }
.upload-placeholder small { font-size: 12px; color: #94a3b8; }
.upload-preview { position: relative; background: #0f172a; text-align: center; }
.upload-preview img { max-width: 100%; max-height: 260px; display: inline-block; vertical-align: middle; }
.upload-remove {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.6); color: #fff; border: none; border-radius: 6px;
  padding: 5px 10px; font-size: 12px; cursor: pointer;
}
.upload-remove:hover { background: rgba(220,38,38,0.9); }

/* 즉시 노출 토글 스위치 */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.toggle-info { display: flex; flex-direction: column; gap: 2px; }
.toggle-title { font-size: 14px; font-weight: 700; color: #1f2937; }
.toggle-desc { font-size: 12px; color: var(--muted); }

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 30px;
  transition: background .25s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform .25s;
}
.switch input:checked + .switch-slider {
  background: var(--primary);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(22px);
}
.switch input:focus-visible + .switch-slider {
  box-shadow: 0 0 0 3px rgba(37,99,235,0.3);
}

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}
