/* ==========================================================================
   REBEAUTY PHOTO — 관리자 (밝은 테마)
   자체 완결 파일. 외부 @import·CDN 없음.
   1) 토큰  2) 리셋  3) 타이포  4) 버튼/폼  5) 배지/칩  6) 표  7) 카드/그리드
   8) 통계타일  9) 페이지네이션  10) 패싯  11) 빈 상태  12) 토스트
   13) 셸(헤더/사이드바/컨텐츠)  14) 로그인 2단 분할  15) 라이트박스
   16) 병원 에셋(.hosp-*)  17) 반응형
   ========================================================================== */

/* ── 1. 토큰 (밝은 테마로 오버라이드) ────────────────────────────────────── */
:root {
  --bg: #f5f6f8;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --dim: #9ca3af;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);

  --accent: #e0507a;
  --accent-2: #7c5cff;
  --ok: #2fbf71;
  --warn: #f0a63c;
  --danger: #ef4d5a;

  --k-cut: #e0507a;
  --k-hero: #4aa8ff;
  --k-face: #2fbf71;
  --k-style: #b07cff;

  --radius: 12px;
  --radius-sm: 8px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --header-h: 56px;
  --sidebar-w: 248px;
  --pad: 24px;
  --gap: 16px;

  /* 어두운 브랜드 패널(로그인 1열·헤더)에서 쓰는 값 */
  --brand-bg: #12141a;
  --brand-text: #e8eaee;
}

/* ── 2. 리셋 ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
img, svg, video { max-width: 100%; }
img { border-style: none; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d3d7de; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #bcc2cc; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── 3. 타이포 ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; letter-spacing: -.02em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono, .num, code, kbd { font-family: var(--mono); font-variant-numeric: tabular-nums; }
code {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 6px; font-size: .88em;
}
pre {
  margin: 0; padding: 12px 14px; overflow: auto;
  background: #0e1117; color: #d7dbe3; border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-pad { padding: 18px 20px; }
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h2, .panel-head h3 { font-size: 14px; }
.panel-head .spacer { flex: 1 1 auto; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.section { margin-bottom: 22px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 10px; }

/* ── 4. 버튼 / 폼 ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .03);
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: #d3d7de; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #d2456e; border-color: #d2456e; color: #fff; }
.btn-dark { background: #1f2430; border-color: #1f2430; color: #fff; }
.btn-dark:hover { background: #2b3140; border-color: #2b3140; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: #fff; border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 8%, #fff); color: var(--danger); }
.btn-sm { min-height: 28px; padding: 0 9px; font-size: 12px; }
.btn-lg { min-height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }

.input, .select, .textarea, input[type="text"], input[type="search"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 36px; padding: 6px 11px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--dim); }
input[disabled], select[disabled], textarea[disabled] { background: var(--surface-2); color: var(--muted); }
select {
  appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 11px;
}
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--dim); }
.field .err { font-size: 12px; color: var(--danger); }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 18px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.toolbar .spacer { flex: 1 1 auto; }
.toolbar .count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 14px;
}
.filter-bar .field { min-width: 130px; }

/* ── 5. 배지 / 칩 ────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; font-weight: 700; line-height: 1.7; white-space: nowrap;
}
.badge-kind {
  --k: var(--muted);
  color: color-mix(in srgb, var(--k) 78%, #000);
  border-color: color-mix(in srgb, var(--k) 38%, transparent);
  background: color-mix(in srgb, var(--k) 13%, #fff);
}
.badge-kind::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--k); flex: none; }
.badge-ok { color: #157a45; border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 12%, #fff); }
.badge-warn { color: #96601a; border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 14%, #fff); }
.badge-danger { color: #a72330; border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 11%, #fff); }
.badge-num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.chip:hover { color: var(--text); border-color: #d3d7de; }
.chip.is-on { color: var(--text); background: color-mix(in srgb, var(--accent) 10%, #fff); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: 12px;
}
.tag b { color: var(--text); font-weight: 600; }

/* ── 6. 표 (행이 많다: sticky thead, 줄무늬 없음, hover 강조) ────────────── */
.table-wrap {
  width: 100%;
  max-height: calc(100vh - var(--header-h) - 210px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.table-wrap.is-auto { max-height: none; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  letter-spacing: .01em;
  box-shadow: inset 0 -1px 0 var(--border);
  border-bottom: 0;
}
.table thead th a { color: inherit; }
.table thead th a:hover { color: var(--accent); }
.table tbody tr { background: var(--surface); }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, #fff); }
.table tbody tr.is-selected { background: color-mix(in srgb, var(--accent) 9%, #fff); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num, .table .num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.table td.nowrap, .table th.nowrap { white-space: nowrap; }
.table td.tight { width: 1%; white-space: nowrap; }
.table .thumb-cell { width: 1%; padding: 4px 8px 4px 12px; }
.table .thumb-cell img {
  display: block; width: 56px; height: 56px; object-fit: cover;
  border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border);
}
.table caption { caption-side: bottom; padding: 8px 12px; font-size: 12px; color: var(--dim); text-align: left; }
.table-empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ── 7. 카드 / 그리드 ────────────────────────────────────────────────────── */
.gallery-grid, .image-grid, .masonry { column-count: 5; column-gap: var(--gap); }
.gallery-grid > *, .image-grid > *, .masonry > * {
  break-inside: avoid; -webkit-column-break-inside: avoid; page-break-inside: avoid;
  display: block; margin: 0 0 var(--gap);
}
.gallery-grid.cols-3, .image-grid.cols-3 { column-count: 3; }
.gallery-grid.cols-4, .image-grid.cols-4 { column-count: 4; }
.gallery-grid.cols-6, .image-grid.cols-6 { column-count: 6; }

.card-grid, .tile-grid, .grid-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--gap);
}
.card-grid.sm, .tile-grid.sm { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.card-grid.lg, .tile-grid.lg { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { border-color: #d3d7de; transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, .09); }
.card:focus-within { border-color: var(--accent); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.card.is-hidden-item { opacity: .55; }
.card-link { display: block; color: inherit; }
.card-link:hover { color: inherit; }

.card-media { position: relative; display: block; width: 100%; background: var(--surface-2); overflow: hidden; }
.card-media img { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--surface-2); transition: transform .3s ease; }
.card:hover .card-media img { transform: scale(1.03); }
.card-media img.is-fallback { object-fit: contain; padding: 12%; opacity: .75; }

.card-kind {
  position: absolute; top: 7px; left: 7px; z-index: 2;
  background: color-mix(in srgb, var(--k, var(--muted)) 30%, rgba(12, 14, 18, .78));
  border-color: transparent; color: #fff;
}
.card-flags { position: absolute; top: 7px; right: 7px; z-index: 2; display: flex; gap: 4px; }
.card-flag {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: rgba(12, 14, 18, .72); font-size: 12px; line-height: 1; color: #fff;
}
.card-flag.on-featured { color: var(--warn); }
.card-flag.on-hidden { color: #ff8a92; }

.card-check { position: absolute; top: 7px; left: 7px; z-index: 3; width: 20px; height: 20px; margin: 0; cursor: pointer; }
.card.has-check .card-kind { left: 34px; }

.card-over {
  position: absolute; inset: auto 0 0 0; z-index: 2;
  display: flex; flex-direction: column; gap: 1px;
  padding: 24px 10px 9px;
  background: linear-gradient(to top, rgba(8, 9, 12, .9) 12%, rgba(8, 9, 12, .5) 55%, transparent);
  opacity: 0; transform: translateY(6px);
  transition: opacity .16s ease, transform .16s ease;
  pointer-events: none;
}
.card:hover .card-over, .card:focus-within .card-over { opacity: 1; transform: none; }
.card-model { font-size: 12.5px; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; align-items: center; gap: 7px; font-size: 11px; color: rgba(255, 255, 255, .78); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.card-meta .sep { opacity: .5; }
.card-body { padding: 9px 11px 11px; }
.card-title { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-size: 11.5px; color: var(--muted); }
@media (hover: none) { .card-over { opacity: 1; transform: none; } }

/* ── 8. 통계 타일 ────────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat {
  --stat-accent: var(--accent);
  display: block; position: relative; padding: 13px 15px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--stat-accent); }
a.stat:hover { border-color: #d3d7de; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, .08); color: inherit; }
.stat-label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-value {
  display: block; margin-top: 1px;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 23px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em;
}
.stat-sub { display: block; font-size: 11.5px; color: var(--dim); }

.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.meter > span { display: block; height: 100%; background: var(--accent); }

/* ── 9. 페이지네이션 ─────────────────────────────────────────────────────── */
.pager { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 20px 0 6px; }
.pager-list { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; }
.pager-link, .pager-gap {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background .15s, border-color .15s, color .15s;
}
.pager-link:hover { background: var(--surface-2); border-color: #d3d7de; color: var(--text); }
.pager-link[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; cursor: default; }
.pager-gap { background: transparent; border-color: transparent; color: var(--dim); min-width: 22px; padding: 0 2px; }
.pager-edge.is-off { opacity: .35; pointer-events: none; }
.pager-info { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

.loadmore { display: flex; justify-content: center; margin: 20px 0; }
.loadmore .btn { min-width: 180px; }
.loadmore-done { color: var(--dim); font-size: 12.5px; }

/* ── 10. 패싯 ────────────────────────────────────────────────────────────── */
.facets { display: flex; flex-direction: column; gap: 9px; }
.facet { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.facet > summary {
  display: flex; align-items: center; gap: 8px; padding: 10px 13px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; list-style: none; user-select: none;
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::after {
  content: ""; margin-left: auto; width: 7px; height: 7px; flex: none;
  border-right: 2px solid var(--dim); border-bottom: 2px solid var(--dim);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform .18s;
}
.facet[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.facet > summary:hover { background: var(--surface-2); }
.facet-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11px; font-family: var(--mono);
}
.facet-list { max-height: 272px; overflow-y: auto; padding: 2px 5px 7px; }
.facet-opt { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: var(--radius-sm); font-size: 12.5px; color: var(--muted); }
.facet-opt:hover { background: var(--surface-2); color: var(--text); }
.facet-box { flex: none; width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid #c8ccd4; background: #fff; position: relative; }
.facet-opt.is-on { color: var(--text); font-weight: 600; }
.facet-opt.is-on .facet-box { background: var(--accent); border-color: var(--accent); }
.facet-opt.is-on .facet-box::after {
  content: ""; position: absolute; left: 4px; top: .5px; width: 4px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(43deg);
}
.facet-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-n { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.facet-clear { display: block; padding: 6px 13px 10px; font-size: 12px; color: var(--dim); }
.facet-clear:hover { color: var(--accent); }
.facet-empty { padding: 7px 13px 11px; font-size: 12px; color: var(--dim); }

.with-facets { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 20px; align-items: start; }
.with-facets > aside { position: sticky; top: calc(var(--header-h) + 14px); }

/* ── 11. 빈 상태 ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px;
  padding: 52px 24px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface);
}
.empty-state svg { width: 40px; height: 40px; color: var(--dim); margin-bottom: 2px; }
.empty-state h3 { font-size: 15px; }
.empty-state p { color: var(--muted); font-size: 13px; max-width: 46ch; }
.empty-state .btn { margin-top: 8px; }

/* ── 12. 토스트 ──────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; z-index: 90; top: calc(var(--header-h) + 12px); right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  width: min(360px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  --tone: var(--accent-2);
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--tone);
  border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  font-size: 13px; pointer-events: auto; animation: toast-in .22s ease both;
}
.toast.is-out { animation: toast-out .2s ease both; }
.toast-success { --tone: var(--ok); }
.toast-error { --tone: var(--danger); }
.toast-info { --tone: var(--accent-2); }
.toast-msg { flex: 1 1 auto; }
.toast-close { flex: none; background: none; border: 0; padding: 0 2px; color: var(--dim); font-size: 17px; line-height: 1; }
.toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(14px); } }

/* ── 13. 셸: 고정 헤더 + 좌측 사이드바(248px) + 100% 폭 컨텐츠 ──────────── */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; padding: 9px 13px; background: var(--accent); color: #fff; border-radius: var(--radius-sm); }
.skip-link:focus { top: 10px; color: #fff; }

.admin-header {
  position: fixed; inset: 0 0 auto 0; z-index: 70;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: var(--brand-bg);
  color: var(--brand-text);
  border-bottom: 1px solid #232833;
}
.admin-header a { color: inherit; }
.admin-brand { display: flex; align-items: baseline; gap: 8px; flex: none; }
.admin-brand b {
  font-size: 15px; font-weight: 800; letter-spacing: .06em;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.admin-brand span { font-size: 11.5px; color: #8b93a1; letter-spacing: .02em; }
.admin-header .spacer { flex: 1 1 auto; }
.admin-header .hdr-meta { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: #a8b0bd; }
.admin-header .hdr-user { color: #fff; font-weight: 600; }
.admin-header .hdr-login { font-family: var(--mono); font-size: 11.5px; color: #7c8492; }
.admin-header .hdr-site {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid #2c323d; color: #c3c9d4; font-size: 12px;
}
.admin-header .hdr-site:hover { border-color: #3d4552; color: #fff; }
.btn-logout {
  min-height: 30px; padding: 0 12px; font-size: 12.5px; font-weight: 600;
  background: transparent; color: #c3c9d4;
  border: 1px solid #2c323d; border-radius: var(--radius-sm); box-shadow: none;
}
.btn-logout:hover { background: #232833; color: #fff; border-color: #3d4552; }

.drawer-btn {
  display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: none;
  background: transparent; border: 1px solid #2c323d; border-radius: var(--radius-sm); color: #c3c9d4;
}
.drawer-btn:hover { background: #232833; color: #fff; }
.drawer-btn svg { width: 18px; height: 18px; }

.admin-sidebar {
  position: fixed; z-index: 65;
  top: var(--header-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 10px 28px;
  transition: transform .22s ease;
}
.nav-section { margin-top: 14px; }
.nav-section:first-child { margin-top: 2px; }
.nav-section > h3 {
  padding: 0 10px 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .1em;
  color: var(--dim); text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: #3f4756; font-size: 13.5px; font-weight: 600;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item svg { width: 17px; height: 17px; flex: none; color: var(--dim); }
.nav-item:hover svg { color: var(--muted); }
.nav-item.is-active {
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: color-mix(in srgb, var(--accent) 82%, #000);
}
.nav-item.is-active svg { color: var(--accent); }
.nav-item.is-active .nav-label { font-weight: 700; }
.nav-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge {
  flex: none; padding: 0 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 17px;
}
.nav-item.is-active .nav-badge { background: #fff; border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent); }
.nav-badge.warn { color: #96601a; border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 14%, #fff); }
.sidebar-foot { margin-top: 18px; padding: 10px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--dim); }

.drawer-backdrop {
  position: fixed; inset: var(--header-h) 0 0 0; z-index: 64;
  background: rgba(15, 18, 24, .45);
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}

.admin-body {
  padding-top: var(--header-h);
  padding-left: var(--sidebar-w);
  min-height: 100vh;
}
/* 컨텐츠 영역: width 100%, max-width 없음. 좌우 패딩 24px만. */
.admin-main {
  width: 100%;
  max-width: none;
  padding: 18px var(--pad) 48px;
}
.admin-page-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  margin-bottom: 16px;
}
.admin-page-head .titles { min-width: 0; }
.admin-page-head h1 { font-size: 21px; }
.admin-actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: 12px; color: var(--dim); margin-bottom: 3px; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .6; }
.crumbs .cur { color: var(--muted); }

/* ── 14. 로그인 2단 분할 (layouts/auth.php) ──────────────────────────────── */
.auth {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}
.auth-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  gap: 22px; padding: 56px clamp(32px, 6vw, 80px);
  color: var(--brand-text);
  background:
    radial-gradient(1100px 620px at 12% 8%, rgba(224, 80, 122, .30), transparent 62%),
    radial-gradient(900px 620px at 88% 92%, rgba(124, 92, 255, .28), transparent 60%),
    linear-gradient(160deg, #14161d 0%, #0e0f12 55%, #101319 100%);
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(120% 90% at 50% 40%, #000 25%, transparent 78%);
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-mark { display: flex; align-items: baseline; gap: 10px; }
.auth-mark b {
  font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; letter-spacing: .08em;
  background: linear-gradient(92deg, #ff7ba3, #9b83ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-mark span { font-size: 12px; letter-spacing: .16em; color: #8b93a1; }
.auth-tagline { font-size: clamp(15px, 1.4vw, 18px); line-height: 1.7; color: #c3c9d4; max-width: 34ch; }
.auth-stats { display: flex; flex-wrap: wrap; gap: 10px 32px; padding-top: 6px; }
.auth-stat { min-width: 96px; }
.auth-stat .n {
  display: block; font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(20px, 2.2vw, 26px); font-weight: 700; color: #fff; line-height: 1.2;
}
.auth-stat .t { display: block; font-size: 12px; color: #8b93a1; }
.auth-note { font-size: 12px; color: #6b7280; }

.auth-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 40px clamp(24px, 5vw, 64px);
  background: #fff;
}
.auth-form-wrap { width: 100%; max-width: 372px; }
.auth-form-wrap h1 { font-size: 20px; margin-bottom: 4px; }
.auth-form-wrap .auth-sub { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.auth-form-wrap .field { margin-bottom: 14px; }
.auth-form-wrap .btn-lg { margin-top: 6px; }
.auth-error {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; margin-bottom: 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, #fff);
  color: #a72330; border-radius: var(--radius-sm); font-size: 13px;
}
.auth-foot { margin-top: 22px; font-size: 12px; color: var(--dim); }

/* ── 15. 라이트박스 ──────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 7, 9, .93); padding: 32px;
  animation: fade-in .16s ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.lightbox img { max-width: 100%; max-height: 100%; width: auto; height: auto; border-radius: var(--radius-sm); }
.lightbox-cap { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: 13px; color: rgba(255, 255, 255, .8); padding: 0 60px; }
.lightbox-btn {
  position: absolute; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, .1); border: 0; color: #fff; font-size: 22px; line-height: 1;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, .2); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
body.lb-open { overflow: hidden; }

/* 상세 공통 */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.detail-stage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; justify-content: center; }
.detail-stage img { display: block; width: auto; max-width: 100%; height: auto; max-height: 72vh; border-radius: var(--radius-sm); }
.detail-side { position: sticky; top: calc(var(--header-h) + 14px); display: flex; flex-direction: column; gap: 14px; }
.kv { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { color: var(--text); font-variant-numeric: tabular-nums; }
.copy-row { display: flex; gap: 7px; align-items: center; }
.copy-row input { font-family: var(--mono); font-size: 12px; }

/* 유틸 */
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1 1 auto; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hide { display: none !important; }

/* ── 16. 병원 에셋 (.hosp-*) ─────────────────────────────────────────────── */
/* 이 API 는 썸네일을 주지 않는다. 목록 미리보기도 2K 원본(장당 평균 2.18MB)이라
   화면 밖 그리드는 렌더를 건너뛰고, 표 미리보기는 아주 작게 눌러 쓴다. */
.hosp-grid {
  content-visibility: auto;
  contain-intrinsic-size: auto 1000px;
}
.hosp-grid > * { contain: layout style; }

/* .table .thumb-cell img 가 56×56 로 강제하므로 같은 자리(0,3,1)에서 다시 눌러준다. */
.table .thumb-cell img.hosp-thumb { width: 96px; height: 54px; }
.table .thumb-cell img.hosp-cover { width: 120px; height: 68px; }

/* 셀 안 보조 설명 — alt_text · 관리 메모 · 해시 앞자리 */
.hosp-note {
  display: block; margin-top: 2px;
  font-size: 11.5px; line-height: 1.45; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis;
}

/* 분포 막대 — 진료과·배치 위치 표에서 쓰는 인라인 미니 게이지 */
.hosp-bar {
  display: inline-block; vertical-align: middle;
  width: 110px; height: 7px; margin-right: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); overflow: hidden;
}
.hosp-bar-fill { display: block; height: 100%; min-width: 2px; background: var(--accent); border-radius: 999px; }

/* 일괄 처리 바 — 선택이 없으면 흐리게, JS 가 .is-on 을 켜면 또렷하게.
   (JS 가 없어도 버튼은 그대로 눌린다 — 숨기지 않는 이유다) */
.hosp-bulkbar {
  position: sticky; bottom: 12px; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: var(--gap);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  opacity: .62;
  transition: opacity .16s, border-color .16s;
}
.hosp-bulkbar.is-on { opacity: 1; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.hosp-bulkbar-space { height: 6px; }

/* 상세의 전체 컬럼 덤프 — 값이 길어도 표가 밀리지 않게 고정 레이아웃 */
.hosp-dump { table-layout: fixed; }
.hosp-dump th {
  width: 170px; vertical-align: top; white-space: nowrap;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.hosp-dump td { font-family: var(--mono); font-size: 11.5px; word-break: break-all; }

/* 상태 토글 버튼 묶음 */
.hosp-flagform { display: flex; flex-wrap: wrap; gap: 8px; }

/* 바탕이 된 참고 이미지 — 외부 사이트의 사진이라 점선으로 구분한다 */
.hosp-source {
  display: block; height: auto;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* ── 17. 반응형 ──────────────────────────────────────────────────────────── */
@media (max-width: 1440px) {
  .gallery-grid, .image-grid, .masonry { column-count: 4; }
  /* .cols-N 은 특이도가 (0,2,0) 이라 위 규칙만으로는 눌리지 않는다. 같은 특이도로 상한을 건다. */
  .gallery-grid.cols-6, .image-grid.cols-6 { column-count: 4; }
  .detail { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1024px) {
  .drawer-btn { display: inline-flex; }
  .admin-sidebar { transform: translateX(-100%); box-shadow: 0 12px 40px rgba(0, 0, 0, .18); }
  .admin-body { padding-left: 0; }
  body.drawer-open .admin-sidebar { transform: none; }
  body.drawer-open .drawer-backdrop { opacity: 1; visibility: visible; }
  body.drawer-open { overflow: hidden; }
  .gallery-grid, .image-grid, .masonry { column-count: 3; }
  .gallery-grid.cols-4, .image-grid.cols-4,
  .gallery-grid.cols-6, .image-grid.cols-6 { column-count: 3; }
  .with-facets { grid-template-columns: minmax(0, 1fr); }
  .with-facets > aside { position: static; }
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail-side { position: static; }
  .table-wrap { max-height: none; }
}
@media (max-width: 768px) {
  :root { --pad: 16px; }
  .admin-header { gap: 10px; padding: 0 12px; }
  .admin-header .hdr-login, .admin-header .hdr-site { display: none; }
  .admin-brand span { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); min-height: auto; }
  .auth-brand { padding: 32px 24px; gap: 14px; }
  .auth-brand::after { display: none; }
  .auth-tagline { font-size: 14px; max-width: none; }
  .auth-stats { gap: 8px 22px; }
  .auth-panel { padding: 32px 24px 48px; min-height: 62vh; }
  .gallery-grid, .image-grid, .masonry { column-count: 2; }
  .gallery-grid.cols-3, .image-grid.cols-3,
  .gallery-grid.cols-4, .image-grid.cols-4,
  .gallery-grid.cols-6, .image-grid.cols-6 { column-count: 2; }
  .card-grid, .tile-grid, .grid-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .toasts { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; }
  .admin-actions { margin-left: 0; width: 100%; }
}
@media (max-width: 480px) {
  :root { --gap: 10px; --pad: 12px; }
  .admin-header .hdr-meta { gap: 8px; }
  .admin-header .hdr-user { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .gallery-grid, .image-grid, .masonry { column-count: 2; }
  .gallery-grid.cols-3, .image-grid.cols-3,
  .gallery-grid.cols-4, .image-grid.cols-4,
  .gallery-grid.cols-6, .image-grid.cols-6 { column-count: 2; }
  .kv { grid-template-columns: 88px minmax(0, 1fr); }
  .lightbox { padding: 12px; }
  /* 좁은 화면에서는 표 미리보기·분포 막대를 줄인다 (0,3,1)/(0,1,0) 특이도 유지 */
  .table .thumb-cell img.hosp-thumb { width: 72px; height: 41px; }
  .table .thumb-cell img.hosp-cover { width: 84px; height: 48px; }
  .hosp-bar { width: 72px; }
  .hosp-dump th { width: 120px; }
}
