:root {
  color-scheme: light;
  --ink: #18343c;
  --ink-soft: #405960;
  --muted: #71848a;
  --line: #dbe5e7;
  --line-strong: #c7d5d8;
  --paper: #ffffff;
  --canvas: #f3f7f8;
  --teal: #075d61;
  --teal-deep: #08464d;
  --teal-wash: #e7f2f1;
  --aqua: #d7efec;
  --amber: #8b5a12;
  --amber-wash: #fff5df;
  --red: #a43b35;
  --red-wash: #fff0ee;
  --radius: 12px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a, select, input, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #4b9d9d;
  outline-offset: 2px;
}
button:disabled, select:disabled, input:disabled, textarea:disabled { cursor: not-allowed; opacity: .62; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  min-height: 62px; padding: 0 26px; display: flex; align-items: center; gap: 24px;
  background: var(--teal-deep); color: #f4fbfa; border-bottom: 1px solid #063d43;
}
.wordmark { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -.04em; font-size: 17px; white-space: nowrap; }
.wordmark-mark { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 8px 8px 8px 3px; background: #d9f1ec; color: var(--teal-deep); font-weight: 800; font-size: 16px; }
.wordmark-light { color: #b9d7d4; font-weight: 480; }
.environment-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid #518084; border-radius: 6px; color: #e2f2ef; background: #0b565c; font-size: 12px; font-weight: 680; letter-spacing: -.01em; }
.status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #d9b65f; box-shadow: 0 0 0 3px #d9b65f24; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 11px; color: #c0d5d4; font-size: 12px; }
.meta-divider { height: 15px; width: 1px; background: #638588; }
.mobile-tabs { display: none; }
.global-notice { width: min(100% - 40px, 1640px); margin: 10px auto 0; padding: 10px 13px; border: 1px solid #c7ddda; border-left: 3px solid #42877e; border-radius: 7px; color: #365b5b; background: #eff7f5; font-size: 12px; line-height: 1.45; }
.global-notice[hidden] { display: none; }
.global-notice.is-error { border-color: #e8c5c1; border-left-color: var(--red); color: #853a35; background: var(--red-wash); }
.actor-switch { max-width: 130px; padding: 5px 22px 5px 7px; border: 1px solid #63888a; border-radius: 5px; color: #eaf5f3; background: #0b565c; font-size: 11px; }

.workspace { flex: 1; width: min(100%, 1680px); margin: 0 auto; padding: 18px 20px 22px; display: grid; grid-template-columns: 250px minmax(420px, 1fr) 300px; align-items: start; gap: 14px; }
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px #153e4410; }
.queue-panel { height: calc(100dvh - 112px); min-height: 0; max-height: calc(100dvh - 112px); padding: 17px 13px 13px; display: flex; flex-direction: column; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.queue-heading { align-items: center; padding: 1px 3px 14px; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 11px; line-height: 1.25; font-weight: 740; letter-spacing: .005em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 19px; line-height: 1.25; letter-spacing: -.035em; font-weight: 730; }
h2 { margin: 0; font-size: 16px; line-height: 1.35; letter-spacing: -.025em; font-weight: 720; }
h3 { margin: 0; font-size: 13px; letter-spacing: -.015em; font-weight: 740; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--teal); cursor: pointer; }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover { background: var(--teal-wash); border-color: #a6c6c4; }
.queue-filter-row { min-height: 35px; padding: 0 3px 10px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.queue-count { font-size: 12px; color: var(--muted); }
.queue-count strong { margin-left: 4px; color: var(--ink); font-size: 13px; }
.text-button { padding: 5px 2px; border: 0; background: none; color: var(--teal); font-size: 12px; font-weight: 680; cursor: pointer; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.topbar .text-button { color: #e2f2ef; }
.topbar .text-button:focus-visible { outline-color: #e2f2ef; }
.queue-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #c3d4d5 transparent; display: flex; flex-direction: column; gap: 6px; padding: 8px 2px 2px 0; }
.queue-item { width: 100%; padding: 11px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; text-align: left; color: var(--ink); background: #fff; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.queue-item:hover { background: #f5f9f9; border-color: var(--line); }
.queue-item[aria-current="true"] { background: var(--teal-wash); border-color: #a4c8c5; box-shadow: inset 3px 0 0 var(--teal); }
.queue-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 730; }
.queue-item-time { color: var(--muted); font-size: 11px; }
.queue-item-meta { grid-column: 1 / -1; color: var(--muted); font-size: 11px; line-height: 1.35; }
.queue-item.is-late .queue-item-name { font-weight: 820; }
.queue-item.is-completed { text-decoration: line-through; color: #728287; }
.queue-item.is-completed .queue-item-meta { text-decoration: none; }
.queue-footnote { margin: auto 3px 0; padding-top: 18px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.empty-state { min-height: 194px; padding: 26px 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; text-align: center; color: var(--muted); }
.empty-state strong { max-width: 190px; color: var(--ink-soft); font-size: 12px; line-height: 1.45; }
.empty-state > span:last-child { max-width: 190px; font-size: 11px; line-height: 1.45; }
.empty-symbol { width: 33px; height: 33px; display: grid; place-items: center; color: var(--teal); border: 1px solid #bcd7d5; border-radius: 50%; font-size: 20px; }

.consult-panel { overflow: hidden; }
.patient-header { padding: 13px 20px 11px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fbfdfd 0%, #fff 100%); }
.patient-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.patient-title-row h1 { max-width: 510px; }
.state-pill { flex: 0 0 auto; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #f8fafb; font-size: 10px; font-weight: 700; }
.state-pill.is-warning { color: var(--amber); background: var(--amber-wash); border-color: #eed49e; }
.state-pill.is-ready { color: var(--teal); background: var(--teal-wash); border-color: #b8d8d5; }
.contact-grid { display: grid; grid-template-columns: 1fr; gap: 4px; margin-top: 9px; }
.contact-tile { min-width: 0; min-height: 44px; padding: 4px 8px; display: grid; grid-template-columns: 110px minmax(0, 1fr) 58px; align-items: center; gap: 5px 9px; background: #f5f8f8; border: 1px solid #e3ebec; border-radius: 7px; }
.contact-tile > span { color: var(--muted); font-size: 10px; font-weight: 660; }
.contact-tile strong { overflow-wrap: anywhere; font-size: 14px; line-height: 1.25; letter-spacing: -.025em; font-weight: 760; min-height: 18px; }
.call-button { min-width: 49px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; color: #fff; background: var(--teal); border-radius: 6px; text-decoration: none; font-size: 12px; font-weight: 740; }
.call-button:hover { background: #064b4f; }
.call-button[aria-disabled="true"] { pointer-events: none; background: #d9e2e3; color: #697d81; }
.identity-strip { min-height: 30px; margin-top: 5px; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 10px; }
.identity-strip strong { color: var(--ink-soft); font-size: 12px; font-weight: 680; letter-spacing: .03em; }
.mask-note { margin-left: auto; color: #849398; font-size: 10px; }
.patient-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 10px; padding-top: 6px; }
.facts-heading { margin: 5px 0 0; color: #829297; font-size: 9px; font-weight: 700; }
.patient-fact { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.patient-fact dt { color: #829297; font-size: 9px; line-height: 1.3; }
.patient-fact dd { margin: 0; color: #405960; font-size: 10px; line-height: 1.45; font-weight: 670; overflow-wrap: anywhere; }
.risk-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
.risk-strip[hidden] { display: none; }
.risk-strip-item { padding: 7px 9px; border: 1px solid #e0e9e9; border-radius: 6px; color: #506b70; background: #f5f8f8; font-size: 10px; line-height: 1.5; font-weight: 660; }
.guide-slot { padding: 0 20px; }
.guide-select { max-width: 100%; display: flex; align-items: center; gap: 9px; padding: 0 0 9px; color: var(--muted); font-size: 10px; }
.guide-select select { max-width: min(100%, 330px); min-height: 34px; padding: 5px 27px 5px 8px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink-soft); background: #fff; font-size: 11px; }
.guide-lines { margin: 0 0 10px; padding: 9px 11px; border-left: 3px solid #a6c7c4; border-radius: 0 6px 6px 0; color: #466369; background: #f4f9f8; font-size: 11px; line-height: 1.6; white-space: pre-line; }
.default-guide-details { margin: 0 0 8px; }
.default-guide-details summary { width: max-content; color: #71858a; font-size: 10px; line-height: 1.5; cursor: pointer; }
.default-guide-details summary::before { content: "+"; display: inline-block; width: 14px; color: var(--teal); font-weight: 750; }
.default-guide-details[open] summary::before { content: "−"; }
.mode-check-warning { margin: 0 20px 9px; padding: 8px 10px; border: 1px solid #efd7a5; border-radius: 6px; color: #76500f; background: var(--amber-wash); font-size: 10px; line-height: 1.5; }
.mode-check-warning[hidden] { display: none; }
.script-toolbar { padding: 11px 20px 8px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.script-toolbar .eyebrow { margin-bottom: 4px; }
.check-progress { min-width: 50px; padding: 6px 8px; text-align: center; color: var(--teal-deep); background: var(--teal-wash); border: 1px solid #cae0de; border-radius: 6px; font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 760; }
.script-list { padding: 0 12px 13px; display: flex; flex-direction: column; gap: 3px; }
.empty-script { min-height: 126px; padding: 22px 16px; display: flex; align-items: center; gap: 13px; color: var(--muted); }
.empty-script strong { color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.empty-script p { margin: 5px 0 0; font-size: 11px; line-height: 1.45; }
.script-line-mark { width: 4px; height: 44px; flex: 0 0 4px; background: #bad9d5; border-radius: 4px; }
.script-group { padding: 12px 10px 11px; border-bottom: 1px solid #e8eeee; }
.script-group:last-child { border-bottom: 0; }
.script-group-header { display: flex; align-items: flex-start; gap: 10px; }
.check-control { width: 23px; height: 23px; margin: 0; flex: 0 0 23px; accent-color: var(--teal); cursor: pointer; }
.group-toggle { flex: 1; min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.group-title { font-size: 13px; line-height: 1.45; font-weight: 760; letter-spacing: -.012em; }
.group-meta { color: var(--muted); font-size: 10px; white-space: nowrap; }
.script-lines { padding: 6px 0 0 33px; }
.script-line { padding: 4px 0 3px; }
.script-line-label { display: block; margin-bottom: 3px; color: #698087; font-size: 10px; line-height: 1.35; font-weight: 720; }
.script-speech { margin: 0; color: #29464e; font-size: 13px; line-height: 1.72; letter-spacing: -.01em; overflow-wrap: anywhere; }
.script-line.is-skipped .script-speech { color: #849397; text-decoration: line-through; }
.memo-control { width: 100%; min-height: 33px; margin-top: 7px; padding: 6px 8px; border: 1px solid #e0e9e9; border-radius: 6px; background: #fafcfc; color: var(--ink); font-size: 11px; resize: vertical; }
.memo-control::placeholder { color: #8b9b9e; }
.memo-details { margin-top: 6px; }
.memo-details summary { width: max-content; color: #7c8e92; font-size: 10px; line-height: 1.5; cursor: pointer; list-style: none; }
.memo-details summary::-webkit-details-marker { display: none; }
.memo-details summary::before { content: "+"; display: inline-block; width: 13px; color: var(--teal); font-weight: 750; }
.memo-details[open] summary::before { content: "−"; }
.script-secondary { padding: 0 20px 18px; display: grid; gap: 8px; }
.secondary-heading { margin: 2px 0 0; color: #71858a; font-size: 10px; font-weight: 720; }
.secondary-check { padding: 9px 10px; display: flex; align-items: flex-start; gap: 9px; color: var(--ink-soft); background: #f7f9f9; border-radius: 7px; font-size: 11px; line-height: 1.5; }
.secondary-check .check-control { width: 19px; height: 19px; flex-basis: 19px; }
.mode-context { padding: 10px; border-left: 3px solid #a6c7c4; background: #f4f9f8; border-radius: 0 7px 7px 0; }

.record-panel { position: sticky; top: 12px; max-height: calc(100vh - 82px); overflow-y: auto; padding: 18px 16px 14px; scrollbar-width: thin; scrollbar-color: #c3d4d5 transparent; }
.record-panel > .panel-heading { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.record-panel h2 { font-size: 17px; }
.record-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 8px; padding: 13px 0 14px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.field:nth-child(5), .field:nth-child(6) { grid-column: 1 / -1; }
.field > span { color: #536d73; font-size: 10px; font-weight: 730; }
.field select, .field textarea { width: 100%; min-width: 0; min-height: 38px; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: #fff; font-size: 11px; }
.field select { padding-right: 22px; }
.field textarea { min-height: 49px; line-height: 1.5; resize: vertical; }
.field select:disabled, .field textarea:disabled { color: #809095; background: #f7f9f9; }
.rx-section, .preview-section { padding: 13px 0; border-top: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.rx-grid { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.rx-head, .rx-row { display: grid; grid-template-columns: 1fr .72fr .85fr; align-items: center; gap: 5px; }
.rx-head { min-height: 28px; padding: 0 7px; color: #60777d; background: #f1f6f6; font-size: 9px; font-weight: 740; }
.rx-head span:not(:first-child) { text-align: center; }
.rx-row { min-height: 36px; padding: 4px 7px; border-top: 1px solid #e8eeee; }
.rx-row strong { font-size: 10px; font-weight: 720; }
.rx-row output { text-align: center; color: var(--ink-soft); font-size: 11px; font-variant-numeric: tabular-nums; }
.rx-row input { width: 100%; min-width: 0; height: 28px; padding: 3px 4px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.rx-row input:disabled { color: #839297; background: #f6f8f8; }
.effective-prescription { margin-top: 8px; padding: 8px 9px; display: flex; flex-direction: column; gap: 4px; border-left: 3px solid #6a9991; border-radius: 0 6px 6px 0; color: #49676a; background: #eff6f4; font-size: 10px; line-height: 1.5; }
.effective-prescription[hidden] { display: none; }
.effective-prescription strong { color: #38625d; font-size: 9px; }
.keep-order-button { width: 100%; min-height: 35px; margin-top: 8px; border: 1px solid #b8d1d0; border-radius: 6px; color: var(--teal-deep); background: #f3f9f8; font-size: 11px; font-weight: 740; cursor: pointer; }
.keep-order-button:not(:disabled):hover { background: var(--teal-wash); }
.field-hint { margin: 6px 1px 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.preview-box { min-height: 53px; padding: 10px; color: var(--ink-soft); background: #f7f9f9; border: 1px solid #e4ebec; border-radius: 6px; font-size: 10px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: #8b9a9e; }
.warning-list { display: grid; gap: 6px; padding-top: 7px; }
.warning-item { padding: 8px 9px; border: 1px solid #eed9ad; border-radius: 6px; color: #76500f; background: var(--amber-wash); font-size: 10px; line-height: 1.5; }
.error-item { border-color: #ecc6c2; color: #8e332f; background: var(--red-wash); }
.record-actions { padding-top: 11px; border-top: 1px solid var(--line); }
.primary-button { width: 100%; min-height: 43px; border: 0; border-radius: 7px; color: white; background: var(--teal); font-size: 13px; font-weight: 760; cursor: pointer; }
.primary-button:not(:disabled):hover { background: #064c51; }
.primary-button:disabled { color: #eef3f3; background: #9badaf; opacity: 1; }
.save-help { margin: 7px 1px 0; color: var(--muted); font-size: 10px; line-height: 1.45; text-align: center; }
.receipt { margin-top: 12px; padding: 11px 10px; display: flex; gap: 10px; border: 1px solid #b8d8d2; border-radius: 8px; background: #edf7f4; }
.receipt[hidden] { display: none; }
.receipt-icon { width: 24px; height: 24px; flex: 0 0 24px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #367d70; font-size: 13px; font-weight: 800; }
.receipt h3 { color: #225c53; }
.receipt p { margin: 4px 0; color: var(--ink-soft); font-size: 10px; line-height: 1.5; }
.receipt dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 9px; font-size: 9px; }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; color: var(--ink); font-weight: 660; overflow-wrap: anywhere; }
.app-footer { min-height: 31px; padding: 5px 25px 10px; display: flex; align-items: center; justify-content: space-between; color: #859397; font-size: 10px; }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 225px minmax(390px, 1fr); padding-inline: 14px; gap: 11px; }
  .record-panel { position: static; grid-column: 2; grid-row: 2; max-height: none; }
  .queue-panel { grid-column: 1; grid-row: 1 / span 2; }
  .record-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field:nth-child(5), .field:nth-child(6) { grid-column: auto; }
  .field:nth-child(5) { grid-column: span 2; }
  .field:nth-child(6) { grid-column: span 1; }
}

@media (max-width: 690px) {
  .topbar { min-height: 55px; padding: 0 14px; gap: 10px; }
  .wordmark { font-size: 15px; gap: 8px; }
  .wordmark-mark { width: 27px; height: 27px; }
  .environment-badge { margin-left: auto; padding: 6px 8px; gap: 6px; font-size: 10px; }
  .topbar-meta { display: flex; margin-left: 0; gap: 7px; font-size: 10px; }
  .actor-switch { max-width: 112px; padding: 4px 18px 4px 6px; font-size: 10px; }
  .mobile-tabs { display: none; }
  .tab-button { min-height: 35px; border: 0; border-radius: 6px; color: #64797f; background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
  .tab-button.is-active { color: var(--teal-deep); background: #dfefed; }
  .workspace { width: 100%; padding: 10px; grid-template-columns: minmax(205px, .72fr) minmax(0, 1.28fr); gap: 9px; }
  .queue-panel { grid-column: 1; grid-row: 1 / span 2; min-height: calc(100dvh - 146px); padding: 13px 8px 10px; }
  .consult-panel { grid-column: 2; grid-row: 1; }
  .record-panel { grid-column: 2; grid-row: 2; padding: 14px 12px 12px; }
  .queue-heading { padding: 0 2px 10px; }
  .queue-heading h1 { font-size: 16px; }
  .queue-heading .eyebrow { font-size: 10px; }
  .icon-button { width: 30px; height: 30px; flex-basis: 30px; }
  .queue-item { padding: 9px 7px; grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .queue-item-time { grid-row: 2; }
  .queue-item-meta { font-size: 10px; }
  .queue-footnote { font-size: 9px; }
  .patient-header { padding: 14px 12px 11px; }
  .patient-title-row h1 { font-size: 16px; }
  .state-pill { font-size: 9px; }
  .contact-grid { grid-template-columns: 1fr; gap: 5px; margin-top: 10px; }
  .contact-tile { min-height: 51px; padding: 6px 7px; grid-template-columns: 78px minmax(0, 1fr) 45px; gap: 4px; }
  .contact-tile > span { font-size: 9px; }
  .contact-tile strong { font-size: 12px; }
  .call-button { min-width: 43px; min-height: 44px; padding: 0 6px; font-size: 11px; }
  .identity-strip { gap: 6px; font-size: 9px; }
  .identity-strip strong { font-size: 10px; }
  .mask-note { font-size: 9px; }
  .script-toolbar { padding: 13px 12px 8px; align-items: center; }
  .script-toolbar h2 { font-size: 13px; }
  .check-progress { min-width: 43px; padding: 5px 6px; font-size: 10px; }
  .script-list { padding: 0 6px 10px; }
  .script-group { padding: 10px 7px; }
  .group-title { font-size: 12px; }
  .group-meta { font-size: 9px; }
  .script-lines { padding-left: 30px; }
  .script-speech { font-size: 12px; line-height: 1.66; }
  .script-secondary { padding: 0 12px 14px; }
  .record-panel > .panel-heading { padding-bottom: 10px; }
  .record-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 7px; }
  .field:nth-child(5), .field:nth-child(6) { grid-column: span 2; }
  .rx-head, .rx-row { grid-template-columns: 1fr .68fr .9fr; }
  .app-footer { padding-inline: 12px; font-size: 9px; }
}

@media (max-width: 430px) {
  .topbar { padding-inline: 11px; }
  .topbar { flex-wrap: wrap; padding-block: 7px; }
  .wordmark { order: 1; }
  .environment-badge { order: 2; }
  .topbar-meta { order: 3; flex-basis: 100%; justify-content: flex-end; }
  .mobile-tabs { position: sticky; top: 0; z-index: 20; min-height: 45px; padding: 5px 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-bottom: 1px solid var(--line); background: #f8fbfb; }
  .environment-badge { font-size: 9px; padding: 6px 7px; }
  .workspace { display: block; padding: 9px 9px 88px; }
  .workspace > .panel { display: none; }
  .workspace > .panel.is-visible { display: block; }
  .workspace > .queue-panel.is-visible { display: flex; }
  .queue-panel { height: calc(100dvh - 160px); min-height: 0; max-height: calc(100dvh - 160px); padding: 14px 11px 11px; }
  .consult-panel, .record-panel { min-height: calc(100dvh - 142px); max-height: none; }
  .queue-item { grid-template-columns: minmax(0, 1fr) auto; }
  .queue-item-time { grid-row: auto; }
  .queue-footnote { padding-top: 24px; }
  .patient-header { padding: 12px 13px 10px; }
  .patient-title-row h1 { font-size: 17px; }
  .contact-grid { grid-template-columns: 1fr; gap: 6px; }
  .contact-tile { min-height: 44px; padding: 4px 8px; grid-template-columns: 78px minmax(0, 1fr) 48px; gap: 5px; }
  .contact-tile > span { font-size: 10px; }
  .contact-tile strong { font-size: 13px; overflow-wrap: anywhere; }
  .call-button { min-height: 42px; }
  .identity-strip { min-height: 33px; }
  .patient-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 9px; }
  .patient-fact dt { font-size: 9px; }
  .patient-fact dd { font-size: 10px; }
  .script-toolbar { padding: 11px 13px 8px; }
  .guide-slot { padding-inline: 13px; }
  .script-toolbar h2 { font-size: 14px; }
  .script-list { padding-inline: 8px; }
  .mode-check-warning { margin-inline: 13px; }
  .script-group { padding: 12px 8px; }
  .group-title { font-size: 13px; }
  .script-lines { padding-left: 32px; }
  .script-speech { font-size: 13px; line-height: 1.72; }
  .record-panel { padding: 16px 13px 15px; }
  .record-actions { position: sticky; bottom: 0; z-index: 3; padding: 9px 0 max(9px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, #ffffffdd, #fff 22%); }
  .record-fields { grid-template-columns: 1fr 1fr; }
  .field select, .field textarea { min-height: 42px; font-size: 12px; }
  .field:nth-child(5), .field:nth-child(6) { grid-column: 1 / -1; }
  .rx-head { min-height: 31px; font-size: 10px; }
  .rx-row { min-height: 42px; }
  .rx-row strong, .rx-row output { font-size: 12px; }
  .rx-row input { height: 33px; font-size: 14px; }
  .primary-button { min-height: 48px; font-size: 14px; }
  .app-footer { padding-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
/* Authentication is a small addition to the existing clinic layout. */
.login-panel { max-width: 640px; margin: 48px auto; padding: 28px; border: 1px solid #cddadf; border-radius: 16px; background: white; }
.login-panel p { line-height: 1.7; }
.login-panel button { padding: 12px 20px; cursor: pointer; }
.company-login form { display: grid; gap: 10px; max-width: 420px; }
.company-login label { font-weight: 650; margin-top: 8px; }
.company-login input { width: 100%; min-width: 0; padding: 12px; border: 1px solid #a9bbc3; border-radius: 8px; font: inherit; }
.company-login input:focus-visible, .company-login button:focus-visible { outline: 3px solid #538eaa; outline-offset: 3px; }
.company-login .password-field { display: flex; gap: 8px; }
.company-login .password-toggle { flex: 0 0 auto; border: 1px solid #a9bbc3; border-radius: 8px; background: #f5f8fa; font: inherit; }
.company-login .primary-button { margin-top: 14px; }
.company-login .login-help { color: #546773; font-size: 14px; }
.company-login [role="alert"]:empty { display: none; }
.company-login [role="alert"] { color: #a12a22; }
@media (max-width: 600px) { .login-panel { margin: 24px 16px; padding: 22px; } }
[hidden] { display: none !important; }
.secondary-line { padding-block: 8px; }
.secondary-line .memo-details { margin: 7px 0 0 28px; }
.secondary-line textarea { width: 100%; }
.script-line.is-unavailable .script-speech { color: #6b7277; }
.information-dialog { width: min(920px, calc(100vw - 32px)); max-height: 85dvh; padding: 20px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink, #233b43); background: #fff; }
.information-dialog::backdrop { background: #20343b66; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; position: sticky; top: -20px; padding-block: 8px; background: white; z-index: 1; }
.dialog-heading h2 { font-size: 18px; }
#reference-content p { white-space: pre-wrap; line-height: 1.75; margin-block: 10px; }
.board-scroll { overflow: auto; max-height: 60dvh; }
.consult-board { border-collapse: collapse; width: 100%; font-size: 12px; }
.consult-board th, .consult-board td { min-width: 125px; padding: 10px; border: 1px solid var(--line); white-space: pre-wrap; vertical-align: top; }
.consult-board th { background: #f2f7f6; position: sticky; top: 0; }
.consult-board .is-completed { text-decoration: line-through; }
.consult-board .is-late { font-weight: 700; }
.freshness-warning { color: #9b431f; }
@media (max-width: 690px) { .information-dialog { padding: 12px; } .topbar-meta { flex-wrap: wrap; } .dialog-heading { top: -12px; } }
