/* ============================================================
   AVA Patient Kit — 통합 환자 정보 모달 (Smart Doctor reference)
   _common/patient_kit.js 와 한 쌍
   ============================================================ */

#ava-pm-root { display: none; }
#ava-pm-root.open { display: block; }

#ava-pm-root .ava-pm-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 16, 10, 0.55);
  backdrop-filter: blur(2px);
  z-index: 99000;
}

#ava-pm-root .ava-pm-card {
  position: fixed;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(96vw, 1480px);
  height: min(94vh, 880px);
  background: #fdfaf6;
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  z-index: 99001;
  display: flex; flex-direction: column;
  overflow: hidden;
  font-family: 'Pretendard Variable', 'Pretendard', system-ui, sans-serif;
  color: #2a2418;
}

#ava-pm-root .ava-pm-header {
  flex-shrink: 0;
  padding: 12px 18px;
  background: linear-gradient(180deg, #f3ece0, #ece2d0);
  border-bottom: 1px solid #d8ccb4;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
  flex-wrap: wrap;
  gap: 8px;
}
/* 📌 환자 sticky 메모 */
#ava-pm-root .ava-pm-sticky-note {
  flex: 1 1 100%;
  display: flex; align-items: center; gap: 6px;
  background: #fffae0;
  border: 1px dashed #d4a85a;
  border-radius: 6px;
  padding: 4px 10px;
  margin-top: 6px;
}
#ava-pm-root .ava-pm-sticky-note.has-note {
  background: #fff5c8;
  border-style: solid;
  box-shadow: 0 1px 4px rgba(212,168,90,.25);
}
#ava-pm-root .ava-pm-sticky-note .pin { font-size: 13px; }
#ava-pm-root .ava-pm-sticky-note input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-family: inherit; font-size: 12px; color: #5a4020;
  padding: 4px 0;
}
#ava-pm-root .ava-pm-sticky-note input::placeholder { color: #c0a878; font-style: italic; }

/* 📋 동의서 history bar */
#ava-pm-root .ava-pm-consent-bar {
  flex: 1 1 100%;
  display: flex; flex-direction: column;
  background: #f0e8f8;
  border: 1px solid #b9a3d5;
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 6px;
  font-size: 11.5px;
  color: #4a3070;
}
#ava-pm-root .ava-pm-consent-bar .cs-icon { font-size: 13px; }
#ava-pm-root .ava-pm-consent-bar > .cs-icon,
#ava-pm-root .ava-pm-consent-bar > .cs-text,
#ava-pm-root .ava-pm-consent-bar > .cs-toggle {
  display: inline-flex; align-items: center; gap: 6px;
}
#ava-pm-root .ava-pm-consent-bar > .cs-text { font-weight: 600; flex: 1; padding: 0 8px; }
#ava-pm-root .ava-pm-consent-bar > .cs-toggle {
  background: transparent; border: 1px solid #b9a3d5; border-radius: 4px;
  padding: 0 8px; cursor: pointer; font-size: 11px; color: #4a3070;
}
#ava-pm-root .ava-pm-consent-bar > .cs-toggle:hover { background: #fff; }
#ava-pm-root .ava-pm-consent-bar { display: flex !important; flex-direction: row !important; flex-wrap: wrap; align-items: center; }
#ava-pm-root .ava-pm-consent-bar .cs-list {
  flex: 1 1 100%;
  margin-top: 8px;
  background: #fff;
  border-radius: 4px;
  padding: 6px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #d0c2e0;
}
#ava-pm-root .ava-pm-consent-bar .cs-item {
  padding: 6px 9px;
  border-bottom: 1px dashed #e6dcef;
  font-size: 11px;
}
#ava-pm-root .ava-pm-consent-bar .cs-item:last-child { border-bottom: 0; }
#ava-pm-root .ava-pm-consent-bar .cs-row1 {
  display: flex; justify-content: space-between; align-items: center;
}
#ava-pm-root .ava-pm-consent-bar .cs-title { font-weight: 700; color: #4a3070; }
#ava-pm-root .ava-pm-consent-bar .cs-when { font-family: monospace; color: #7755A8; font-size: 10.5px; }
#ava-pm-root .ava-pm-consent-bar .cs-row2 {
  display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; align-items: center;
}
#ava-pm-root .ava-pm-consent-bar .cs-srg,
#ava-pm-root .ava-pm-consent-bar .cs-ver,
#ava-pm-root .ava-pm-consent-bar .cs-by {
  font-size: 9.5px; padding: 1px 6px; border-radius: 3px; background: #ece2f0; color: #4a3070;
}
#ava-pm-root .ava-pm-consent-bar .cs-view {
  margin-left: auto; padding: 2px 9px; background: #7755A8; color: #fff;
  border: 0; border-radius: 4px; font-size: 10.5px; cursor: pointer; font-family: inherit;
}
#ava-pm-root .ava-pm-consent-bar .cs-view:hover { background: #4a3070; }

/* ─── 📄 문서 발행 탭 (처방전·영수증·진료확인서) ─── */
#ava-pm-root .ava-pm-docs { padding: 4px 2px; font-family: inherit; }
#ava-pm-root .ava-pm-docs-hint {
  background: #fff5dc; border-left: 3px solid #C97B26; padding: 9px 12px;
  font-size: 11.5px; color: #5a4020; border-radius: 4px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
#ava-pm-root .ava-pm-docs-hint i { color: #C97B26; font-size: 13px; }
#ava-pm-root .ava-pm-docs-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px;
}
#ava-pm-root .ava-pm-docs-grid .doc-btn {
  background: #fff; border: 1.5px solid #E5E0D6; border-radius: 8px;
  padding: 16px 10px 14px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: .15s; text-align: center;
}
#ava-pm-root .ava-pm-docs-grid .doc-btn:hover {
  border-color: #A88C64; background: #fffaf0; transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168,140,100,.15);
}
#ava-pm-root .ava-pm-docs-grid .doc-btn .doc-ic { font-size: 32px; line-height: 1; }
#ava-pm-root .ava-pm-docs-grid .doc-btn .doc-t {
  font-family: Georgia, serif; font-size: 14px; font-weight: 700; color: #2a2420;
}
#ava-pm-root .ava-pm-docs-grid .doc-btn .doc-d {
  font-size: 10.5px; color: #7A7268; line-height: 1.5;
}
#ava-pm-root .ava-pm-docs-note {
  font-size: 10.5px; color: #7A7268; line-height: 1.7;
  background: #fafaf6; border: 1px solid #E5E0D6; border-radius: 5px; padding: 10px 12px;
}

/* ─── 📅 환자 통합 타임라인 ─── */
#ava-pm-root .ava-pm-tl {
  display: flex; flex-direction: column; gap: 14px;
  font-family: inherit; padding: 4px 2px;
}
#ava-pm-root .ava-pm-tl .tl-loading,
#ava-pm-root .ava-pm-tl .tl-empty {
  text-align: center; padding: 40px 16px;
  color: #9A8B79; font-size: 13px; font-style: italic;
}
#ava-pm-root .ava-pm-tl .tl-summary {
  background: linear-gradient(135deg, #1F1B17, #332A22);
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
#ava-pm-root .ava-pm-tl .tl-total {
  font-family: Georgia, serif; font-size: 14px; color: #A88C64;
  font-weight: 600; letter-spacing: .3px;
}
#ava-pm-root .ava-pm-tl .tl-counts {
  font-size: 11px; color: #C8B395; font-family: monospace; line-height: 1.6;
}
/* 필터 칩 */
#ava-pm-root .ava-pm-tl .tl-filters {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 4px 2px;
}
#ava-pm-root .ava-pm-tl .tl-chip {
  padding: 5px 12px; border: 1px solid #d8ccb4; background: #fff;
  border-radius: 99px; font-size: 11.5px; cursor: pointer; font-family: inherit;
  color: #5a4020; font-weight: 600; transition: .12s;
}
#ava-pm-root .ava-pm-tl .tl-chip:hover { border-color: #A88C64; background: #fff5dc; }
#ava-pm-root .ava-pm-tl .tl-chip.active {
  background: #A88C64; color: #fff; border-color: #A88C64;
  box-shadow: 0 2px 6px rgba(168,140,100,.35);
}
#ava-pm-root .ava-pm-tl .tl-filter-hint {
  font-size: 10px; color: #9A8B79; font-style: italic; margin-left: auto;
}
#ava-pm-root .ava-pm-tl .tl-group {
  display: flex; flex-direction: column; gap: 6px;
}
#ava-pm-root .ava-pm-tl .tl-group-head {
  font-family: Georgia, serif; font-style: italic;
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: #A88C64;
  padding: 8px 0 4px; border-bottom: 1px solid #E5E0D6;
  display: flex; align-items: center; gap: 8px;
}
#ava-pm-root .ava-pm-tl .tl-group-head .tl-cnt {
  font-family: monospace; font-style: normal; font-size: 10px;
  background: #A88C64; color: #fff;
  padding: 1px 7px; border-radius: 99px; letter-spacing: 0;
}
#ava-pm-root .ava-pm-tl .tl-row {
  display: grid; grid-template-columns: 36px 1fr auto;
  gap: 10px; align-items: flex-start;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #F2EEE8;
  border-left: 3px solid #d4a85a;
  border-radius: 5px;
  font-size: 12px;
  position: relative;
}
#ava-pm-root .ava-pm-tl .tl-row:hover {
  background: #fafaf6;
  box-shadow: 0 2px 6px rgba(0,0,0,.05);
}
#ava-pm-root .ava-pm-tl .tl-dot {
  width: 28px; height: 28px;
  background: #fff5dc;
  border: 2px solid #A88C64;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
#ava-pm-root .ava-pm-tl .tl-title {
  font-weight: 700; color: #2A2420; font-size: 12.5px;
  line-height: 1.4;
}
#ava-pm-root .ava-pm-tl .tl-sub {
  color: #7A7268; font-size: 10.5px; margin-top: 2px;
  font-family: monospace;
}
#ava-pm-root .ava-pm-tl .tl-extra {
  margin-top: 4px;
}
#ava-pm-root .ava-pm-tl .tl-when {
  color: #A88C64; font-size: 10.5px;
  font-family: monospace; font-weight: 600;
  white-space: nowrap;
}
#ava-pm-root .ava-pm-tl .tl-view-sig {
  background: #7755A8; color: #fff; border: 0; border-radius: 4px;
  padding: 3px 9px; font-size: 10.5px; cursor: pointer; font-family: inherit;
}
#ava-pm-root .ava-pm-tl .tl-view-sig:hover { background: #4a3070; }

/* 이벤트 타입별 색깔 */
#ava-pm-root .ava-pm-tl .tl-row.register { border-left-color: #5183B5; }
#ava-pm-root .ava-pm-tl .tl-row.register .tl-dot { background: #E8F0FE; border-color: #5183B5; }
#ava-pm-root .ava-pm-tl .tl-row.appt { border-left-color: #d4a85a; }
#ava-pm-root .ava-pm-tl .tl-row.checkin { border-left-color: #5183B5; }
#ava-pm-root .ava-pm-tl .tl-row.checkin .tl-dot { background: #E8F0FE; border-color: #5183B5; }
#ava-pm-root .ava-pm-tl .tl-row.payment { border-left-color: #3F7A4F; }
#ava-pm-root .ava-pm-tl .tl-row.payment .tl-dot { background: #E8F5E9; border-color: #3F7A4F; }
#ava-pm-root .ava-pm-tl .tl-row.refund { border-left-color: #A03838; background: #fff8f8; }
#ava-pm-root .ava-pm-tl .tl-row.refund .tl-dot { background: #FDE0E0; border-color: #A03838; }
#ava-pm-root .ava-pm-tl .tl-row.paid { border-left-color: #3F7A4F; background: #f5fdf5; }
#ava-pm-root .ava-pm-tl .tl-row.paid .tl-dot { background: #C8E6C9; border-color: #3F7A4F; }
#ava-pm-root .ava-pm-tl .tl-row.surgery { border-left-color: #A03838; }
#ava-pm-root .ava-pm-tl .tl-row.surgery .tl-dot { background: #FDE0E0; border-color: #A03838; }
#ava-pm-root .ava-pm-tl .tl-row.treatment { border-left-color: #5183B5; }
#ava-pm-root .ava-pm-tl .tl-row.treatment .tl-dot { background: #D8EBFA; border-color: #5183B5; }
#ava-pm-root .ava-pm-tl .tl-row.consent { border-left-color: #7755A8; }
#ava-pm-root .ava-pm-tl .tl-row.consent .tl-dot { background: #F0E8F8; border-color: #7755A8; }
#ava-pm-root .ava-pm-tl .tl-row.label { border-left-color: #C97B26; }
#ava-pm-root .ava-pm-tl .tl-row.label .tl-dot { background: #FFF4E0; border-color: #C97B26; }
#ava-pm-root .ava-pm-tl .tl-row.no_show { border-left-color: #A03838; opacity: .8; background: #fff8f8; }
#ava-pm-root .ava-pm-tl .tl-row.no_show .tl-dot { background: #fff; border-color: #A03838; }
#ava-pm-root .ava-pm-tl .tl-row.cancelled { border-left-color: #999; opacity: .65; }
#ava-pm-root .ava-pm-tl .tl-row.cancelled .tl-dot { background: #f5f5f5; border-color: #999; }
#ava-pm-root .ava-pm-tl .tl-row.cancelled .tl-title { text-decoration: line-through; }
#ava-pm-root .ava-pm-title { margin: 0; font-size: 14px; font-weight: 700; color: #5a4a30; }
#ava-pm-root .ava-pm-title small { color: #9a8b73; font-weight: 500; margin-left: 8px; font-size: 11px; }
#ava-pm-root .ava-pm-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,0.06); border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #5a4a30;
}
#ava-pm-root .ava-pm-close:hover { background: rgba(0,0,0,0.12); }

#ava-pm-root .ava-pm-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(420px, 44%) 1fr;
  gap: 0;
}

/* ─── Left: 환자 기본정보 + 탭 ─────────────────────────── */
#ava-pm-root .ava-pm-left {
  display: flex; flex-direction: column;
  border-right: 1px solid #e6dcc8;
  background: #faf6ef;
  min-height: 0;
}

#ava-pm-root .ava-pm-info {
  padding: 14px 16px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
  border-bottom: 1px solid #e6dcc8;
  background: #fff;
  font-size: 12px;
}
#ava-pm-root .ava-pm-info .row { display: flex; align-items: center; gap: 6px; }
#ava-pm-root .ava-pm-info .row.full { grid-column: 1 / -1; }
#ava-pm-root .ava-pm-info label {
  flex-shrink: 0; width: 60px; font-size: 11px; color: #8a7657; font-weight: 600;
}
#ava-pm-root .ava-pm-info input,
#ava-pm-root .ava-pm-info textarea,
#ava-pm-root .ava-pm-info select {
  flex: 1; min-width: 0;
  padding: 4px 8px;
  border: 1px solid #d8ccb4;
  border-radius: 4px;
  font-size: 12px;
  background: #fffef8;
  font-family: inherit;
}
#ava-pm-root .ava-pm-info textarea { min-height: 32px; resize: vertical; }
#ava-pm-root .ava-pm-info input:focus,
#ava-pm-root .ava-pm-info textarea:focus { outline: 2px solid #c7a875; outline-offset: -1px; }

#ava-pm-root .ava-pm-tabs {
  flex-shrink: 0;
  display: flex; flex-wrap: wrap;
  background: #ece2d0;
  border-bottom: 1px solid #d8ccb4;
  padding: 0 6px;
}
#ava-pm-root .ava-pm-tabs button {
  padding: 8px 12px;
  background: transparent; border: 0; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #6a5840;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
}
#ava-pm-root .ava-pm-tabs button:hover { color: #2a2418; }
#ava-pm-root .ava-pm-tabs button.active {
  color: #5a4020; border-bottom-color: #c7a875; background: #fdfaf6;
}

#ava-pm-root .ava-pm-tabbody {
  flex: 1; min-height: 0;
  overflow-y: auto;
  background: #fff;
}
#ava-pm-root .ava-pm-tabbody table {
  width: 100%; border-collapse: collapse; font-size: 11px;
}
#ava-pm-root .ava-pm-tabbody thead {
  position: sticky; top: 0; background: #f3ece0; z-index: 1;
}
#ava-pm-root .ava-pm-tabbody th,
#ava-pm-root .ava-pm-tabbody td {
  padding: 6px 8px; border-bottom: 1px solid #ede4d2; text-align: left;
}
#ava-pm-root .ava-pm-tabbody th { font-weight: 700; color: #5a4a30; font-size: 11px; }
#ava-pm-root .ava-pm-tabbody tr:hover td { background: #faf6ef; cursor: pointer; }
#ava-pm-root .ava-pm-tabbody .empty { padding: 30px 16px; text-align: center; color: #9a8b73; font-size: 12px; }
#ava-pm-root .ava-pm-tabbody .pod-tag {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  background: #f0e4cc; color: #5a4020; font-size: 10px; font-weight: 600;
}

/* ─── Right: 빠른 액션 ─────────────────────────────── */
#ava-pm-root .ava-pm-right {
  display: flex; flex-direction: column; min-height: 0;
  background: #fdfaf6;
}

#ava-pm-root .ava-pm-action-tabs {
  flex-shrink: 0;
  display: flex;
  background: #f3ece0; border-bottom: 1px solid #d8ccb4;
  padding: 0 6px;
}
#ava-pm-root .ava-pm-action-tabs button {
  padding: 8px 14px;
  background: transparent; border: 0; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #6a5840;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
#ava-pm-root .ava-pm-action-tabs button.active {
  color: #5a4020; border-bottom-color: #c7a875; background: #fdfaf6;
}

#ava-pm-root .ava-pm-action-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; }
#ava-pm-root .ava-pm-action-body .meta-row {
  display: grid; grid-template-columns: 90px 1fr 90px 1fr; gap: 6px 8px;
  margin-bottom: 8px; font-size: 12px;
}
#ava-pm-root .ava-pm-action-body .meta-row label { color: #8a7657; font-weight: 600; align-self: center; }
#ava-pm-root .ava-pm-action-body .meta-row input,
#ava-pm-root .ava-pm-action-body .meta-row select {
  padding: 4px 6px; border: 1px solid #d8ccb4; border-radius: 4px; font-size: 12px; background: #fffef8;
  font-family: inherit;
}
/* 30분 단위 시간 picker — 폰트 monospace + 약간 크게 → 숫자 찾기 편하게 */
#ava-pm-root .ava-pm-action-body .meta-row select.ava-pm-time-select {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 5px 6px;
  font-weight: 600;
  color: #5a4020;
  cursor: pointer;
}

/* 가격 그리드 (AVA_PRICES 기반) */
#ava-pm-root .ava-pm-price-search {
  margin-top: 10px; margin-bottom: 6px;
}
#ava-pm-root .ava-pm-price-search input {
  width: 100%; padding: 6px 10px;
  border: 1px solid #d8ccb4; border-radius: 4px;
  font-size: 12px; font-family: inherit;
  background: #fffdf8;
}
/* ▼ 환자 수술/시술 기존 기록 카드 (액션 탭 상단) */
#ava-pm-root .ava-pm-history {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #fdfaf3 0%, #f6efe2 100%);
  border: 1px solid #d8ccb4;
  border-left: 4px solid #a88c64;
  border-radius: 6px;
}
#ava-pm-root .ava-pm-history .hist-loading,
#ava-pm-root .ava-pm-history .hist-empty {
  font-size: 11px; color: #a89880; font-style: italic;
  text-align: center; padding: 4px 0;
}
#ava-pm-root .ava-pm-history .hist-title {
  font-size: 11.5px; font-weight: 700; color: #5a4020;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
#ava-pm-root .ava-pm-history .hist-count {
  background: #a88c64; color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 8px;
}
#ava-pm-root .ava-pm-history .hist-list {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 110px; overflow-y: auto;
}
#ava-pm-root .ava-pm-history .hist-row {
  display: grid;
  grid-template-columns: 78px 1fr auto auto;
  gap: 8px; align-items: center;
  padding: 4px 8px;
  background: #fff;
  border-left: 3px solid #d4a85a;
  border-radius: 3px;
  font-size: 11px;
}
#ava-pm-root .ava-pm-history .hist-pay-ok { color:#3F7A4F; font-weight:600; font-size:10px; }
#ava-pm-root .ava-pm-history .hist-pay-partial { color:#A88C64; font-weight:600; font-size:10px; }
#ava-pm-root .ava-pm-history .hist-pay-unpaid { color:#A03838; font-weight:600; font-size:10px; }
#ava-pm-root .ava-pm-history .hist-pay-btn {
  background:#3F7A4F; color:#fff; border:0; border-radius:5px;
  padding:4px 9px; font-size:11px; cursor:pointer; font-family:inherit;
  transition:.12s;
}
#ava-pm-root .ava-pm-history .hist-pay-btn:hover { background:#2a5a3a; transform:scale(1.05); }
#ava-pm-root .ava-pm-history .hist-procedure {
  border-left-color: #6090c0;
}
#ava-pm-root .ava-pm-history .hist-date {
  color: #8a7657; font-family: monospace; font-size: 10.5px;
}
#ava-pm-root .ava-pm-history .hist-name {
  color: #2a2418; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#ava-pm-root .ava-pm-history .hist-price {
  color: #5a4020; font-weight: 700; font-size: 10.5px;
}

/* ▼ 상위 카테고리 = 회색 세그먼트 컨트롤 (네비게이션 톤) */
#ava-pm-root .ava-pm-price-cats {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 4px;
  background: #e6e1d4;
  border: 1px solid #c8bfa8;
  border-radius: 8px;
  margin-bottom: 8px;
}
#ava-pm-root .ava-pm-price-cat {
  padding: 6px 12px;
  background: transparent;
  color: #6a5840;
  border: 0;
  border-radius: 5px;
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 5px;
  transition: all 0.12s;
  white-space: nowrap;
}
#ava-pm-root .ava-pm-price-cat:hover {
  background: rgba(255,255,255,0.55);
  color: #2a2418;
}
#ava-pm-root .ava-pm-price-cat.active {
  background: #fff;
  color: #2a2418;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(40, 30, 20, 0.18);
}
#ava-pm-root .ava-pm-price-cat .cnt {
  font-size: 9px; font-weight: 600; opacity: 0.55;
  background: rgba(0,0,0,0.06);
  padding: 1px 5px; border-radius: 8px;
  color: inherit;
}
#ava-pm-root .ava-pm-price-cat.active .cnt {
  background: rgba(168, 140, 100, 0.22);
  opacity: 0.9;
  color: #5a4020;
}

/* ▼ 하위 항목 = 진한 컬러 버튼 (액션 톤) */
#ava-pm-root .ava-pm-price-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
  max-height: 260px; overflow-y: auto;
  padding: 10px;
  background: #fff;
  border: 1px solid #d8ccb4;
  border-radius: 6px;
}
#ava-pm-root .ava-pm-price-cell {
  position: relative;
  padding: 10px 10px;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11.5px; font-family: inherit;
  font-weight: 600;
  user-select: none;
  transition: all 0.12s ease;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  min-height: 40px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
#ava-pm-root .ava-pm-price-cell .n {
  line-height: 1.3;
  word-break: keep-all;
}
#ava-pm-root .ava-pm-price-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  filter: brightness(1.05);
}
#ava-pm-root .ava-pm-price-cell:active {
  transform: translateY(0);
  filter: brightness(0.95);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* 수술 = 따뜻한 골드 (filled) */
#ava-pm-root .ava-pm-price-cell--surgery {
  background: linear-gradient(180deg, #f4d68a 0%, #d4a85a 100%);
  color: #3a2308;
  border: 1px solid #b88a30;
}
#ava-pm-root .ava-pm-price-cell--surgery:hover {
  background: linear-gradient(180deg, #f8dc92 0%, #dfb466 100%);
}

/* 시술 = 차분한 블루 (filled) */
#ava-pm-root .ava-pm-price-cell--procedure {
  background: linear-gradient(180deg, #a8c8e8 0%, #6090c0 100%);
  color: #0a2848;
  border: 1px solid #3a6890;
}
#ava-pm-root .ava-pm-price-cell--procedure:hover {
  background: linear-gradient(180deg, #b4d4f0 0%, #6c9ccc 100%);
}

/* 클릭 후 잠깐 강조 (피드백) */
#ava-pm-root .ava-pm-price-cell.added {
  animation: ava-pm-pulse 0.6s ease;
}
@keyframes ava-pm-pulse {
  0%   { background: #2a4870; color: #fff; transform: scale(0.97); }
  40%  { background: #1a6840; color: #fff; transform: scale(1.05); }
  100% { transform: scale(1); }
}
#ava-pm-root .ava-pm-price-cell.added .n { color: #fff; }

/* Chip 색상 (수술/시술 구분) */
#ava-pm-root .ava-pm-chip--surgery {
  background: #fef0e8; border-color: #d4805a; color: #6a3018;
}
#ava-pm-root .ava-pm-chip--procedure {
  background: #eef5fc; border-color: #6090c0; color: #1a4068;
}

/* 확정 저장된 칩 — 잠금 상태 (배경 더 진하고, X 없이 ✓ 표시) */
#ava-pm-root .ava-pm-chip--saved {
  background: #e8f3e8;
  border: 1px solid #5a8c5a;
  color: #1a4818;
  padding-right: 8px;
}
#ava-pm-root .ava-pm-chip--saved.ava-pm-chip--surgery {
  background: #f8e8d8; border-color: #c08040;
}
#ava-pm-root .ava-pm-chip--saved.ava-pm-chip--procedure {
  background: #d8e8f4; border-color: #4080b8;
}
#ava-pm-root .ava-pm-chip-saved-mark {
  background: #5a8c5a; color: #fff;
  width: 14px; height: 14px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
  margin-right: 2px;
}
#ava-pm-root .ava-pm-chip--saved.ava-pm-chip--surgery .ava-pm-chip-saved-mark {
  background: #c08040;
}
#ava-pm-root .ava-pm-chip--saved.ava-pm-chip--procedure .ava-pm-chip-saved-mark {
  background: #4080b8;
}
#ava-pm-root .ava-pm-chip-date {
  font-size: 10px; opacity: 0.7;
  font-family: monospace;
  margin-left: 2px;
}
#ava-pm-root .ava-pm-chip-price-readonly {
  font-size: 11px; font-weight: 700;
  margin-left: 4px;
}
#ava-pm-root .ava-pm-chip-total small {
  font-size: 10px; font-weight: 500; opacity: 0.85;
}

/* 저장 칩의 X 버튼 — 신규 칩 X 보다 살짝 진한 빨강 */
#ava-pm-root .ava-pm-chip-x-saved {
  margin-left: 2px;
  background: rgba(0,0,0,0.12) !important;
}
#ava-pm-root .ava-pm-chip-x-saved:hover {
  background: #c04040 !important; color: #fff !important;
}

/* 좌측 패널 행 삭제 버튼 */
#ava-pm-root .ava-pm-row-del {
  width: 22px; height: 22px;
  border: 0; border-radius: 4px;
  background: transparent;
  color: #b08070;
  cursor: pointer;
  font-size: 13px; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  opacity: 0.4;
  transition: all 0.12s;
}
#ava-pm-root .ava-pm-row-del:hover {
  background: #c04040; color: #fff;
  opacity: 1;
}
#ava-pm-root .ava-pm-chip-name {
  font-weight: 600;
}
#ava-pm-root .ava-pm-chip-price {
  width: 70px;
  padding: 2px 6px; margin-left: 2px;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 3px;
  background: #fff;
  font-size: 11px; font-family: inherit;
  text-align: right;
  color: #2a2418;
}
#ava-pm-root .ava-pm-chip-price:focus {
  outline: none;
  border-color: #5a4020;
  box-shadow: 0 0 0 2px rgba(168, 140, 100, 0.25);
}
#ava-pm-root .ava-pm-chip-unit {
  font-size: 10px; opacity: 0.65; margin-left: -2px;
}
#ava-pm-root .ava-pm-chip-total {
  margin-left: auto;
  padding: 5px 12px;
  background: #5a4020; color: #fff;
  border-radius: 14px;
  font-size: 11.5px; font-weight: 600;
  align-self: center;
  letter-spacing: 0.02em;
}
#ava-pm-root .ava-pm-chip-total b {
  font-weight: 800; font-size: 12.5px;
  margin-right: 1px;
}

/* 시술 그리드 (legacy — 잔존 호환) */
#ava-pm-root .ava-pm-procedure-grid {
  margin-top: 12px;
  border: 1px solid #d8ccb4; border-radius: 6px; overflow: hidden;
  background: #fff;
}
#ava-pm-root .ava-pm-procedure-grid .row {
  display: grid; grid-template-columns: 80px repeat(4, 1fr);
  border-bottom: 1px solid #ede4d2;
}
#ava-pm-root .ava-pm-procedure-grid .row:last-child { border-bottom: 0; }
#ava-pm-root .ava-pm-procedure-grid .cat {
  padding: 8px 6px;
  background: #f3ece0; color: #5a4020;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid #d8ccb4;
}
#ava-pm-root .ava-pm-procedure-grid .cell {
  padding: 6px 4px; text-align: center; cursor: pointer;
  border-right: 1px solid #ede4d2; font-size: 11px;
  user-select: none;
  transition: background 0.1s;
}
#ava-pm-root .ava-pm-procedure-grid .cell:last-child { border-right: 0; }
#ava-pm-root .ava-pm-procedure-grid .cell:hover { background: #faf6ef; }
#ava-pm-root .ava-pm-procedure-grid .cell:active { background: #ede4d2; }

#ava-pm-root .ava-pm-procedure-hint {
  font-size: 10px; color: #9a8b73; padding: 4px 0; text-align: center;
}

/* 선택된 시술 chip 영역 */
#ava-pm-root .ava-pm-selected-procedures {
  margin-top: 10px; padding: 8px 10px;
  background: #fff8e9; border: 1px dashed #d8b572; border-radius: 6px;
  min-height: 40px;
  display: flex; flex-wrap: wrap; gap: 6px;
  align-content: flex-start;
}
#ava-pm-root .ava-pm-selected-procedures:empty::after {
  content: '위 버튼을 클릭하면 여기에 추가됩니다 — 가격은 환자별로 입력';
  color: #b89860; font-size: 11px; align-self: center; margin: 0 auto;
}
#ava-pm-root .ava-pm-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 4px 3px 8px;
  background: #fff; border: 1px solid #d8b572; border-radius: 12px;
  font-size: 11px; color: #5a4020;
}
#ava-pm-root .ava-pm-chip .x {
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,0.08); border: 0; cursor: pointer;
  font-size: 11px; line-height: 1; color: #6a5840;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
#ava-pm-root .ava-pm-chip .x:hover { background: #d04040; color: #fff; }

/* POD 박스 */
#ava-pm-root .ava-pm-pod-box {
  margin-top: 10px; padding: 10px 14px;
  background: linear-gradient(135deg, #fdf3dc, #f7e6c0);
  border: 1px solid #d8b572; border-radius: 6px;
  font-size: 12px; color: #5a4020;
}
#ava-pm-root .ava-pm-pod-box strong { color: #2a2418; font-size: 13px; }

/* 액션 버튼 */
#ava-pm-root .ava-pm-actions {
  flex-shrink: 0;
  padding: 10px 14px;
  border-top: 1px solid #e6dcc8; background: #f3ece0;
  display: flex; justify-content: flex-end; gap: 8px;
}
#ava-pm-root .ava-pm-actions button {
  padding: 7px 16px; font-size: 12px; font-weight: 600;
  border: 1px solid #c7a875; border-radius: 4px;
  background: #fff; color: #5a4020; cursor: pointer;
  font-family: inherit;
}
#ava-pm-root .ava-pm-actions button.primary {
  background: linear-gradient(180deg, #c7a875, #b8956a); color: #fff; border-color: #a07f50;
}
#ava-pm-root .ava-pm-actions button:hover { filter: brightness(1.05); }

/* ─── 이미지 뷰어 ──────────────────────────────────── */
#ava-iv-root { display: none; }
#ava-iv-root.open { display: block; }
#ava-iv-root .ava-iv-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 99500;
}
#ava-iv-root .ava-iv-card {
  position: fixed; inset: 2vh 2vw; background: #18120c;
  border-radius: 10px; z-index: 99501;
  display: grid; grid-template-columns: 110px 160px 1fr;
  overflow: hidden;
  color: #fff;
}
#ava-iv-root .ava-iv-dates {
  background: #221a10; border-right: 1px solid #2c2418;
  overflow-y: auto;
}
#ava-iv-root .ava-iv-dates .item {
  padding: 8px 10px; font-size: 11px; cursor: pointer;
  border-bottom: 1px solid #2c2418; color: #c8b8a0;
}
#ava-iv-root .ava-iv-dates .item:hover { background: #2c2418; color: #fff; }
#ava-iv-root .ava-iv-dates .item.active { background: #c7a875; color: #18120c; font-weight: 700; }

#ava-iv-root .ava-iv-thumbs {
  background: #1a140c; border-right: 1px solid #2c2418;
  overflow-y: auto; padding: 8px;
}
#ava-iv-root .ava-iv-thumbs .thumb {
  width: 100%; aspect-ratio: 3/4; object-fit: cover;
  border-radius: 4px; cursor: pointer; margin-bottom: 6px;
  border: 2px solid transparent; transition: border-color 0.15s;
  display: block;
}
#ava-iv-root .ava-iv-thumbs .thumb:hover { border-color: #c7a875; }
#ava-iv-root .ava-iv-thumbs .thumb.in-canvas { border-color: #6ad0a0; }
#ava-iv-root .ava-iv-thumbs .thumb-meta { font-size: 10px; color: #8a7c64; text-align: center; margin-top: -2px; margin-bottom: 6px; }

#ava-iv-root .ava-iv-canvas {
  background: #0c0805;
  display: grid;
  gap: 4px;
  padding: 4px;
  position: relative;
}
#ava-iv-root .ava-iv-canvas img {
  width: 100%; height: 100%; object-fit: contain;
  background: #18120c;
  cursor: pointer;
  border: 1px solid transparent;
}
#ava-iv-root .ava-iv-canvas img:hover { border-color: #c7a875; }
#ava-iv-root .ava-iv-canvas .empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #6a5840; font-size: 14px; pointer-events: none;
}

#ava-iv-root .ava-iv-close {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff; border: 0; cursor: pointer;
  font-size: 20px;
}
/* B/A 슬라이더 토글 버튼 */
#ava-iv-root .ava-iv-ba-toggle {
  position: absolute; top: 12px; right: 60px; z-index: 3;
  background: linear-gradient(135deg,#A88C64,#8e7252); color: #fff;
  border: 0; border-radius: 999px; padding: 7px 14px; cursor: pointer;
  font-size: 12px; font-weight: 700; font-family: inherit;
  box-shadow: 0 4px 12px rgba(168,140,100,.4);
}
#ava-iv-root .ava-iv-ba-toggle:hover { background: #5a4020; }
/* B/A 슬라이더 본체 */
#ava-iv-root .ava-iv-ba-wrap {
  position: relative; width: 100%; height: 100%;
  overflow: hidden; user-select: none; cursor: ew-resize;
  background: #000;
}
#ava-iv-root .ava-iv-ba-bg,
#ava-iv-root .ava-iv-ba-after img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain;
}
#ava-iv-root .ava-iv-ba-after {
  position: absolute; inset: 0;
  clip-path: inset(0 0 0 50%);
  pointer-events: none;
}
#ava-iv-root .ava-iv-ba-handle {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 3px; background: #fff;
  transform: translateX(-1.5px);
  cursor: ew-resize; z-index: 5;
  box-shadow: 0 0 8px rgba(0,0,0,.5);
}
#ava-iv-root .ava-iv-ba-handle::after {
  content: '⇔'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: #fff; color: #1F1B17; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  font-size: 18px;
}
#ava-iv-root .ava-iv-ba-label {
  position: absolute; top: 16px; padding: 6px 14px;
  background: rgba(0,0,0,.6); color: #fff;
  font-family: Georgia, serif; font-style: italic; letter-spacing: 2px;
  font-size: 12px; border-radius: 4px; pointer-events: none; z-index: 4;
}
#ava-iv-root .ava-iv-ba-label.l { left: 20px; }
#ava-iv-root .ava-iv-ba-label.r { right: 20px; }

@media (max-width: 768px) {
  #ava-pm-root .ava-pm-card { width: 100vw; height: 100vh; border-radius: 0; }
  #ava-pm-root .ava-pm-body { grid-template-columns: 1fr; }
  #ava-pm-root .ava-pm-left { border-right: 0; border-bottom: 1px solid #e6dcc8; max-height: 50%; }
  #ava-iv-root .ava-iv-card { grid-template-columns: 1fr; grid-template-rows: 80px 100px 1fr; inset: 0; border-radius: 0; }
  #ava-iv-root .ava-iv-dates { display: flex; overflow-x: auto; overflow-y: hidden; }
  #ava-iv-root .ava-iv-dates .item { flex-shrink: 0; }
  #ava-iv-root .ava-iv-thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 4px; }
  #ava-iv-root .ava-iv-thumbs .thumb { width: 70px; aspect-ratio: 3/4; flex-shrink: 0; margin-bottom: 0; }
  #ava-iv-root .ava-iv-thumbs .thumb-meta { display: none; }
}
