/* ================================================================
 * workbench.css — 표 중심 작업대 공용 스타일
 *
 * 원칙: 화면을 스크롤로 훑지 않는다. 목록은 표로 압축해 한눈에 보고,
 * 한 번의 클릭으로 오른쪽에서 상세를 확인한다. 페이지 자체는 스크롤하지
 * 않고 좌우 두 칸만 각자 스크롤한다.
 *
 * 사용 화면: vet-ai-agent · prescription-inbox · vet-prescription-management
 * 헤더 높이가 다른 화면은 --wb-head를 덮어쓴다.
 * ================================================================ */

/* ================================================================ 수의사 도우미 작업대
 * 원칙: 화면을 스크롤로 훑지 않는다. 목록은 표로 압축해 한눈에 보고, 한 번의
 * 클릭으로 오른쪽에서 상세를 확인한다. 페이지 자체는 스크롤하지 않고 두 칸만
 * 각자 스크롤한다. 이전 판은 카드가 세로로 쌓여 6건에 4화면이 필요했다.
 * ================================================================ */
:root {
  /* 페이지 헤더 높이. 화면마다 헤더가 달라 각 페이지에서 덮어쓸 수 있게 변수로 뺀다. */
  --wb-head: 57px;
}

.assistant-patient-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  max-width: 2080px;
  margin: 18px auto;
  padding: 0 12px;
}
.assistant-patient-layout.is-sidebar-collapsed { grid-template-columns: 48px minmax(0, 1fr); }
.assistant-patient-layout main.vet-home-container.agent-shell {
  width: 100%;
  min-width: 0;
  margin: 0;
}
.assistant-patient-sidebar {
  box-sizing: border-box;
  position: sticky;
  top: 12px;
  align-self: start;
  height: calc(100dvh - 106px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 1px solid #dce5ee;
  border-radius: 8px;
  min-width: 0;
}
.assistant-patient-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.assistant-patient-sidebar h2 { font-size: 16px; margin: 0; }
.assistant-sidebar-toggle { width: 30px; height: 30px; flex: 0 0 30px; display: inline-grid; place-items: center; padding: 0; border: 1px solid #c5d3e5; border-radius: 4px; color: #27415f; background: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.assistant-sidebar-toggle:hover { border-color: #3868ed; color: #2454d6; background: #f5f8ff; }
.assistant-sidebar-toggle:focus-visible { outline: 2px solid #3868ed; outline-offset: 2px; }
.assistant-patient-layout.is-sidebar-collapsed .assistant-patient-sidebar { padding: 8px; }
.assistant-patient-layout.is-sidebar-collapsed .assistant-patient-sidebar-head { justify-content: center; }
.assistant-patient-layout.is-sidebar-collapsed .assistant-patient-sidebar-head h2,
.assistant-patient-layout.is-sidebar-collapsed .assistant-patient-sidebar > :not(.assistant-patient-sidebar-head) { display: none !important; }
.assistant-patient-sidebar [hidden] { display: none !important; }
.assistant-patient-modes[hidden] { display: none !important; }
.assistant-patient-sidebar input { width: 100%; min-width: 0; box-sizing: border-box; height: 36px; padding: 6px 8px; border: 1px solid #c5d3e5; border-radius: 4px; font-size: 13px; }
.assistant-patient-sidebar [role="status"] { font-size: 12px; margin: 0; color: #627489; }
.assistant-patient-list { overflow-y: auto; min-height: 0; display: grid; align-content: start; gap: 4px; }
.assistant-patient-list button { display: block; min-width: 0; text-align: left; padding: 9px; border: 1px solid transparent; background: #fff; border-radius: 4px; }
.assistant-patient-list button span { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-patient-list button[aria-pressed="true"] { border-color: #3868ed; background: #edf4ff; }
.assistant-patient-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.assistant-patient-modes button { min-width: 0; padding: 7px 2px; border: 1px solid #c5d3e5; border-radius: 4px; background: #fff; color: #30445c; font: inherit; font-size: 12px; cursor: pointer; }
.assistant-patient-modes button[aria-pressed="true"] { color: #2454d6; border-color: #9ab8fa; background: #edf4ff; font-weight: 700; }
.assistant-patient-summary {
  flex: none;
  min-width: 0;
  padding: 12px 14px;
  border-top: 1px solid #dce5ee;
  background: transparent;
}
.agent-status:empty { display: none; }
.assistant-patient-summary[hidden] { display: none; }
.assistant-patient-summary-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.assistant-patient-summary-head h2 { margin: 0; font-size: 15px; }
.assistant-patient-summary-head p { margin: 3px 0 0; font-size: 12px; color: #586e85; }
.assistant-patient-summary-body { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 10px; max-height: 190px; overflow: auto; }
.assistant-patient-summary-body details { min-width: min(290px, 100%); flex: 1; font-size: 12px; }
.assistant-patient-summary-body summary { cursor: pointer; font-weight: 700; }
.assistant-patient-summary-body ul { margin: 6px 0; padding-left: 18px; }
.assistant-patient-summary-body li { margin: 4px 0; }
.assistant-patient-summary-body li button { border: 0; background: none; color: #2454d6; font: inherit; text-align: left; cursor: pointer; padding: 0; }
.assistant-patient-summary-body li button:hover { text-decoration: underline; }
.assistant-patient-summary-body .empty { color: #66788c; }
.assistant-selected-patient { margin: 0 0 10px; padding: 6px 10px; background: #edf4ff; color: #173c7a; font-size: 13px; }
@media (max-width: 900px) {
  .assistant-patient-layout { grid-template-columns: minmax(0, 1fr); padding: 0 8px; }
  .assistant-patient-layout.is-sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .assistant-patient-sidebar { position: static; height: auto; max-height: 280px; }
  .assistant-patient-layout.is-sidebar-collapsed .assistant-patient-sidebar { height: 46px; max-height: 46px; align-items: flex-start; }
  .assistant-patient-layout.is-sidebar-collapsed .assistant-patient-sidebar-head { width: 100%; justify-content: flex-start; }
  .assistant-patient-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 120px; }
}
.agent-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* 헤더를 뺀 화면 전체를 쓴다. 컨테이너 기본 여백(24px 102px)을 쓰면 아래가
     잘려 페이지가 스크롤된다. */
  height: calc(100dvh - var(--wb-head, 57px));
  min-height: 0;
  /* 넓은 화면에서 표의 가변 열이 폭을 다 먹어 데이터가 왼쪽에 몰린다.
     읽기 좋은 폭으로 제한하고 남는 공간은 좌우로 나눈다. */
  max-width: 1640px;
  margin: 0 auto;
  padding: 10px 16px 12px;
  /* 이 프로젝트는 전역 border-box가 아니라 padding이 높이에 더해진다. */
  box-sizing: border-box;
}

/* display를 지정한 요소는 hidden 속성이 무력화된다(작성자 규칙이 UA 규칙을 이긴다).
   이 화면은 탭 전환을 hidden으로 하므로 안쪽 전체에 안전장치를 둔다. */
.agent-shell [hidden] {
  display: none !important;
}

.agent-bar {
  flex: none;
  min-width: 0;
}
.agent-bar .ai-composer {
  display: block;
  overflow: hidden;
  border: 1px solid #c5d3e5;
  border-radius: 14px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.agent-bar .ai-composer:focus-within {
  border-color: #3868ed;
  box-shadow: 0 0 0 3px rgba(56, 104, 237, 0.12);
}
.agent-bar .composer-shell {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.agent-bar .composer-shell:focus-within {
  border: 0;
  box-shadow: none;
}

.agent-bar .ai-prompt-grid {
  margin-top: 6px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.agent-bar .ai-prompt-grid button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 700;
}

.agent-bar .ai-prompt-grid button:disabled,
.agent-bar .ai-prompt-grid button[data-feature-disabled] {
  opacity: 0.42;
  filter: grayscale(0.35);
  cursor: not-allowed;
  border-color: #d8dee8;
  background: #f3f6fa;
  color: #7b8794;
  box-shadow: none;
}

.agent-status {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-muted, #64727a);
}

.ai-readback-panel {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  max-height: 170px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--accent, #2563eb);
  border-radius: 12px;
  background: #f8fbff;
  box-shadow: var(--shadow, 0 8px 28px rgba(15, 23, 42, 0.06));
}

.ai-readback-panel strong {
  display: block;
  margin-bottom: 2px;
  color: var(--accent-strong, #1d4ed8);
  font-size: 12px;
}

.ai-readback-text {
  display: grid;
  gap: 5px;
}

.ai-readback-line {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.ai-readback-line span {
  color: var(--text-muted, #64727a);
  font-size: 11.5px;
  font-weight: 800;
}

.ai-readback-line p {
  margin: 0;
  color: var(--text, #1c2830);
  font-size: 12.5px;
  line-height: 1.35;
}

.ai-readback-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
  margin-top: 0;
}

.ai-readback-steps > div {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 5px;
  align-items: center;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid var(--accent-border, #bfdbfe);
  border-radius: 8px;
  background: var(--surface, #ffffff);
}

.ai-readback-steps b {
  color: var(--text-muted, #64727a);
  font-size: 11.5px;
}

.ai-readback-steps strong {
  color: var(--accent-strong, #1d4ed8);
  font-size: 12px;
}

.ai-readback-steps small {
  color: var(--text-muted, #64727a);
  font-size: 11.5px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-readback-steps > div.is-warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.ai-readback-steps > div.is-warning strong {
  color: #92400e;
}

.ai-readback-meta {
  display: flex;
  justify-content: flex-start;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}

.ai-readback-meta span {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft, #eff6ff);
  color: var(--accent-strong, #1d4ed8);
  font-size: 11px;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}

.ai-readback-meta .is-warning {
  background: #fef3c7;
  color: #92400e;
}

.ai-decision-panel {
  flex: none;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #facc15;
  border-left: 4px solid #ca8a04;
  border-radius: 12px;
  background: #fffbeb;
  box-shadow: var(--shadow, 0 8px 28px rgba(15, 23, 42, 0.06));
}

.ai-decision-head strong {
  display: block;
  margin-bottom: 3px;
  color: #92400e;
  font-size: 13px;
}

.ai-decision-head p {
  margin: 0;
  color: var(--text, #1c2830);
  font-size: 12.5px;
  line-height: 1.45;
}

.ai-decision-body {
  display: grid;
  gap: 10px;
}

.ai-decision-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.ai-decision-grid > div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #fde68a;
  border-radius: 10px;
  background: #ffffff;
}

.ai-decision-grid span {
  display: block;
  color: var(--text-muted, #64727a);
  font-size: 11px;
  font-weight: 800;
}

.ai-decision-grid b {
  display: block;
  margin-top: 3px;
  color: var(--text, #1c2830);
  font-size: 14px;
}

.ai-decision-grid .is-requested {
  border-color: #f59e0b;
  background: #fff7ed;
}

.ai-decision-grid .is-requested b {
  color: #9a3412;
}

.ai-decision-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-pet-choice-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-decision-note {
  margin: 0;
  color: var(--text-muted, #64727a);
  font-size: 12px;
  line-height: 1.4;
}

.ai-decline-list {
  display: grid;
  gap: 8px;
}

.ai-decline-list article {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fff;
}

.ai-decline-list strong {
  display: block;
  color: #991b1b;
  font-size: 13px;
}

.ai-decline-list p {
  margin: 4px 0 0;
  color: var(--text, #1c2830);
  font-size: 12.5px;
  line-height: 1.45;
}

.ai-comparison-panel {
  flex: none;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #bae6fd;
  border-left: 4px solid #0891b2;
  border-radius: 12px;
  background: #f0fdfa;
  box-shadow: var(--shadow, 0 8px 28px rgba(15, 23, 42, 0.06));
}

.ai-comparison-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ai-comparison-head strong {
  display: block;
  margin-bottom: 3px;
  color: #0f766e;
  font-size: 13px;
}

.ai-comparison-head p {
  margin: 0;
  color: var(--text, #1c2830);
  font-size: 12.5px;
  line-height: 1.45;
}

.ai-comparison-body {
  min-width: 0;
  overflow-x: auto;
}

.ai-comparison-table {
  min-width: 520px;
  background: var(--surface, #ffffff);
}

.ai-comparison-table th,
.ai-comparison-table td {
  text-align: left;
  white-space: nowrap;
}

.ai-comparison-table .comparison-after-cell {
  color: #0f766e;
  font-weight: 800;
}

.agent-split {
  display: grid;
  grid-template-columns:
    minmax(360px, calc(var(--agent-split-left, 50%) - 5px))
    10px
    minmax(360px, calc(100% - var(--agent-split-left, 50%) - 5px));
  gap: 0;
  flex: 1;
  min-height: 0;
}

.agent-split-resize {
  align-self: stretch;
  width: 10px;
  min-width: 10px;
  min-height: 0;
  border: 0;
  background:
    linear-gradient(90deg, transparent 0 3px, rgba(148, 163, 184, 0.35) 3px 4px, transparent 4px 6px, rgba(148, 163, 184, 0.35) 6px 7px, transparent 7px);
  cursor: col-resize;
  opacity: 0.72;
}

.agent-split-resize:hover,
.agent-split-resize:focus-visible,
body.agent-split-resizing .agent-split-resize {
  background:
    linear-gradient(90deg, transparent 0 3px, var(--accent, #2563eb) 3px 4px, transparent 4px 6px, var(--accent, #2563eb) 6px 7px, transparent 7px);
  opacity: 1;
  outline: none;
}

body.agent-split-resizing {
  cursor: col-resize;
  user-select: none;
}

.agent-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 14px;
  background: var(--surface, #ffffff);
  box-shadow: var(--shadow, 0 8px 28px rgba(15, 23, 42, 0.06));
  overflow: hidden;
}

.agent-shell .agent-split .agent-pane .pane-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  box-sizing: border-box;
  height: 68px;
  min-height: 68px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  background: var(--surface-soft, #f8fafc);
}
.agent-shell .agent-list > .pane-head { overflow-x: auto; overflow-y: hidden; }
.agent-shell .agent-list > .pane-head .pane-tabs { flex: none; }
.agent-shell .agent-list > .pane-head .pane-tools { flex: none; flex-wrap: nowrap; }

/* 두 칸만 스크롤한다. 페이지는 스크롤하지 않는다. */
.agent-pane .pane-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.agent-detail .pane-body {
  padding: 12px 14px;
}

.ai-clarification-card {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
  padding: 14px 16px;
  border: 1px solid var(--accent-border, #bfdbfe);
  border-left: 4px solid var(--accent, #2563eb);
  border-radius: 8px;
  background: var(--accent-soft, #eff6ff);
}

.ai-clarification-card strong {
  color: var(--accent-strong, #1d4ed8);
  font-size: 14px;
}

.ai-clarification-card p {
  margin: 0;
  color: var(--text, #1c2830);
  font-size: 13px;
  line-height: 1.5;
}

#aiFollowupAnalysisForm:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

#aiFollowupAnalysisForm label {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
}

#aiFollowupAnalysisForm input,
#aiFollowupAnalysisForm select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 6px 8px;
  border: 1px solid #c9d7ec;
  border-radius: 4px;
  background: #fff;
  color: #17345b;
}

.ai-actions .ghost.small {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.ai-actions .ghost.small:hover,
.ai-actions .ghost.small:focus-visible {
  border-color: var(--accent, #2563eb);
  background: var(--accent, #2563eb);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
  outline: none;
}

.pane-tabs {
  display: flex;
  gap: 4px;
}

.pane-tab {
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted, #64727a);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.pane-tab b {
  display: inline-block;
  min-width: 18px;
  margin-inline-start: 5px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--line, #e2e8f0);
  color: var(--text-muted, #64727a);
  font-size: 11px;
}

.pane-tab.is-active {
  border-color: var(--accent-border, #bfdbfe);
  background: var(--accent-soft, #eff6ff);
  color: var(--accent-strong, #1d4ed8);
}

.pane-tab.is-active b {
  background: var(--accent, #2563eb);
  color: #fff;
}

.pane-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
  flex-wrap: wrap;
}

.pane-tools select,
.pane-tools input {
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid var(--line-strong, #cbd5e1);
  border-radius: 8px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text, #1c2830);
  background: var(--surface, #ffffff);
}

.pane-tools input {
  width: 148px;
}

/* select는 기본으로 남은 폭을 다 먹어 도구 줄이 두 줄로 접힌다. */
.pane-tools select {
  width: auto;
  max-width: 150px;
}

.filter-chip {
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 999px;
  background: var(--surface, #ffffff);
  color: var(--text-muted, #64727a);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.filter-chip.is-active {
  border-color: var(--accent-border, #bfdbfe);
  background: var(--accent-soft, #eff6ff);
  color: var(--accent-strong, #1d4ed8);
}

/* ---------------------------------------------------------------- 업무 표
 * 고정 레이아웃 + 말줄임. 이전 판은 좁은 칸에서 글자가 세로로 한 자씩 쌓여
 * 행 하나가 180px을 먹었다. */
.work-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12.5px;
}

.work-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-strong, #cbd5e1);
  background: var(--surface-soft, #f8fafc);
  color: var(--text-muted, #64727a);
  font-size: 11.5px;
  font-weight: 750;
  text-align: left;
  white-space: nowrap;
}

#aiItemList:has(.followup-pagination-inline) .work-table thead th,
#aiItemList.has-followup-pagination .work-table thead th {
  top: 45px;
}

.work-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  color: var(--text, #1c2830);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.work-table tbody tr {
  cursor: pointer;
}

.work-table td.report-time {
  padding-left: 6px;
  padding-right: 6px;
  text-overflow: clip;
}

.pending-work-table { min-width: 980px; }
.pet-work-status-table { min-width: 920px; table-layout: auto; }
.pet-work-status-table th,
.pet-work-status-table td { padding: 8px 6px; }
.pet-work-status-table th:first-child { min-width: 95px; }
.pet-work-status-table td:nth-child(5) { min-width: 170px; white-space: normal; }
.pet-work-status-table td:nth-child(6) { min-width: 90px; white-space: normal; }
.pet-work-status-table td:nth-child(7) { min-width: 105px; white-space: nowrap; }
.pet-work-status-table td:last-child { min-width: 130px; overflow: visible; }
.pet-work-status-table td:last-child a { white-space: nowrap; }
.pending-work-table th:nth-child(1) { width: 85px; }
.pending-work-table th:nth-child(2) { width: 65px; }
.pending-work-table th:nth-child(3) { width: 80px; }
.pending-work-table th:nth-child(4) { width: 85px; }
.pending-work-table th:nth-child(5) { width: 75px; }
.pending-work-table th:nth-child(6) { width: 100px; }
.pending-work-table th:nth-child(7) { width: 90px; }
.pending-work-table th:last-child { width: 132px; }
.pending-work-table th { box-sizing: border-box; }
.pending-work-table th,
.pending-work-table tbody td { padding-left: 6px; padding-right: 6px; }

.pending-work-table td:last-child {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.pending-work-table td:last-child a,
.pending-work-table td:last-child button {
  max-width: 100%;
  min-width: 104px;
  white-space: nowrap;
  word-break: keep-all;
}

.vet-followup-reply-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line, #dce4ed);
  border-radius: 8px;
  background: var(--surface-soft, #f7faff);
}
.vet-followup-reply-panel .followup-workbench-head { display: grid; gap: 6px; }
.vet-followup-reply-panel .followup-workbench-head strong { font-size: 17px; }
.vet-followup-reply-panel .followup-level-pill {
  justify-self: start; padding: 5px 12px; border-radius: 8px; background: #e2f2ff; color: #075985;
}
.vet-followup-reply-panel .followup-level-pill.high { background: #fee2e2; color: #b91c1c; }
.vet-followup-reply-panel .followup-level-pill.medium { background: #fff3cd; color: #92400e; }
.vet-followup-reply-panel .followup-analysis-panel {
  min-width: 0; padding: 14px; background: #fff; border: 1px solid #dce4ed; border-radius: 8px;
}
.vet-followup-reply-panel .followup-analysis-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vet-followup-reply-panel .answer-section { margin-top: 12px; }
.vet-followup-reply-panel .answer-text,
.vet-followup-reply-panel .answer-section p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.vet-followup-reply-panel .answer-table-wrap { max-width: 100%; overflow-x: auto; }
.vet-followup-reply-panel .answer-table { min-width: 420px; }
.vet-followup-reply-panel .answer-basis { color: #64748b; overflow-wrap: anywhere; }
.vet-followup-reply-panel .followup-template-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.vet-followup-reply-panel .followup-template-actions button {
  min-height: 32px; padding: 6px 10px; border: 1px solid #c4d5ff; border-radius: 8px;
  background: #fff; color: #1d4ed8; font-size: 12px; font-weight: 800; cursor: pointer;
}
.vet-followup-reply-panel .followup-template-actions button.is-selected { background: #2563eb; color: #fff; border-color: #1d4ed8; }
.vet-followup-reply-panel button:disabled { opacity: .55; cursor: default; }
.vet-followup-reply-panel form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.vet-followup-reply-panel label {
  display: grid;
  gap: 6px;
}
.vet-followup-reply-panel input:not([type="checkbox"]),
.vet-followup-reply-panel textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-strong, #cbd5e1);
  border-radius: 4px;
  font: inherit;
}
.vet-followup-reply-panel textarea {
  resize: vertical;
  min-height: 180px;
}
.vet-followup-reply-panel .vet-reply-confirm {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  justify-content: flex-start;
}
.vet-followup-reply-panel .vet-reply-confirm input {
  flex: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 3px 0 0;
  padding: 0;
}
.vet-reply-original {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  body.prescription-inbox-page.inbox-detail-open { overflow: hidden; }
  body.prescription-inbox-page.inbox-detail-open .agent-detail .pane-body { max-height: none; }
}

.work-table tbody tr:hover {
  background: var(--surface-tint, #eff6ff);
}

.work-table tbody tr.is-selected {
  background: var(--accent-soft, #eff6ff);
  box-shadow: inset 3px 0 0 var(--accent, #2563eb);
}

.work-table tbody tr:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: -2px;
}

body.prescription-triage-mode .agent-shell {
  height: calc(100dvh - var(--wb-head, 57px));
  min-height: 0;
}

body.prescription-triage-mode .agent-split {
  grid-template-columns: 1fr;
  align-content: start;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

body.prescription-triage-mode .agent-split-resize {
  display: none;
}

body.prescription-triage-mode .agent-detail {
  display: none;
}

body.prescription-triage-mode .agent-pane .pane-body {
  max-height: none;
  min-height: 0;
}

body.prescription-triage-mode #aiTableTools {
  display: flex;
}

body.prescription-triage-mode .work-table tbody td {
  height: auto;
  padding-block: 10px;
}

body.prescription-triage-mode .agent-list .pane-body {
  overflow: auto;
}

body.answer-focus-mode .agent-split {
  grid-template-columns: 1fr;
}

body.answer-focus-mode .agent-split-resize {
  display: none;
}

body.answer-focus-mode .agent-list {
  display: none;
}

body.answer-focus-mode .agent-detail .pane-body {
  padding: 16px 18px;
}

body.answer-focus-mode .ai-answer-panel {
  max-width: 980px;
}

body.recipe-explanation-mode .agent-list > .pane-head,
body.recipe-explanation-mode #aiItemList,
body.recipe-explanation-mode #axApprovalList {
  display: none;
}

.agent-list > [hidden] {
  display: none !important;
}

body.recipe-explanation-mode #aiRecipeExplanationPanel {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

body.composition-review-mode .agent-list > .pane-head {
  display: flex;
}

body.composition-review-mode #aiItemList {
  display: block;
  flex: 0 1 42%;
  min-height: 160px;
  overflow: auto;
}

#aiRecipeExplanationTitle {
  font-size: 18px;
  margin: 0 0 12px;
}

.answer-section ul {
  padding-left: 20px;
  margin: 8px 0;
}

.answer-section li {
  line-height: 1.6;
  margin-bottom: 6px;
}

.prescription-triage-table {
  min-width: 980px;
}

.prescription-triage-table th,
.prescription-triage-table td {
  vertical-align: middle;
}

.prescription-triage-table td:nth-child(4) {
  white-space: normal;
}

.prescription-triage-table th:nth-child(n+7):nth-child(-n+9),
.prescription-triage-table td:nth-child(n+7):nth-child(-n+9) {
  padding-left: 6px;
  padding-right: 6px;
}

.prescription-triage-table td:last-child .small {
  box-sizing: border-box;
  max-width: 100%;
  padding-left: 8px;
  padding-right: 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

.prescription-triage-table .prescription-row-note {
  display: block;
  margin-top: 3px;
  line-height: 1.35;
  white-space: normal;
}

.prescription-approval-queue {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
  padding: 12px;
}

.prescription-approval-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 10px;
  background: var(--surface, #ffffff);
}

.prescription-approval-card .approval-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.prescription-approval-card .approval-card-head > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.prescription-approval-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  color: var(--text, #1c2830);
}

.prescription-approval-card p {
  margin: 0;
  color: var(--text-muted, #64727a);
  font-size: 13px;
  line-height: 1.55;
}

.prescription-approval-card b {
  flex: none;
  color: var(--text-muted, #64727a);
  font-size: 12px;
}

.prescription-approval-card .approval-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.work-table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.work-table .cell-strong {
  font-weight: 700;
}

.work-table .cell-sub {
  color: var(--text-soft, #7a878c);
}

.work-table .row-action-button {
  width: 100%;
  min-height: 28px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.work-table .table-action-stack {
  display: grid;
  gap: 5px;
  min-width: 92px;
}

.work-table .table-action-stack .small {
  width: 100%;
  min-height: 28px;
  padding: 5px 8px;
  white-space: nowrap;
}

.risk-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 40px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  text-align: center;
}

.risk-tag .status-spinner,
button .status-spinner.tiny {
  width: 12px;
  height: 12px;
  border-width: 2px;
  flex: 0 0 auto;
}

.risk-tag.is-high { background: #fee2e2; color: #b42318; }
.risk-tag.is-medium { background: #fef3c7; color: #92400e; }
.risk-tag.is-normal { background: #e0f2fe; color: #075985; }
.risk-tag.is-pending { background: var(--accent-soft, #eff6ff); color: var(--accent-strong, #1d4ed8); }

.table-empty {
  padding: 28px 16px;
  color: var(--text-soft, #7a878c);
  text-align: center;
  font-size: 13px;
}

/* ---------------------------------------------------------------- 상세 칸 */
.detail-head {
  align-items: flex-start;
}

.detail-title {
  min-width: 0;
  flex: 1;
}

.detail-title h2 {
  margin: 0 0 2px;
  font-size: 15px;
}

.detail-title span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--text-muted, #64727a);
  font-size: 12.5px;
  line-height: 1.5;
}

.agent-detail .ai-safety-note {
  flex: none;
  margin: 0;
  padding: 9px 14px;
  border-top: 1px solid var(--line, #e2e8f0);
  background: var(--surface-soft, #f8fafc);
  color: var(--text-soft, #7a878c);
  font-size: 11.5px;
}

/* ---------------------------------------------------------------- 실행 내역
 * 처리 계획과 도구 목록은 진단용이다. 기본으로 접어 두어 본 작업 공간을 뺏지 않는다. */
.agent-trace {
  flex: none;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  background: var(--surface, #ffffff);
}

.agent-trace > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  color: var(--text-muted, #64727a);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.agent-trace > summary::-webkit-details-marker { display: none; }
.agent-trace > summary b { color: var(--accent-strong, #1d4ed8); font-size: 12px; }
.agent-trace[open] > summary b::after { content: " ▲"; }
.agent-trace:not([open]) > summary b::after { content: " ▼"; }

.trace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  padding: 4px 14px 14px;
  max-height: 30vh;
  overflow: auto;
}

.trace-grid h3 {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--text-muted, #64727a);
}

.trace-grid ol {
  margin: 0;
  padding-inline-start: 18px;
  font-size: 12.5px;
  line-height: 1.7;
}

@media (max-width: 1100px) {
  .agent-shell {
    height: auto;
    margin: 0;
    max-width: none;
    padding-inline: 12px;
  }

  .agent-split {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .agent-split-resize {
    display: none;
  }

  .agent-pane .pane-body {
    max-height: 60vh;
  }
}

/* ---------------------------------------------------------------- 화면별 보정 */
.agent-bar .bar-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.agent-bar .bar-title h1 {
  margin: 0;
  font-size: 18px;
}

.agent-bar .bar-title span {
  color: var(--text-muted, #64727a);
  font-size: 12.5px;
}

.agent-bar .bar-actions {
  margin-top: 8px;
}

/* 수신함 탭은 컴포저 자리에 온다. */
.agent-bar .inbox-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.agent-pane .pane-foot {
  flex: none;
  margin: 0;
  padding: 7px 12px;
  border-top: 1px solid var(--line, #e2e8f0);
  background: var(--surface-soft, #f8fafc);
  color: var(--text-soft, #7a878c);
  font-size: 11.5px;
}

/* 상세 칸 안의 기존 카드가 제 폭을 넘기지 않게 한다. */
.agent-detail .pane-body img,
.agent-detail .pane-body table {
  max-width: 100%;
}

.ai-analytics-visual {
  display: grid;
  gap: 14px;
}

.ai-analytics-result {
  padding: 12px;
}

.ai-analytics-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ai-analytics-kpis article {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-analytics-kpis span {
  display: block;
  color: var(--text-muted, #64727a);
  font-size: 11.5px;
  font-weight: 700;
}

.ai-analytics-kpis strong {
  display: block;
  margin-top: 4px;
  color: var(--text, #0f172a);
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.ai-analytics-section.primary {
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.ai-direct-result {
  padding: 14px;
}

.ai-direct-result-head {
  margin-bottom: 12px;
}

.ai-direct-result-head strong {
  display: block;
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
}

.ai-direct-result-head p {
  margin: 5px 0 0;
  color: #52657a;
  font-size: 13px;
}

.ai-direct-result .ai-answer-list,
.ai-direct-detail .ai-answer-list {
  display: grid;
  gap: 10px;
}

.ai-direct-detail .ai-answer-list.compact .answer-row {
  padding: 10px;
}

.ai-direct-detail .ai-answer-list.compact .answer-text,
.ai-direct-detail .ai-answer-list.compact .answer-section p,
.ai-direct-detail .ai-answer-list.compact .answer-section li {
  font-size: 12px;
}

.ai-analytics-section.is-highlighted,
.answer-table-section.is-highlighted {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.12);
  transition: outline-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-weight-summary-table tbody tr {
  cursor: pointer;
}

.ai-adherence-patient-table tbody tr {
  cursor: pointer;
}

.ai-adherence-report-table {
  min-width: 760px;
}

.ai-adherence-report-table th,
.ai-adherence-report-table td {
  white-space: nowrap;
}

.ai-adherence-report-table th:nth-child(2),
.ai-adherence-report-table td:nth-child(2),
.ai-adherence-report-table th:nth-child(6),
.ai-adherence-report-table td:nth-child(6) {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-weight-summary-table tbody tr:hover,
.ai-weight-summary-table tbody tr:focus,
.ai-weight-summary-table tbody tr.is-selected,
.ai-adherence-patient-table tbody tr:hover,
.ai-adherence-patient-table tbody tr:focus,
.ai-adherence-patient-table tbody tr.is-selected {
  background: #eff6ff;
  outline: 2px solid #bfdbfe;
  outline-offset: -2px;
}

.ai-weight-chart-shell {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.ai-weight-chart-shell.is-dragging {
  cursor: grabbing;
}

.ai-analytics-bar-row.is-good .ai-analytics-bar-track b {
  background: #16a34a;
}

.ai-analytics-bar-row.is-watch .ai-analytics-bar-track b {
  background: #f59e0b;
}

.ai-analytics-bar-row.is-risk .ai-analytics-bar-track b {
  background: #dc2626;
}

.ai-analytics-note {
  margin: 0;
  color: var(--text-muted, #64727a);
  font-size: 12.5px;
  line-height: 1.55;
}

body.modal-open {
  overflow: hidden;
}

.followup-detail-modal-card {
  width: min(1040px, calc(100vw - 32px));
}

.followup-detail-modal-body {
  background: #f8fbff;
}

.followup-detail-modal-content {
  display: grid;
  gap: 14px;
}

.followup-detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.followup-detail-summary div {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: var(--surface, #fff);
  padding: 11px 12px;
}

.followup-detail-summary span {
  color: var(--text-muted, #64727a);
  font-size: 12px;
  font-weight: 800;
}

.followup-detail-summary strong {
  min-width: 0;
  color: var(--text, #0f172a);
  font-size: 14px;
  overflow-wrap: anywhere;
}

@media (max-width: 780px) {
  .followup-detail-summary {
    grid-template-columns: 1fr;
  }

  .followup-detail-modal {
    padding: 12px;
  }
}

.ai-analytics-pie-wrap {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.ai-analytics-pie {
  width: 150px;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.72), 0 0 0 1px var(--line, #e2e8f0);
}

.ai-analytics-pie-legend {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.ai-analytics-pie-legend div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  color: var(--text, #0f172a);
  font-size: 12.5px;
}

.ai-analytics-pie-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.ai-analytics-pie-legend span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.ai-analytics-pie-legend strong {
  font-size: 12.5px;
}

.ai-analytics-pie-legend em {
  color: var(--text-muted, #64727a);
  font-size: 12px;
  font-style: normal;
}

@media (max-width: 720px) {
  .ai-analytics-pie-wrap {
    grid-template-columns: 1fr;
  }

  .ai-analytics-pie {
    justify-self: center;
  }
}

/* 각 화면의 기존 `main` 규칙(폭 제한·바깥 여백)이 작업대 레이아웃을 밀어낸다.
   요소+클래스로 특이도를 맞추고 workbench.css가 뒤에 실려 이긴다. */
body main.agent-shell {
  width: auto;
  max-width: 1640px;
  margin: 0 auto;
}

body main.vet-home-container.agent-shell {
  width: min(1840px, calc(100% - 20px));
  max-width: none;
  margin: 18px auto;
  padding-inline: 0;
}

body.prescription-management-page main.agent-shell {
  width: min(1840px, calc(100% - 20px));
  max-width: none;
  padding-inline: 0;
}

/* 수신함은 상세가 레시피 전문이라 오른쪽이 더 필요하고, 목록은 제목 한 열이라
   좁혀야 빈 공간이 줄어든다. 화면 성격에 따라 분할 비율을 달리한다. */
.prescription-inbox-page .agent-split {
  grid-template-columns:
    minmax(300px, calc(var(--agent-split-left, 30%) - 5px))
    10px
    minmax(560px, calc(100% - var(--agent-split-left, 30%) - 5px));
}

/* 처방식 관리는 오른쪽 레시피 상세가 주 작업 영역이다. 목록은 상태/환자/질환을
   스캔할 정도로만 두고, 상세 폭을 넓혀 영양소 표와 설명문이 겹치지 않게 한다. */
.prescription-management-page .agent-split {
  grid-template-columns:
    minmax(520px, calc(var(--agent-split-left, 50%) - 5px))
    10px
    minmax(520px, calc(100% - var(--agent-split-left, 50%) - 5px));
}

.prescription-management-page .agent-detail .pane-body {
  padding: 12px;
}

.prescription-management-page .work-table.prescription-management-table {
  min-width: 671px;
}

.prescription-management-page .work-table.prescription-management-table th,
.prescription-management-page .work-table.prescription-management-table td {
  padding-inline: 8px;
}

.prescription-management-page .work-table.prescription-management-table .management-actions {
  justify-content: flex-start;
}

.prescription-management-page .work-table.prescription-management-table .management-actions button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  body main.vet-home-container.agent-shell {
    width: auto;
    margin: 0;
    padding-inline: 12px;
  }

  .prescription-inbox-page .agent-split {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .prescription-inbox-page .agent-split-resize {
    display: none;
  }

  body.prescription-management-page main.agent-shell {
    width: auto;
    padding-inline: 12px;
  }

  .prescription-management-page .agent-split {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .prescription-management-page .agent-split-resize {
    display: none;
  }
}
#aiLimitValueForm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
#aiLimitValueForm input {
  width: 140px;
  max-width: 100%;
  min-height: 36px;
  box-sizing: border-box;
}
#aiLimitValueForm label {
  flex-basis: 100%;
}
#aiGenerationTargetForm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
#aiGenerationTargetForm label {
  flex-basis: 100%;
}
#aiGenerationTargetForm select {
  min-height: 36px;
  max-width: 100%;
}
.weight-explorer-search {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
body.weight-explorer-mode .ai-answer-list {
  grid-template-columns: minmax(0, 1fr);
}
body.weight-explorer-mode .answer-row {
  min-width: 0;
}
.weight-explorer-search label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.weight-explorer-search input {
  flex: 1 1 220px;
  min-width: 0;
  max-width: 100%;
}
#aiWeightPatientChoices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.ai-weight-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: #334155;
}
.ai-weight-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.ai-weight-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}
.prescription-result-summary {
  padding: 8px 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  background: #f7fafc;
  border-bottom: 1px solid #dce5ef;
  overflow-wrap: anywhere;
}

.followup-pagination {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  color: #334155;
  white-space: nowrap;
}

.followup-pagination-inline {
  position: sticky;
  top: 0;
  z-index: 6;
  flex: none;
  display: flex;
  justify-content: flex-end;
  min-height: 45px;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  margin: 0;
  border-bottom: 1px solid #dbe6f2;
  background: #f8fafc;
}

.followup-pagination span {
  font-weight: 600;
}
