/* 메디셀플러스 상담 관리 — 관리자 화면 v7 (2026-10-19)
   디자인 시스템: Pretendard · Navy/Blue Primary · Neutral Gray · Semantic(Success/Warning/Danger/Info)
   제약: 외부 리소스 없음(CSP default-src 'none' / style-src 'self' / font-src 'self' / img-src 'self' data:), 인라인 style 속성 없음. */

/* ───────────── 1. 디자인 토큰 ───────────── */
:root {
  /* Brand / Primary */
  --navy-900: #131c46; --navy-800: #14294a;
  --blue-700: #2438ad; --blue-600: #2f46d6; --blue-100: #e3e8ff; --blue-50: #f1f4ff;
  /* Neutral */
  --gray-0: #ffffff; --gray-25: #fafbfc; --gray-50: #f5f6f8; --gray-100: #eef0f3; --gray-200: #e3e6eb; --gray-300: #cdd2da;
  --gray-400: #9aa1ad; --gray-500: #646c79; --gray-700: #3a414d; --gray-900: #151b26;
  /* Semantic (텍스트 색은 해당 배경에서 4.5:1 이상) */
  --success-700: #146c43; --success-50: #e8f6ee; --success-500: #22a061;
  --warning-700: #9a4a00; --warning-50: #fff3e3; --warning-500: #f08c1a;
  --danger-700:  #b42318; --danger-50:  #fdeeec; --danger-500:  #e5483d;
  --info-700:    #1f4fbf; --info-50:    #ebf2ff; --info-500:    #3b7bf6;
  --violet-700:  #5b34c7; --violet-50:  #f1ecff; --violet-500:  #8a63f0;
  /* Roles */
  --bg: var(--gray-50); --surface: var(--gray-0); --surface-sub: var(--gray-25);
  --border: var(--gray-200); --border-strong: var(--gray-300);
  --text: var(--gray-900); --text-2: var(--gray-700); --text-3: var(--gray-500); --text-disabled: var(--gray-400);
  --primary: var(--blue-600); --primary-hover: var(--blue-700); --primary-soft: var(--blue-50); --focus: rgba(47, 70, 214, .28);
  /* Spacing scale (4px 기반) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;
  /* Radius */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-full: 999px;
  /* Elevation */
  --sh-1: 0 1px 2px rgba(21, 27, 38, .05);
  --sh-2: 0 1px 2px rgba(21, 27, 38, .04), 0 4px 12px rgba(21, 27, 38, .05);
  --sh-3: 0 16px 48px rgba(19, 28, 70, .22), 0 2px 6px rgba(19, 28, 70, .08);
  /* Typography */
  --font: Pretendard, "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --fs-12: .75rem; --fs-13: .8125rem; --fs-14: .875rem; --fs-15: .9375rem; --fs-16: 1rem; --fs-18: 1.125rem; --fs-20: 1.25rem; --fs-24: 1.5rem; --fs-32: 2rem;
  /* Layout */
  --sidebar: 240px; --content-max: 1440px; --control-h: 40px;
}

/* ───────────── 2. 기본 ───────────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--fs-14); line-height: 1.5; letter-spacing: -.005em; -webkit-font-smoothing: antialiased; }
h1 { font-size: var(--fs-24); line-height: 1.3; font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2 { font-size: var(--fs-16); line-height: 1.4; font-weight: 700; letter-spacing: -.01em; margin: 0 0 var(--s3); }
p { margin: 0; }
strong { font-weight: 700; color: var(--text); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-3); } .small { font-size: var(--fs-13); } .center { text-align: center; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ───────────── 3. 컨트롤 ───────────── */
label { display: block; font-size: var(--fs-13); font-weight: 600; color: var(--text-2); }
input:not([type=checkbox]), select, textarea {
  display: block; width: 100%; min-width: 0; height: var(--control-h); margin-top: 6px; padding: 0 var(--s3);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface);
  font: inherit; font-size: var(--fs-14); font-weight: 400; color: var(--text); transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; min-height: 120px; padding: 10px var(--s3); resize: vertical; line-height: 1.6; }
select { padding-right: var(--s8); appearance: none; -webkit-appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23646c79' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
input::placeholder, textarea::placeholder { color: #868d99; }
input:hover, select:hover, textarea:hover { border-color: var(--gray-400); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--gray-50); color: var(--text-disabled); cursor: not-allowed; }
input[type=date] { font-variant-numeric: tabular-nums; }
.input-code { font-size: var(--fs-18) !important; letter-spacing: .2em; font-variant-numeric: tabular-nums; text-align: center; }
label > input, label > select, label > textarea { margin-top: 6px; }
label.check { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-sub); font-weight: 400; font-size: var(--fs-14); color: var(--text-2); cursor: pointer; }
label.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }
label.check em { font-style: normal; color: var(--warning-700); }

/* 버튼: primary(기본) · ghost · sm/lg · block */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: var(--control-h); padding: 0 var(--s4);
  border: 1px solid var(--primary); border-radius: var(--r-sm); background: var(--primary); color: #fff;
  font: inherit; font-size: var(--fs-14); font-weight: 600; white-space: nowrap; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--gray-100); border-color: var(--gray-200); color: var(--text-disabled); cursor: not-allowed; transform: none; }
.btn--ghost, .btn.alt { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn--ghost:hover, .btn.alt:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--text); }
.btn--ghost:disabled { background: var(--surface); }
.btn--sm { height: 32px; padding: 0 var(--s3); font-size: var(--fs-13); }
.btn--lg { height: 48px; font-size: var(--fs-15); }
.btn--block { width: 100%; }
.link { padding: 2px 0; border: 0; background: none; font: inherit; font-size: var(--fs-13); font-weight: 600; color: var(--primary); cursor: pointer; }
.link:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }
.link:disabled { color: var(--text-disabled); cursor: default; text-decoration: none; }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--text-3); font-size: 0; cursor: pointer; }
.icon-btn::before { content: "\2715"; font-size: 15px; line-height: 1; }
.icon-btn:hover { background: var(--gray-100); color: var(--text); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: var(--s2); margin-top: var(--s2); }

/* 알림 메시지 */
.msg { display: flex; gap: var(--s2); margin: var(--s3) 0 0; padding: 10px var(--s3); border-radius: var(--r-sm); font-size: var(--fs-13); line-height: 1.5; background: var(--danger-50); color: var(--danger-700); }
.msg::before { content: "!"; flex: none; display: grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: var(--r-full); background: var(--msg-ic, var(--danger-700)); color: #fff; font-size: 11px; font-weight: 800; }
.msg.ok { --msg-ic: var(--success-700); background: var(--success-50); color: var(--success-700); } .msg.ok::before { content: "\2713"; }
.msg.warn { --msg-ic: var(--warning-700); background: var(--warning-50); color: var(--warning-700); }
.note { background: var(--warning-50); border-color: #f6d7ad; color: var(--warning-700); word-break: break-all; font-size: var(--fs-13); }

/* 상태 배지 (Semantic) */
.tag { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-full); background: var(--gray-100); color: var(--text-2); font-size: var(--fs-12); font-weight: 600; white-space: nowrap; }
.tag[data-status]::before, .dot { content: ""; flex: none; width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }
.tag[data-status="상담요망"] { background: var(--warning-50); color: var(--warning-700); }
.tag[data-status="일정체크"] { background: var(--info-50); color: var(--info-700); }
.tag[data-status="방문예정"] { background: var(--violet-50); color: var(--violet-700); }
.tag[data-status="방문완료"] { background: var(--success-50); color: var(--success-700); }
.tag[data-status="TM부재중"] { background: var(--gray-100); color: var(--gray-700); }
.tag[data-status="TM미예약"] { background: var(--danger-50); color: var(--danger-700); }
.tag[data-status=""] { background: var(--surface); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--border-strong); }
.tag.on, .tag[data-delivery="sent"] { background: var(--success-50); color: var(--success-700); }
.tag.off, .tag[data-delivery="failed"], .tag[data-delivery="dead"] { background: var(--danger-50); color: var(--danger-700); }
.tag[data-delivery="pending"], .tag[data-delivery="retrying"] { background: var(--warning-50); color: var(--warning-700); }
/* 분포 막대·범례 색 */
.dot { display: inline-block; width: 8px; height: 8px; background: var(--gray-400); }
[data-status="상담요망"].dot, .dist-bar__seg[data-status="상담요망"] { background: var(--warning-500); }
[data-status="일정체크"].dot, .dist-bar__seg[data-status="일정체크"] { background: var(--info-500); }
[data-status="방문예정"].dot, .dist-bar__seg[data-status="방문예정"] { background: var(--violet-500); }
[data-status="방문완료"].dot, .dist-bar__seg[data-status="방문완료"] { background: var(--success-500); }
[data-status="TM부재중"].dot, .dist-bar__seg[data-status="TM부재중"] { background: var(--gray-400); }
[data-status="TM미예약"].dot, .dist-bar__seg[data-status="TM미예약"] { background: var(--danger-500); }
[data-status=""].dot, .dist-bar__seg[data-status=""] { background: var(--gray-300); }

/* 카드 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s6); margin-bottom: var(--s4); box-shadow: var(--sh-1); }
.card > h2 { margin-bottom: var(--s2); }
.card > h2 + .muted { margin-bottom: var(--s4); }

/* ───────────── 4. 레이아웃 ───────────── */
main { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s8) var(--s10) var(--s12); }
.boot { padding: 30vh 0 0; text-align: center; color: var(--text-3); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s6); }
.page-head p { margin-top: var(--s1); font-size: var(--fs-14); }
.page-head__action { flex: none; }
.footnote { margin-top: var(--s8); padding-top: var(--s4); border-top: 1px solid var(--border); text-align: center; color: var(--text-3); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s4); align-items: start; }
.grid-2 > .card, .stack-cards > .card { margin-bottom: 0; }
.stack-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.grid-2 + .card { margin-top: var(--s4); }

/* 사이드바 / 상단 메뉴 */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--s6); min-height: 60px; padding: 0 var(--s6); background: var(--surface); border-bottom: 1px solid var(--border); }
.top__brand { display: flex; align-items: center; gap: var(--s3); flex: none; }
.top__logo { display: block; height: 26px; width: auto; }
.top__product { font-size: var(--fs-12); font-weight: 700; color: var(--text-3); letter-spacing: .02em; white-space: nowrap; }
.top__tabs { display: flex; gap: var(--s1); flex: 1; overflow-x: auto; scrollbar-width: none; }
.top__tabs::-webkit-scrollbar { display: none; }
.top__tabs button { position: relative; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 var(--s3); border: 0; border-radius: var(--r-md); background: none; font: inherit; font-size: var(--fs-14); font-weight: 600; color: var(--text-3); white-space: nowrap; cursor: pointer; transition: background .12s, color .12s; }
.top__tabs button::before { content: ""; flex: none; width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--ic) no-repeat center / contain; mask: var(--ic) no-repeat center / contain; }
.top__tabs button:hover { background: var(--gray-50); color: var(--text); }
.top__tabs button[aria-selected="true"] { background: var(--primary-soft); color: var(--blue-700); }
.top__tabs button[data-tab="list"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='3' width='16' height='18' rx='2.5'/%3E%3Cpath d='M8 8h8M8 12h8M8 16h5'/%3E%3C/svg%3E"); }
.top__tabs button[data-tab="new"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v8M8 12h8'/%3E%3C/svg%3E"); }
.top__tabs button[data-tab="notify"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15z'/%3E%3Cpath d='M10 20a2 2 0 0 0 4 0'/%3E%3C/svg%3E"); }
.top__tabs button[data-tab="users"] { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3.5'/%3E%3Cpath d='M2.5 20a6.5 6.5 0 0 1 13 0'/%3E%3Cpath d='M16 4.5a3.5 3.5 0 0 1 0 7M18.5 20a6 6 0 0 0-3-5.2'/%3E%3C/svg%3E"); }
.top__user { display: flex; align-items: center; gap: var(--s3); flex: none; min-width: 0; }
.avatar { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: var(--r-full); background: var(--navy-900); color: #fff; font-size: var(--fs-13); font-weight: 700; }
.top__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.top__who #who { font-size: var(--fs-13); font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top__role { font-size: var(--fs-12); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 1024px) {
  .top { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); flex-direction: column; align-items: stretch; gap: 0; padding: var(--s6) var(--s4) var(--s4); border-bottom: 0; border-right: 1px solid var(--border); overflow-y: auto; }
  .top__brand { flex-direction: column; align-items: flex-start; gap: var(--s2); padding: 0 var(--s2) var(--s6); }
  .top__tabs { flex: 1; flex-direction: column; gap: 2px; overflow: visible; }
  .top__tabs::before { content: "메뉴"; padding: 0 var(--s3) var(--s2); font-size: var(--fs-12); font-weight: 600; color: var(--text-3); }
  .top__tabs button { width: 100%; text-align: left; }
  .top__tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: calc(var(--s4) * -1); top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
  .top__user { flex-wrap: wrap; gap: var(--s3); padding: var(--s4) var(--s2) 0; border-top: 1px solid var(--border); }
  .top__who { flex: 1; }
  .top__user .btn { width: 100%; }
  body:has(> header#top:not([hidden])) main { width: auto; margin-left: var(--sidebar); max-width: none; }
  body:has(> header#top:not([hidden])) main > * { max-width: var(--content-max); margin-left: auto; margin-right: auto; }
}

/* ───────────── 5. 상담 목록 ───────────── */
/* 통계: 핵심 KPI 2개 + 처리상태 분포 1개 */
.stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2.4fr); gap: var(--s4); margin-bottom: var(--s4); }
.kpi { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; padding: var(--s5) var(--s6); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.kpi__label { font-size: var(--fs-13); font-weight: 600; color: var(--text-3); }
.kpi__value { font-size: var(--fs-32); line-height: 1.15; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi__unit { font-size: var(--fs-13); color: var(--text-3); }
.kpi:not(.kpi--dist) { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-content: space-between; column-gap: 6px; }
.kpi:not(.kpi--dist) .kpi__label { grid-column: 1 / -1; }
.kpi:not(.kpi--dist) .kpi__unit { align-self: end; padding-bottom: 6px; }
.kpi--primary { background: var(--navy-900); border-color: var(--navy-900); box-shadow: 0 6px 20px rgba(19, 28, 70, .18); }
.kpi--primary .kpi__label { color: #c9d2ff; } .kpi--primary .kpi__value { color: #fff; } .kpi--primary .kpi__unit { color: #c9d2ff; }
.kpi--dist { gap: var(--s3); }
.kpi__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.kpi__meta { font-size: var(--fs-13); font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.kpi__empty { color: var(--text-3); font-size: var(--fs-13); padding: var(--s2) 0; }
.dist-bar { display: flex; gap: 2px; height: 10px; border-radius: var(--r-full); overflow: hidden; background: var(--gray-100); }
.dist-bar__seg { min-width: 4px; }
.dist-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: var(--s2) var(--s4); margin: 0; padding: 0; list-style: none; }
.dist-legend li { display: flex; align-items: center; gap: var(--s2); min-width: 0; font-size: var(--fs-13); color: var(--text-2); }
.dist-legend__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-legend b { font-variant-numeric: tabular-nums; color: var(--text); }

/* 검색 필터: 한 줄 툴바 */
.filters { display: grid; grid-template-columns: minmax(280px, 1.6fr) repeat(3, minmax(120px, 1fr)) auto; gap: var(--s3); align-items: end; margin-bottom: var(--s4); padding: var(--s4) var(--s5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.field { min-width: 0; font-size: var(--fs-12); font-weight: 600; color: var(--text-3); }
.field__label { display: block; }
.field--hidden { display: none; }
.range { display: flex; align-items: center; gap: var(--s2); margin-top: 6px; }
.range input { margin-top: 0; }
.range__sep { color: var(--text-3); }
.filters__actions { display: flex; gap: var(--s2); }

/* 데이터 테이블 */
.table-card { padding: 0; overflow: hidden; }
.table-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.table-card__count { flex: none; font-size: var(--fs-13); font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.status-tabs { display: flex; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.status-tabs::-webkit-scrollbar { display: none; }
.status-tabs button { flex: none; height: 32px; padding: 0 var(--s3); border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); font: inherit; font-size: var(--fs-13); font-weight: 600; color: var(--text-2); cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.status-tabs button:hover { border-color: var(--gray-400); color: var(--text); }
.status-tabs button[aria-selected="true"] { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.table-scroll { position: relative; overflow-x: auto; }
.table-scroll--flush { margin: var(--s3) calc(var(--s6) * -1) 0; border-top: 1px solid var(--border); }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.tbl th { height: 40px; padding: 0 var(--s4); background: var(--surface-sub); border-bottom: 1px solid var(--border); text-align: left; font-size: var(--fs-12); font-weight: 600; color: var(--text-3); white-space: nowrap; }
.tbl td { height: 52px; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--gray-100); vertical-align: middle; white-space: nowrap; color: var(--text-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--gray-25); }
.table-scroll--flush .tbl th:first-child, .table-scroll--flush .tbl td:first-child { padding-left: var(--s6); }
.table-scroll--flush .tbl th:last-child, .table-scroll--flush .tbl td:last-child { padding-right: var(--s6); }
.tbl td.muted { color: var(--text-3); }
.tbl select { width: auto; height: 32px; margin: 0; padding: 0 var(--s8) 0 var(--s2); font-size: var(--fs-13); }
.tbl td .link + .link { margin-left: var(--s3); }
/* 상담 목록 열 */
.tbl--leads th:first-child, .tbl--leads td:first-child { padding-left: var(--s5); }
.tbl--leads th:last-child, .tbl--leads td:last-child { padding-right: var(--s5); width: 1%; }
.tbl--leads tbody tr.is-clickable { cursor: pointer; }
.tbl--leads tbody tr:hover { background: var(--blue-50); }
.c-date { font-variant-numeric: tabular-nums; }
.c-date__d { color: var(--text); font-weight: 500; }
.c-date__t { margin-left: var(--s2); color: var(--text-3); }
.c-name { color: var(--text) !important; font-weight: 700; }
.c-phone { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.src { display: inline-block; padding: 2px 8px; border-radius: var(--r-sm); background: var(--gray-100); font-size: var(--fs-12); font-weight: 600; color: var(--text-2); }
.row-btn { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); font: inherit; font-size: var(--fs-13); font-weight: 600; color: var(--text-2); cursor: pointer; transition: all .12s; }
.row-btn::after { content: ""; width: 12px; height: 12px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E") no-repeat center / contain; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E") no-repeat center / contain; }
.tbl--leads tbody tr:hover .row-btn, .row-btn:hover { border-color: var(--primary); background: var(--primary); color: #fff; }
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s12) var(--s4); text-align: center; color: var(--text-3); }
.empty strong { font-size: var(--fs-15); color: var(--text-2); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); background: var(--surface-sub); }
.pager:empty { display: none; }
.pager__info { margin-right: var(--s2); font-size: var(--fs-13); color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ───────────── 6. 폼·알림·계정 ───────────── */
/* 상담 수동 등록: 컴팩트 폼(최대 920px, 가운데) */
#p-new > .page-head, #p-new > .form-card { width: 100%; max-width: 920px; margin-left: auto; margin-right: auto; }
#p-new > .page-head { margin-bottom: var(--s5); }
.form-card { padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s5); padding: var(--s6) var(--s6) var(--s5); }
.form-grid .span-2 { grid-column: 1 / -1; }
#f-new textarea { height: 160px; min-height: 96px; max-height: 480px; overflow-y: auto; resize: vertical; }
#f-new label.check { padding: 10px var(--s4); font-size: var(--fs-13); line-height: 1.55; }
#f-new label.check input { margin-top: 1px; }
.form-card > .msg { margin: 0 var(--s6) var(--s4); }
.form-card__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s6); border-top: 1px solid var(--border); background: var(--surface-sub); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.form-card__foot::before { content: "필수: 이름 · 연락처 · 동의 확인"; font-size: var(--fs-12); color: var(--text-3); }
.form-card__foot .btn { min-width: 120px; }
.inline { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: end; }
.inline h2.full { flex-basis: 100%; margin: 0; }
.inline label { flex: 1 1 180px; }
#f-recipient { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: 9rem minmax(0, 1fr); margin: 0 0 var(--s4); }
.kv dt, .kv dd { padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.kv dt { font-size: var(--fs-13); color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-all; white-space: pre-wrap; }
#n-status h2 { margin-bottom: var(--s3); }
#n-status .msg { margin: 0 0 var(--s3); }

/* ───────────── 7. 인증 화면 ───────────── */
body:has(> header#top[hidden]) { background: var(--bg) linear-gradient(var(--navy-900), var(--navy-900)) no-repeat top / 100% 36vh; }
.narrow { width: 100%; max-width: 420px; margin: 12vh auto 0; padding: var(--s10) var(--s8) var(--s8); border: 0; border-radius: var(--r-lg); box-shadow: var(--sh-3); }
.narrow--wide { max-width: 520px; }
.narrow::before { content: ""; display: block; height: 28px; margin-bottom: var(--s8); background: url("medicell-logo.svg") no-repeat left center / contain; }
.narrow h1 { font-size: var(--fs-24); margin-bottom: var(--s2); }
.narrow > p.muted { margin-bottom: var(--s6); font-size: var(--fs-14); }
.narrow form > label { margin-bottom: var(--s4); }
.narrow form > .btn { margin-top: var(--s2); }
.narrow h2 { margin-top: var(--s2); }
.narrow__foot { margin-top: var(--s5); text-align: center; }
.secret { display: inline-block; padding: 4px 8px; border-radius: var(--r-sm); background: var(--primary-soft); color: var(--navy-900); font-size: var(--fs-16); letter-spacing: .08em; }
.uri { display: block; margin-bottom: var(--s4); padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--gray-50); font-size: var(--fs-12); color: var(--text-3); word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); margin: var(--s4) 0 var(--s6); padding: 0; list-style: none; }
.codes li { padding: var(--s2); border: 1px dashed var(--border-strong); border-radius: var(--r-sm); background: var(--gray-25); font-family: ui-monospace, Consolas, monospace; text-align: center; }

/* ───────────── 8. 상담 상세(다이얼로그) ───────────── */
dialog { width: min(680px, 94vw); max-height: 88vh; padding: 0; border: 0; border-radius: var(--r-lg); box-shadow: var(--sh-3); color: var(--text); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(21, 27, 38, .48); }
.dlg__close { position: absolute; top: var(--s4); right: var(--s4); margin: 0; z-index: 2; }
#dlg-body { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
#dlg-body > h2 { order: 0; margin: 0; padding: var(--s6) var(--s12) 0 var(--s6); font-size: var(--fs-20); }
#dlg-body > .dlg-meta { order: 1; display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s6) var(--s4); border-bottom: 1px solid var(--border); font-size: var(--fs-13); color: var(--text-3); font-variant-numeric: tabular-nums; }
#dlg-body > p.small { order: 2; margin: var(--s4) var(--s6) 0; padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--info-50); color: var(--info-700); font-size: var(--fs-12); font-weight: 600; }
#dlg-body > .kv { order: 3; margin: var(--s2) var(--s6) 0; grid-template-columns: 7rem minmax(0, 1fr); }
#dlg-body > .kv dd:nth-of-type(2), #dlg-body > .kv dd:nth-of-type(3) { font-size: var(--fs-16); font-weight: 700; font-variant-numeric: tabular-nums; }
#dlg-body > .kv dd:nth-of-type(6) { padding: var(--s3); margin: var(--s2) 0; border: 0; border-radius: var(--r-md); background: var(--gray-50); line-height: 1.7; min-height: 72px; }
#dlg-body > .kv dt:nth-of-type(6) { padding-top: calc(var(--s2) + var(--s3)); }
#dlg-body > .kv dd:last-of-type, #dlg-body > .kv dt:last-of-type { border-bottom: 0; font-size: var(--fs-13); color: var(--text-3); }
#dlg-body > label { order: 4; margin: var(--s4) var(--s6) 0; }
#dlg-body > .msg { order: 6; margin: var(--s3) var(--s6) 0; }
#dlg-body > .row { order: 7; position: sticky; bottom: 0; flex-direction: row-reverse; justify-content: flex-start; gap: var(--s2); margin-top: var(--s6); padding: var(--s4) var(--s6); border-top: 1px solid var(--border); background: var(--surface-sub); }
#dlg-body > .row .btn { min-width: 112px; }
#dlg-body > .row .link { height: var(--control-h); padding: 0 var(--s4); border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text-2); }
#dlg-body > .row .link:hover { background: var(--gray-50); text-decoration: none; color: var(--text); }

/* 상담 메모 */
#dlg-body > .notes { order: 5; margin: var(--s5) var(--s6) 0; padding-top: var(--s4); border-top: 1px solid var(--border); }
.notes__head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.notes__head h3 { margin: 0; font-size: var(--fs-15); font-weight: 700; }
.notes__count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--gray-100); font-size: var(--fs-12); font-weight: 700; line-height: 20px; text-align: center; color: var(--text-2); }
.notes__count:empty { display: none; }
.notes__hint { margin-left: auto; font-size: var(--fs-12); color: var(--text-3); }
.notes__form { border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.notes__form:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.notes__form textarea { margin: 0; min-height: 76px; height: 76px; border: 0; border-radius: var(--r-md) var(--r-md) 0 0; box-shadow: none !important; resize: vertical; }
.notes__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 6px 6px 6px var(--s3); border-top: 1px solid var(--gray-100); }
.notes__len { font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }
.notes .msg { margin-top: var(--s2); }
.notes__list { margin: var(--s3) 0 0; padding: 0; list-style: none; display: grid; gap: var(--s2); }
.note-item { padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--gray-50); }
.note-item__meta { display: flex; align-items: center; gap: var(--s2); margin-bottom: 4px; font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }
.note-item__author { font-weight: 700; color: var(--text-2); }
.note-item__at::before { content: "·"; margin-right: var(--s2); }
.note-item__body { margin: 0; font-size: var(--fs-14); line-height: 1.6; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.notes__empty { padding: var(--s3) 0; font-size: var(--fs-13); color: var(--text-3); text-align: center; }

/* ───────────── 9. 반응형 ───────────── */
@media (max-width: 1279px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi--dist { grid-column: 1 / -1; }
  .filters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .filters > .field--range { grid-column: span 3; }
  .filters > label.field:nth-of-type(1) { grid-column: span 3; }
  .filters > label.field:nth-of-type(2), .filters > label.field:nth-of-type(3) { grid-column: span 2; }
  .filters__actions { grid-column: span 2; }
  .filters__actions .btn { flex: 1; }
}
@media (min-width: 1024px) and (max-width: 1279px) { main { padding: var(--s6) var(--s6) var(--s10); } }
@media (max-width: 1023px) {
  main { padding: var(--s6) var(--s6) var(--s10); }
  .top { padding: 0 var(--s4); gap: var(--s4); }
  .top__product { display: none; }
  .top__who { display: none; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  html { font-size: 16px; }
  main { padding: var(--s5) var(--s4) var(--s10); }
  .top { flex-wrap: wrap; min-height: 0; padding: var(--s3) var(--s4) 0; gap: 0 var(--s3); }
  .top__brand { flex: 1; }
  .top__logo { height: 22px; }
  .avatar { display: none; }
  .top__tabs { order: 3; flex-basis: 100%; margin: var(--s2) calc(var(--s4) * -1) 0; padding: 0 var(--s2) var(--s2); }
  .top__tabs button { height: 36px; padding: 0 var(--s3); }
  .page-head { align-items: flex-start; flex-direction: column; gap: var(--s3); margin-bottom: var(--s5); }
  .page-head__action { width: 100%; }
  h1 { font-size: var(--fs-20); }
  .kpi { padding: var(--s4); }
  .kpi__value { font-size: 1.75rem; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: var(--s4); }
  .filters > .field--range, .filters__actions { grid-column: 1 / -1 !important; }
  .filters > label.field:nth-of-type(1), .filters > label.field:nth-of-type(2), .filters > label.field:nth-of-type(3) { grid-column: span 1; }
  .filters > label.field:nth-of-type(3) { grid-column: 1 / -1; }
  .filters__actions .btn { flex: 1; }
  .table-card__head { flex-direction: column; align-items: stretch; gap: var(--s2); padding: var(--s3); }
  .table-card__count { align-self: flex-end; }
  /* 목록: 표 대신 카드형 행 */
  .tbl--leads thead { display: none; }
  .tbl--leads, .tbl--leads tbody { display: block; }
  .tbl--leads tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name status" "phone act" "date act" "src act"; gap: 2px var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--gray-100); }
  .tbl--leads td { display: block; height: auto; padding: 0 !important; border: 0; white-space: normal; }
  .tbl--leads td:nth-child(1) { grid-area: date; font-size: var(--fs-13); }
  .tbl--leads td:nth-child(2) { grid-area: name; font-size: var(--fs-15); }
  .tbl--leads td:nth-child(3) { grid-area: phone; }
  .tbl--leads td:nth-child(4) { grid-area: src; margin-top: 4px; }
  .tbl--leads td:nth-child(5) { grid-area: status; justify-self: end; }
  .tbl--leads td:nth-child(6) { grid-area: act; align-self: center; justify-self: end; width: auto; }
  .card { padding: var(--s5); }
  .table-scroll--flush { margin-left: calc(var(--s5) * -1); margin-right: calc(var(--s5) * -1); }
  .form-grid { grid-template-columns: 1fr; gap: var(--s4); padding: var(--s5); }
  .form-card__foot { padding: var(--s4) var(--s5); } .form-card__foot::before { display: none; } .form-card__foot .btn { width: 100%; }
  .form-card > .msg { margin: 0 var(--s5) var(--s4); }
  .kv { grid-template-columns: 6.5rem minmax(0, 1fr); }
  body:has(> header#top[hidden]) { background-size: 100% 28vh; }
  .narrow { margin-top: 8vh; padding: var(--s8) var(--s6) var(--s6); }
  dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  #dlg-body > h2 { padding-left: var(--s5); } #dlg-body > .dlg-meta { padding: var(--s2) var(--s5) var(--s4); }
  #dlg-body > p.small, #dlg-body > .kv, #dlg-body > label, #dlg-body > .msg, #dlg-body > .notes { margin-left: var(--s5); margin-right: var(--s5); }
  .notes__hint { display: none; }
  #dlg-body > .kv { grid-template-columns: 5.5rem minmax(0, 1fr); }
  #dlg-body > .row { padding: var(--s3) var(--s5); } #dlg-body > .row .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* 수동 등록 동의 확인(2026-10-19): 항목별 4개, 2열 */
#f-new .consent-set { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2) var(--s3); margin: 0; padding: 0; border: 0; min-width: 0; }
#f-new .consent-set legend { grid-column: 1 / -1; padding: 0; margin-bottom: var(--s2); font-size: var(--fs-14); font-weight: 600; color: var(--text); }
#f-new .consent-set legend .muted { margin-left: var(--s2); font-size: var(--fs-13); font-weight: 400; }
#f-new .consent-set label.check { margin: 0; }
#f-new .consent-set label.check b { color: var(--text); font-weight: 600; }
#f-new .consent-set input:disabled + span { opacity: .55; }
@media (max-width: 767px) { #f-new .consent-set { grid-template-columns: 1fr; } }
/* 2026-10-20 환자 접수 확인 문자 설정 */
#n-enable label.check + label.check { margin-top: var(--s3); }
#n-enable #f-ack-max { margin-top: var(--s3); }
#f-login .muted.small { margin-top: var(--s3); }
/* 2026-10-20 계정 관리: 좁은 화면에서도 관리 버튼(비밀번호 초기화 등)이 보이게 행 아래 줄로 */
#u-table tr.u-act-row { display: none; }
@media (max-width: 1180px) {
  #u-table th.u-act-h, #u-table td.u-act-inline { display: none; }
  #u-table tr.u-act-row { display: table-row; }
  #u-table tr.u-act-row td { padding-top: 0; border-top: 0; }
  #u-table .u-act-wrap { position: sticky; left: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); max-width: calc(100vw - 2 * var(--s6)); }
}
/* 2026-10-20 MFA 등록: 단계 안내·QR 코드 */
.enroll-steps { margin: var(--s4) 0 var(--s5); padding-left: 1.4em; display: grid; gap: var(--s2); font-size: var(--fs-14); color: var(--text-2); }
.enroll-steps li { line-height: 1.6; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: var(--s2); margin: var(--s2) 0 var(--s4); }
.qr-box canvas { width: 232px; height: 232px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-md); image-rendering: pixelated; }
