:root {
  color-scheme: light;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-soft: #eaf4ff;
  --green: #248a3d;
  --green-soft: #eaf7ed;
  --orange: #c93400;
  --orange-soft: #fff0e9;
  --red: #d70015;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #86868b;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --surface: rgba(255, 255, 255, .94);
  --background: #f5f5f7;
  --idle: #a1a1a6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .05);
}

* { box-sizing: border-box; }

html { background: var(--background); }

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
  background: rgba(250, 250, 252, .82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.topbar__inner, .page-shell { width: min(1420px, calc(100% - 40px)); margin: 0 auto; }
.topbar__inner { min-height: 72px; display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 38px;
  height: 55px;
  object-fit: contain;
  flex: 0 0 auto;
}

h1 { font-size: 19px; line-height: 1.2; font-weight: 650; }
h2 { font-size: 18px; line-height: 1.25; font-weight: 650; }
.brand-copy p, .panel-heading p, .registration-heading p { margin-top: 4px; color: var(--secondary); font-size: 12px; }
.current-time { margin-left: auto; color: var(--text); font-size: 15px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.topnav { margin-left: auto; display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 8px; background: rgba(118, 118, 128, .08); }
.topnav a { min-height: 34px; padding: 0 12px; display: grid; place-items: center; border-radius: 6px; color: var(--secondary); text-decoration: none; font-weight: 600; font-size: 13px; }
.topnav a:hover { color: var(--text); background: rgba(255, 255, 255, .72); }
.topnav a.active { color: var(--text); background: white; box-shadow: 0 1px 4px rgba(0, 0, 0, .09); }
.topnav + .current-time { margin-left: 14px; }

.page-shell { padding: 28px 0 56px; }
.dashboard { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(410px, .85fr); gap: 18px; align-items: start; }
.panel, .registration { border: 1px solid rgba(0, 0, 0, .08); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.panel, .registration { animation: surface-enter .42s cubic-bezier(.22, 1, .36, 1) both; }
.dashboard .panel:nth-child(2) { animation-delay: .06s; }
.page-shell > .registration { animation-delay: .1s; }
.panel { min-height: 570px; overflow: hidden; }
.panel-heading, .registration-heading { min-height: 72px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.live-dot { animation: status-breathe 2.4s ease-in-out infinite; }
.instrument-summary { color: var(--green); font-weight: 650; font-variant-numeric: tabular-nums; }

.instrument-grid { padding: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.instrument-card { min-height: 90px; padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: 8px; background: #fbfbfd; transition: border-color .2s ease, background .2s ease, transform .2s ease; }
.instrument-card:hover { border-color: #c7c7cc; background: white; }
.instrument-card--active { border-color: #b8dfc1; background: var(--green-soft); }
.instrument-card--ending { border-color: #ffc8ad; background: var(--orange-soft); }
.instrument-card__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.instrument-card h3 { font-size: 15px; font-weight: 650; }
.status-label { flex: 0 0 auto; color: var(--secondary); font-size: 12px; font-weight: 600; }
.status-label::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--idle); }
.instrument-card--active .status-label { color: var(--green); }
.instrument-card--active .status-label::before { background: var(--green); }
.instrument-card--active .status-label::before { animation: status-breathe 2s ease-in-out infinite; }
.instrument-card--ending .status-label { color: var(--orange); }
.instrument-card--ending .status-label::before { background: var(--orange); }
.instrument-card__detail { min-height: 19px; margin-top: 9px; display: flex; justify-content: space-between; gap: 8px; color: var(--secondary); font-size: 12px; }
.patient-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.countdown { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.progress { height: 4px; margin-top: 9px; overflow: hidden; border-radius: 2px; background: #e5e5ea; }
.progress__bar { height: 100%; width: 0; border-radius: 2px; background: var(--idle); transition: width .3s linear; }
.instrument-card--active .progress__bar { background: var(--green); }
.instrument-card--ending .progress__bar { background: #ff9f0a; }

.queue-list { max-height: 501px; overflow: auto; scrollbar-width: thin; scrollbar-color: #c7c7cc transparent; }
.queue-order-wrap { border-bottom: 1px solid var(--line-soft); background: #fbfbfd; }
.queue-order-title { padding: 11px 14px 8px; display: flex; align-items: center; justify-content: space-between; }
.queue-order-title strong { font-size: 13px; }
.queue-order-title span { color: var(--tertiary); font-size: 11px; }
.queue-order-scroll { overflow-x: auto; scrollbar-width: thin; }
.queue-order-table { width: 100%; border-collapse: collapse; }
.queue-order-table th, .queue-order-table td { padding: 9px 10px; border-top: 1px solid var(--line-soft); text-align: left; vertical-align: middle; font-size: 12px; }
.queue-order-table th { color: var(--tertiary); font-weight: 600; background: #f5f5f7; }
.queue-matrix { min-width: max-content; table-layout: fixed; }
.queue-matrix th, .queue-matrix td { width: 112px; min-width: 112px; text-align: center; }
.queue-matrix .queue-matrix-corner, .queue-matrix .queue-matrix-rank { position: sticky; left: 0; z-index: 2; width: 68px; min-width: 68px; }
.queue-matrix .queue-matrix-corner { z-index: 3; }
.queue-matrix .queue-matrix-rank { color: var(--text); background: #f5f5f7; font-weight: 700; }
.queue-matrix-patient { margin: 2px 0; padding: 7px 6px; border-radius: 6px; background: var(--blue-soft); text-align: left; }
.queue-matrix-patient--active { background: var(--green-soft); }
.queue-matrix-patient--paused { background: #fff7e6; }
.queue-matrix-patient small { display: block; color: var(--secondary); font-size: 10px; line-height: 1.35; }
.queue-matrix-patient strong { display: block; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.queue-matrix-empty { color: var(--tertiary); }
.queue-table-status { display: inline-flex; padding: 4px 6px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 700; white-space: nowrap; }
.queue-table-status--active { background: var(--green-soft); color: var(--green); }
.queue-table-status--paused { background: #fff7e6; color: #8a5b00; }
.queue-table-status--waiting { background: var(--blue-soft); color: var(--blue); }
.queue-order-empty { padding: 26px 14px; color: var(--secondary); text-align: center; }
.queue-item { padding: 16px 18px; border-bottom: 1px solid var(--line-soft); background: rgba(255, 255, 255, .5); }
.queue-item:last-child { border-bottom: 0; }
.queue-item__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.queue-item__controls { display: flex; align-items: center; gap: 7px; }
.queue-item h3 { font-size: 16px; font-weight: 650; }
.queue-status { padding: 4px 9px; border-radius: 7px; background: #f2f2f7; color: var(--secondary); font-size: 12px; font-weight: 600; }
.queue-status--active { background: var(--green-soft); color: var(--green); }
.queue-status--paused { background: #fff7e6; color: #9a6700; }
.queue-status--waiting { background: var(--blue-soft); color: var(--blue); }
.delete-patient, .add-patient-item { min-height: 28px; padding: 0 8px; border: 0; border-radius: 6px; font-size: 12px; font-weight: 600; }
.delete-patient { background: #fff0f1; color: var(--red); }
.add-patient-item { background: var(--blue-soft); color: var(--blue); }
.queue-meta { margin-top: 11px; display: grid; gap: 6px; color: var(--secondary); font-size: 12px; }
.queue-meta div { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 6px; }
.queue-meta dt { color: var(--tertiary); }
.queue-meta dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.queue-actions { display: flex; gap: 8px; }
.queue-actions { flex-wrap: wrap; }
.queue-wait-hint { width: 100%; margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #f2f2f7; color: var(--secondary); text-align: center; font-size: 12px; }
.start-treatment, .pause-treatment, .cancel-treatment { flex: 1; min-height: 40px; margin-top: 12px; border-radius: 8px; font-weight: 650; }
.start-treatment { border: 0; background: var(--blue); color: white; box-shadow: 0 1px 2px rgba(0, 113, 227, .18); }
.start-treatment:hover, #submit-button:hover, .primary-button:hover, .compact-form button:hover { background: var(--blue-hover); }
.cancel-treatment { border: 1px solid #ffc7cd; background: white; color: var(--red); }
.pause-treatment { border: 1px solid #f0c36d; background: #fffaf0; color: #8a5b00; }
.start-treatment:disabled, .pause-treatment:disabled, .cancel-treatment:disabled, .delete-patient:disabled { opacity: .48; cursor: wait; }
.start-treatment:active, .cancel-treatment:active, .delete-patient:active, #submit-button:active, .primary-button:active, .compact-form button:active, .file-button:active { transform: scale(.985); }
.empty-state { grid-column: 1 / -1; padding: 58px 20px; color: var(--secondary); text-align: center; }

.patient-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--background); }
.patient-shell { width: min(100%, 520px); padding: 28px; border: 1px solid rgba(0, 0, 0, .08); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); animation: surface-enter .42s cubic-bezier(.22, 1, .36, 1) both; }
.patient-checkin-shell { max-width: 460px; }
.patient-checkin-shell .patient-form { display: grid; gap: 16px; }
.patient-checkin-shell .patient-message { margin-top: 0; }
.patient-checkin-shell .field span { font-size: 14px; }
.patient-checkin-shell .patient-submit { min-height: 54px; font-size: 16px; box-shadow: 0 8px 20px rgba(0, 113, 227, .2); }
.patient-checkin-result { margin-top: 24px; padding: 22px 18px; display: grid; justify-items: center; gap: 6px; border: 1px solid #b8dfc1; border-radius: 8px; background: var(--green-soft); text-align: center; }
.patient-checkin-result[hidden] { display: none; }
.patient-checkin-result p { color: var(--green); font-weight: 700; }
.patient-checkin-result strong { margin-top: 3px; color: var(--green); font-size: 52px; line-height: 1; font-variant-numeric: tabular-nums; }
.patient-checkin-result span { color: var(--text); font-size: 14px; font-weight: 650; }
.patient-checkin-result small { margin-top: 8px; color: var(--secondary); font-size: 12px; }
.patient-header { display: flex; align-items: center; gap: 14px; padding-bottom: 22px; border-bottom: 1px solid var(--line-soft); }
.patient-logo { width: 34px; height: 50px; object-fit: contain; flex: 0 0 auto; }
.patient-eyebrow { color: var(--secondary); font-size: 12px; font-weight: 650; }
.patient-header h1 { margin-top: 3px; font-size: 24px; }
.patient-subtitle { margin-top: 6px; color: var(--secondary); font-size: 13px; }
.patient-form { padding-top: 24px; }
.patient-projects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.patient-project input { position: absolute; opacity: 0; pointer-events: none; }
.patient-project span { min-height: 48px; padding: 8px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fbfbfd; color: var(--text); text-align: center; cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .12s ease; }
.patient-project span:hover { background: white; border-color: #a1a1a6; }
.patient-project input:checked + span { border-color: var(--blue); background: var(--blue-soft); color: #0058b0; font-weight: 650; }
.patient-project input:focus-visible + span { outline: 4px solid rgba(0, 113, 227, .13); outline-offset: 1px; }
.patient-middle-area { max-width: none; margin-top: 15px; }
.patient-middle-area[hidden] { display: none; }
.patient-message { min-height: 20px; margin-top: 18px; color: var(--secondary); font-size: 13px; text-align: center; }
.patient-message--error { color: var(--red); }
.patient-message--success { color: var(--green); }
.patient-error { grid-column: 1 / -1; color: var(--red); text-align: center; }
.patient-submit { width: 100%; min-height: 48px; margin-top: 8px; border: 0; border-radius: 8px; background: var(--blue); color: white; font-weight: 650; box-shadow: 0 1px 2px rgba(0, 113, 227, .18); transition: transform .12s ease, background .18s ease, opacity .12s ease; }
.patient-submit:hover { background: var(--blue-hover); }
.patient-submit:active { transform: scale(.985); }
.patient-submit:disabled { cursor: wait; opacity: .48; }
.patient-submit.is-loading { opacity: .72; }
.patient-footer { margin-top: 19px; color: var(--tertiary); font-size: 12px; text-align: center; }
.patient-qr { margin: 18px auto 0; padding-top: 16px; border-top: 1px solid var(--line-soft); display: grid; justify-items: center; gap: 6px; color: var(--tertiary); font-size: 11px; }
.patient-qr img { width: 112px; height: 112px; padding: 7px; border: 1px solid var(--line-soft); border-radius: 8px; background: white; }

.registration { margin-top: 18px; }
.registration form { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid--single { grid-template-columns: minmax(240px, 520px); }
.field { display: grid; gap: 8px; color: var(--text); font-weight: 600; font-size: 13px; }
.field-note { margin: 0; color: var(--secondary); font-size: 12px; font-weight: 500; }
em { color: var(--red); font-style: normal; }
input[type="text"], input[type="tel"], input[type="datetime-local"], input[type="date"], select { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .9); color: var(--text); outline: none; transition: border-color .15s ease, box-shadow .15s ease; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, .13); }
fieldset { min-width: 0; margin: 21px 0 0; padding: 0; border: 0; }
legend { margin-bottom: 11px; font-size: 13px; font-weight: 600; }
.project-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.project-option input, .segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.project-option span { min-height: 42px; padding: 8px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fbfbfd; color: var(--text); text-align: center; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.project-option span:hover { background: white; border-color: #a1a1a6; }
.project-option input:checked + span { border-color: var(--blue); background: var(--blue-soft); color: #0058b0; font-weight: 650; }
.project-option input:checked + span { animation: option-select .18s ease-out; }
.project-option input:focus-visible + span, .segmented-control input:focus-visible + span { outline: 4px solid rgba(0, 113, 227, .18); outline-offset: 1px; }
.middle-area { max-width: 360px; margin-top: 13px; }
.middle-area[hidden] { display: none; }
.segmented-control { width: 180px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented-control label + label { border-left: 1px solid var(--line); }
.segmented-control span { height: 40px; display: grid; place-items: center; background: white; cursor: pointer; }
.segmented-control input:checked + span { background: var(--blue); color: white; font-weight: 650; }
.manual-times { margin-top: 13px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.manual-times[hidden] { display: none; }
.form-actions { min-height: 44px; margin-top: 24px; display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.form-message { color: var(--secondary); }
.form-message--error { color: var(--red); }
.form-message--success { color: var(--green); }
#submit-button, .compact-form button, .primary-button { min-height: 42px; padding: 0 17px; border: 0; border-radius: 8px; background: var(--blue); color: white; font-weight: 650; box-shadow: 0 1px 2px rgba(0, 113, 227, .18); }
#submit-button { min-width: 174px; }
#submit-button:disabled { cursor: wait; opacity: .48; }
.form-loading { color: var(--secondary); }

.page-stack { display: grid; gap: 18px; }
.compact-form { margin-top: 0; }
.manual-entry-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.appointment-panel, .daily-panel { min-height: 480px; }
.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar input[type="date"] { width: auto; min-width: 145px; }
.file-button { height: 42px; padding: 0 14px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--blue); cursor: pointer; font-weight: 600; }
.file-button:hover { background: var(--blue-soft); border-color: #a8cdf2; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
th { background: #f7f7f9; color: var(--secondary); font-size: 12px; font-weight: 600; }
td { font-size: 13px; }
tbody tr:hover { background: #fafafa; }
.table-empty { height: 220px; color: var(--secondary); text-align: center; }
.add-item-dialog { width: min(440px, calc(100% - 24px)); padding: 0; border: 0; border-radius: 8px; background: white; color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .22); }
.add-item-dialog::backdrop { background: rgba(0, 0, 0, .28); backdrop-filter: blur(3px); }
.add-item-dialog[open] { animation: surface-enter .22s cubic-bezier(.22, 1, .36, 1); }
.dialog-heading { padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line-soft); }
.dialog-heading p { margin-top: 4px; color: var(--secondary); font-size: 12px; }
.dialog-close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: #f2f2f7; color: var(--secondary); font-size: 22px; line-height: 1; }
.dialog-body { padding: 20px; display: grid; gap: 16px; }
.dialog-actions { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }
.secondary-button { min-height: 42px; padding: 0 17px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--text); font-weight: 650; }
.primary-button:disabled { cursor: wait; opacity: .48; }
.link-state { color: var(--green); font-weight: 600; }
.unlinked-state { color: var(--orange); }

.timeline { padding: 12px 22px 28px; }
.timeline-row { display: grid; grid-template-columns: 92px 18px minmax(0, 1fr); gap: 12px; min-height: 78px; }
.timeline-row { animation: timeline-enter .34s cubic-bezier(.22, 1, .36, 1) both; }
.timeline-row:nth-child(2) { animation-delay: .035s; }
.timeline-row:nth-child(3) { animation-delay: .07s; }
.timeline-row:nth-child(4) { animation-delay: .105s; }
.timeline-row:nth-child(n+5) { animation-delay: .14s; }
.timeline-time { padding-top: 15px; color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline-track { position: relative; display: flex; justify-content: center; }
.timeline-track::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line-soft); }
.timeline-dot { position: relative; z-index: 1; width: 10px; height: 10px; margin-top: 19px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px white; }
.timeline-row--manual .timeline-dot { background: #ff9f0a; }
.timeline-content { margin: 7px 0; padding: 12px 14px; border-left: 3px solid var(--blue); border-radius: 0 8px 8px 0; background: #f7faff; }
.timeline-row--manual .timeline-content { border-left-color: #ff9f0a; background: #fff8ed; }
.timeline-content__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timeline-content h3 { font-size: 14px; font-weight: 650; }
.event-type { color: var(--secondary); font-size: 12px; }
.timeline-content p { margin-top: 5px; color: var(--secondary); font-size: 12px; }

@keyframes surface-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes profile-photo-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes list-item-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dialog-content-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes timeline-enter {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes status-breathe {
  0%, 100% { opacity: .72; transform: scale(.9); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes option-select {
  0% { transform: scale(.97); }
  100% { transform: scale(1); }
}

@keyframes mobile-item-enter {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mobile-status-pop {
  0% { transform: scale(.92); opacity: .65; }
  100% { transform: scale(1); opacity: 1; }
}

@media (hover: hover) {
  .instrument-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .06); }
  .start-treatment:hover, #submit-button:hover, .primary-button:hover, .compact-form button:hover, .file-button:hover { transform: translateY(-1px); }
}

@media (max-width: 1050px) {
  .dashboard { grid-template-columns: 1fr; }
  .panel { min-height: 0; }
  .queue-list { max-height: 520px; }
}

@media (max-width: 680px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  body { padding-bottom: env(safe-area-inset-bottom); font-size: 14px; }
  .topbar { position: relative; }
  .topbar__inner, .page-shell { width: min(100% - 16px, 1420px); }
  .topbar__inner { min-height: 0; flex-wrap: wrap; padding: max(8px, env(safe-area-inset-top)) 0 8px; gap: 7px 9px; }
  .brand-mark { width: 28px; height: 40px; }
  h1 { font-size: 16px; }
  .brand-copy p { display: none; }
  .current-time { max-width: 118px; margin-left: auto; font-size: 11px; line-height: 1.25; }
  .topnav { order: 3; width: 100%; margin: 0; justify-content: stretch; }
  .topnav a { flex: 1; min-width: 0; min-height: 34px; padding: 0 5px; text-align: center; white-space: nowrap; }
  .topnav + .current-time { margin-left: auto; }
  .page-shell { padding: 8px 0 max(28px, env(safe-area-inset-bottom)); }
  .dashboard, .panel, .queue-panel, .queue-order-wrap { min-width: 0; }
  .dashboard { width: 100%; gap: 10px; }
  .dashboard .queue-panel { order: -1; }
  .panel, .registration { border-radius: 8px; box-shadow: 0 4px 18px rgba(0, 0, 0, .045); }
  .panel-heading, .registration-heading { min-height: 58px; padding: 11px 12px; }
  body .page-shell:not(.page-stack) { display: flex; flex-direction: column; }
  body .page-shell:not(.page-stack) > .registration { order: -1; margin: 0 0 10px; }
  .queue-list { max-height: none; overflow: visible; }
  .queue-order-title { padding: 10px 11px 7px; flex-wrap: wrap; gap: 3px 10px; }
  .queue-order-title span { line-height: 1.35; }
  .queue-order-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .queue-matrix th, .queue-matrix td { width: 98px; min-width: 98px; padding: 7px 5px; scroll-snap-align: start; }
  .queue-matrix .queue-matrix-corner, .queue-matrix .queue-matrix-rank { width: 60px; min-width: 60px; padding-left: 4px; padding-right: 4px; }
  .queue-matrix-patient { padding: 7px 5px; }
  .instrument-grid { padding: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .instrument-card { min-height: 82px; padding: 9px; }
  .instrument-card h3 { font-size: 14px; }
  .instrument-card__detail { display: grid; gap: 3px; }
  .queue-item { padding: 12px; }
  .mobile-entering .instrument-card,
  .mobile-entering .queue-item { animation: mobile-item-enter .34s cubic-bezier(.22, 1, .36, 1) both; }
  .mobile-entering .instrument-card:nth-child(2),
  .mobile-entering .queue-item:nth-child(2) { animation-delay: .035s; }
  .mobile-entering .instrument-card:nth-child(3),
  .mobile-entering .queue-item:nth-child(3) { animation-delay: .07s; }
  .mobile-entering .instrument-card:nth-child(4),
  .mobile-entering .queue-item:nth-child(4) { animation-delay: .105s; }
  .mobile-entering .instrument-card:nth-child(n+5),
  .mobile-entering .queue-item:nth-child(n+5) { animation-delay: .14s; }
  .queue-status { animation: mobile-status-pop .2s ease-out; }
  .start-treatment, .pause-treatment, .cancel-treatment,
  .add-patient-item, .delete-patient, #submit-button,
  .primary-button, .secondary-button, .dialog-close,
  .topnav a, .project-option span {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform .12s ease, opacity .12s ease, background-color .18s ease;
  }
  .start-treatment:active, .pause-treatment:active, .cancel-treatment:active,
  .add-patient-item:active, .delete-patient:active, #submit-button:active,
  .primary-button:active, .secondary-button:active, .dialog-close:active,
  .topnav a:active, .project-option span:active { transform: scale(.96); opacity: .82; }
  .add-item-dialog[open] { animation: mobile-item-enter .26s cubic-bezier(.22, 1, .36, 1); }
  .queue-item__top { align-items: flex-start; flex-direction: column; }
  .queue-item__controls { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .queue-meta { grid-template-columns: 1fr; gap: 7px; }
  .queue-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .queue-actions button { width: 100%; min-width: 0; min-height: 44px; padding-left: 6px; padding-right: 6px; white-space: normal; overflow-wrap: anywhere; }
  .registration { margin-top: 10px; }
  .registration form { padding: 13px 12px; }
  .form-grid, .manual-times { grid-template-columns: 1fr; }
  .field input, .field select { min-height: 48px; font-size: 16px; }
  .project-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .project-option span { min-height: 44px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  #submit-button { width: 100%; min-height: 46px; }
  .manual-entry-grid { grid-template-columns: 1fr; }
  .toolbar { width: 100%; justify-content: flex-start; }
  .appointment-panel .panel-heading, .daily-panel .panel-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .primary-button { flex: 1; }
  .timeline { padding: 8px 10px 20px; }
  .timeline-row { grid-template-columns: 64px 14px minmax(0, 1fr); gap: 7px; }
  .patient-page { display: block; padding: 12px 10px; }
  .patient-shell { width: 100%; min-height: calc(100vh - 24px); padding: 22px 15px; border-radius: 10px; }
  .patient-checkin-shell { min-height: auto; margin: max(12px, env(safe-area-inset-top)) auto max(20px, env(safe-area-inset-bottom)); padding: 22px 18px 20px; border-radius: 8px; }
  .patient-checkin-shell .patient-header { gap: 12px; padding-bottom: 20px; }
  .patient-checkin-shell .patient-logo { width: 38px; height: 54px; }
  .patient-checkin-shell .patient-header h1 { font-size: 25px; }
  .patient-checkin-shell .patient-subtitle { max-width: 270px; line-height: 1.55; }
  .patient-checkin-shell .patient-form { padding-top: 22px; gap: 18px; }
  .patient-checkin-shell input { height: 52px; border-color: #c7c7cc; background: #fbfbfd; font-size: 16px; }
  .patient-checkin-shell .patient-submit { margin-top: 4px; }
  .patient-checkin-shell .patient-footer { margin-top: 16px; }
  .patient-header h1 { font-size: 22px; }
  .patient-projects { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .patient-project span { min-height: 50px; }
  .patient-form { padding-top: 20px; }
  .patient-form input[type="text"], .patient-form select { height: 50px; font-size: 16px; }
  .patient-submit { position: sticky; bottom: 10px; z-index: 2; min-height: 52px; margin-top: 12px; box-shadow: 0 6px 18px rgba(0, 113, 227, .2); }
  .patient-qr img { width: 104px; height: 104px; }
}

@media (max-width: 350px) {
  .instrument-grid { grid-template-columns: 1fr; }
  .project-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

.therapist-switcher { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--secondary); font-size: 12px; font-weight: 600; }
.therapist-switcher input { width: 120px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--text); outline: none; }
.therapist-shell { width: min(900px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 56px; display: grid; gap: 18px; }
.therapist-page { font-size: 15px; }
.therapist-panel { overflow: hidden; border: 1px solid rgba(0, 0, 0, .075); border-radius: 8px; background: rgba(255, 255, 255, .96); box-shadow: 0 1px 2px rgba(0, 0, 0, .025), 0 10px 30px rgba(0, 0, 0, .045); animation: surface-enter .42s cubic-bezier(.22, 1, .36, 1) both; transition: transform .28s cubic-bezier(.22, 1, .36, 1), box-shadow .28s ease, border-color .28s ease; }
.therapist-shell > .therapist-panel:nth-child(2) { animation-delay: .04s; }
.therapist-shell > .therapist-panel:nth-child(3) { animation-delay: .08s; }
.therapist-shell > .therapist-panel:nth-child(4) { animation-delay: .12s; }
.therapist-shell > .therapist-panel:nth-child(5) { animation-delay: .16s; }
.therapist-profile { padding: 22px; display: flex; align-items: center; gap: 22px; }
.therapist-profile-photo { width: 132px; height: 168px; flex: 0 0 auto; object-fit: cover; object-position: center top; border: 1px solid rgba(0, 0, 0, .06); border-radius: 8px; background: #eef1f2; box-shadow: 0 8px 22px rgba(0, 0, 0, .07); animation: profile-photo-in .65s cubic-bezier(.22, 1, .36, 1) both; transition: transform .32s cubic-bezier(.22, 1, .36, 1), box-shadow .32s ease; }
.therapist-profile-copy { min-width: 0; }
.therapist-profile-identity > small { display: block; margin-top: 2px; color: var(--secondary); font-size: 13px; font-weight: 600; }
.therapist-profile-copy h2 { margin-top: 5px; font-size: 25px; letter-spacing: -.015em; }
.therapist-profile-copy h2 small { color: var(--secondary); font-size: 13px; font-weight: 600; }
.therapist-profile-copy p { margin-top: 10px; color: var(--secondary); font-size: 14px; line-height: 1.75; }
.therapist-panel-heading { padding: 19px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); }
.therapist-panel-heading p { margin-top: 4px; color: var(--secondary); font-size: 12px; }
.therapist-panel-heading h2 { font-size: 19px; }
.therapist-search { padding: 22px; display: flex; gap: 10px; }
.therapist-search input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid #c7c7cc; border-radius: 8px; background: #fbfbfd; color: var(--text); font-size: 16px; outline: none; transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.therapist-search input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, .13); }
.therapist-primary { min-height: 44px; padding: 0 18px; border: 0; border-radius: 8px; background: var(--blue); color: white; font-weight: 650; box-shadow: 0 1px 2px rgba(0, 113, 227, .16); }
.therapist-primary:hover { background: var(--blue-hover); }
.therapist-message { min-height: 20px; padding: 0 22px 14px; color: var(--secondary); font-size: 13px; }
.therapist-message--error { color: var(--red); }
.therapist-message--success { color: var(--green); }
.manual-patient-card { margin: 0 22px 22px; padding: 20px; border: 1px solid var(--line-soft); border-radius: 8px; background: #fbfbfd; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8); animation: surface-enter .25s ease-out; transition: transform .2s cubic-bezier(.22, 1, .36, 1), box-shadow .2s ease; }
.manual-patient-card--last { border-color: #e9bd42; background: #fff9e7; }
.manual-patient-card--exhausted { border: 2px solid #d70015; background: #fff1f2; }
.manual-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.manual-patient-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.manual-delete-patient { min-height: 36px; padding: 0 12px; border: 1px solid #ffd0d4; border-radius: 8px; background: #fff0f1; color: var(--red); font-weight: 700; cursor: pointer; }
.manual-delete-patient:active { transform: scale(.97); }
.manual-delete-patient:disabled { opacity: .48; cursor: wait; }
.manual-card-label { color: var(--tertiary); font-size: 12px; }
.manual-card-heading h3 { margin-top: 3px; font-size: 22px; }
.manual-patient-id { color: var(--tertiary); font-size: 12px; }
.manual-patient-contact { margin-top: 6px; color: var(--secondary); font-size: 12px; overflow-wrap: anywhere; }
.manual-count-grid { margin-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line-soft); border-radius: 8px; background: white; }
.manual-count-grid div { padding: 13px; display: grid; gap: 5px; text-align: center; border-right: 1px solid var(--line-soft); }
.manual-count-grid div:last-child { border-right: 0; }
.manual-count-grid span { color: var(--secondary); font-size: 12px; }
.manual-count-grid strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.manual-patient-card--last .manual-remaining strong { color: #9a6700; }
.manual-patient-card--exhausted .manual-remaining strong { color: var(--red); }
.manual-card-notice { margin-top: 14px; color: var(--secondary); font-size: 13px; text-align: center; }
.manual-patient-card--last .manual-card-notice { color: #9a6700; font-weight: 650; }
.manual-patient-card--exhausted .manual-card-notice { color: var(--red); font-weight: 650; }
.manual-checkin-button { width: 100%; min-height: 50px; margin-top: 15px; border: 0; border-radius: 8px; background: var(--green); color: white; font-size: 15px; font-weight: 700; box-shadow: 0 4px 12px rgba(36, 138, 61, .18); }
.manual-checkin-button:hover { background: #1e7735; }
.manual-checkin-button:disabled { opacity: .5; cursor: wait; }
.manual-no-prescription { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); color: var(--secondary); }
.manual-addition-history { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line-soft); }
.manual-addition-history h4 { margin: 0 0 8px; font-size: 13px; color: var(--secondary); font-weight: 650; }
.manual-addition-history ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; max-height: 168px; overflow-y: auto; }
.manual-addition-history li { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.manual-addition-history li time { flex-shrink: 0; color: var(--secondary); font-variant-numeric: tabular-nums; }
.manual-addition-history li span { font-weight: 650; }
.manual-addition-history li small { color: var(--secondary); }
.manual-create-prescription { margin-top: 12px; display: flex; gap: 10px; }
.manual-create-prescription input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
.manual-record-list { padding: 4px 22px 16px; }
.manual-record { min-height: 62px; padding: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line-soft); }
.manual-record { animation: list-item-in .3s cubic-bezier(.22, 1, .36, 1) both; }
.manual-record:nth-child(2) { animation-delay: .035s; }
.manual-record:nth-child(3) { animation-delay: .07s; }
.manual-record:last-child { border-bottom: 0; }
.manual-record div { display: grid; gap: 4px; }
.manual-record span { color: var(--secondary); font-size: 12px; }
.manual-record b { color: var(--green); font-size: 13px; white-space: nowrap; }
.arrival-actions { display: flex; align-items: center; gap: 8px; }
.arrival-actions button { min-height: 38px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--blue); color: white; font-weight: 700; }
.arrival-actions button[data-complete-arrival] { background: var(--green); }
.arrival-actions button:disabled { opacity: .5; }
.therapist-refresh { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--blue); font-weight: 650; }
.history-actions { display: flex; align-items: center; gap: 8px; }
.therapist-export { min-height: 36px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--green); color: white; font-weight: 700; text-decoration: none; white-space: nowrap; }
.therapist-export:active { transform: scale(.97); }
.therapist-empty { padding: 34px 10px; color: var(--secondary); text-align: center; }
.therapist-dialog { width: min(460px, calc(100% - 24px)); padding: 0; border: 0; border-radius: 10px; background: white; color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .22); }
.therapist-dialog::backdrop { background: rgba(0, 0, 0, .3); backdrop-filter: blur(3px); }
.therapist-dialog[open] { animation: surface-enter .22s cubic-bezier(.22, 1, .36, 1); }
.therapist-dialog[open] .dialog-body { animation: dialog-content-in .28s .04s cubic-bezier(.22, 1, .36, 1) both; }
.dialog-message { padding: 0; margin: 0; }
.history-filter { padding: 14px 22px 8px; }
.history-filter input { width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; background: white; font-size: 16px; outline: none; }
.history-filter input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, .13); }
.manual-history-list { padding: 4px 22px 16px; max-height: 480px; overflow-y: auto; }
.manual-history-item { width: 100%; min-height: 68px; padding: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.manual-history-item:last-child { border-bottom: 0; }
.manual-history-item { transition: transform .2s cubic-bezier(.22, 1, .36, 1), background-color .2s ease; }
.manual-history-item { animation: list-item-in .32s cubic-bezier(.22, 1, .36, 1) both; }
.manual-history-item:nth-child(2) { animation-delay: .035s; }
.manual-history-item:nth-child(3) { animation-delay: .07s; }
.manual-history-item:nth-child(4) { animation-delay: .105s; }
.manual-history-item:active { transform: scale(.985); }
.manual-history-item:hover { background: rgba(0, 113, 227, .045); }
.history-patient-main, .history-count { display: grid; gap: 5px; }
.history-patient-main small, .history-count small { color: var(--secondary); font-size: 12px; }
.history-count { flex: 0 0 auto; text-align: right; }
.history-count b { color: var(--green); font-size: 14px; }
.history-count--empty b { color: var(--red); }
.therapist-qr-panel { padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.therapist-qr-copy p { margin-top: 7px; color: var(--secondary); font-size: 13px; }
.therapist-qr-copy a { display: inline-flex; margin-top: 16px; color: var(--blue); font-size: 14px; font-weight: 700; }
.therapist-qr-panel img { width: 176px; height: 176px; padding: 8px; border: 1px solid var(--line-soft); border-radius: 8px; background: white; image-rendering: pixelated; }
.therapist-qr-panel img { box-shadow: 0 8px 24px rgba(0, 0, 0, .055); transition: transform .3s cubic-bezier(.22, 1, .36, 1), box-shadow .3s ease; }

@media (hover: hover) {
  .therapist-panel:hover { border-color: rgba(0, 0, 0, .12); box-shadow: 0 14px 38px rgba(0, 0, 0, .075); transform: translateY(-2px); }
  .therapist-profile:hover .therapist-profile-photo { transform: scale(1.018); }
  .therapist-primary:hover, .therapist-export:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(0, 113, 227, .18); }
  .therapist-export:hover { box-shadow: 0 7px 18px rgba(36, 138, 61, .18); }
  .therapist-refresh:hover, .manual-delete-patient:hover { background: #f5f5f7; transform: translateY(-1px); }
}

.therapist-primary:active, .therapist-refresh:active, .therapist-export:active, .manual-delete-patient:active { transform: scale(.97); }

@media (max-width: 680px) {
  .therapist-page .topbar { position: relative; }
  .therapist-page .topbar__inner { width: calc(100% - 24px); min-height: 0; padding: 12px 0; gap: 9px; }
  .therapist-page .brand-mark { width: 30px; height: 44px; }
  .therapist-page .brand-copy { min-width: 0; }
  .therapist-page .brand-copy h1 { font-size: 18px; }
  .therapist-page .brand-copy p { display: block; }
  .therapist-shell { width: min(100% - 16px, 900px); padding: 10px 0 max(28px, env(safe-area-inset-bottom)); gap: 14px; }
  .therapist-profile { padding: 15px; align-items: flex-start; gap: 14px; }
  .therapist-profile-photo { width: 92px; height: 124px; border-radius: 8px; }
  .therapist-profile-copy h2 { font-size: 20px; }
  .therapist-profile-copy h2 small { display: block; margin-top: 3px; }
  .therapist-profile-copy p { margin-top: 8px; font-size: 12px; line-height: 1.6; }
  .therapist-switcher { order: 3; width: 100%; margin: 0 0 8px; justify-content: space-between; }
  .therapist-switcher input { flex: 1; max-width: none; height: 46px; font-size: 16px; }
  .therapist-panel-heading { padding: 16px; gap: 12px; }
  .therapist-panel-heading > div { min-width: 0; }
  .therapist-panel-heading h2 { font-size: 17px; }
  .therapist-primary, .therapist-refresh { min-height: 44px; }
  .therapist-export { min-height: 44px; }
  .therapist-search { padding: 16px; flex-direction: column; }
  .therapist-search input { width: 100%; height: 50px; }
  .therapist-search .therapist-primary { width: 100%; min-height: 48px; }
  .therapist-message { padding: 0 15px 12px; }
  .manual-patient-card { margin: 0 16px 16px; padding: 16px; }
  .manual-card-heading { flex-direction: column; }
  .manual-patient-actions { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .manual-delete-patient { min-height: 44px; }
  .manual-count-grid strong { font-size: 22px; }
  .manual-count-grid div { padding: 12px 7px; }
  .manual-checkin-button { min-height: 52px; font-size: 16px; }
  .manual-record-list { padding: 4px 16px 14px; }
  .manual-record { align-items: flex-start; }
  .manual-create-prescription { flex-direction: column; }
  .manual-create-prescription input { height: 48px; }
  .manual-create-prescription .therapist-primary { width: 100%; }
  .history-filter { padding: 14px 16px 7px; }
  .manual-history-list { padding: 4px 16px 14px; max-height: 420px; }
  .manual-history-item { min-height: 76px; }
  .history-patient-main { min-width: 0; }
  .history-patient-main strong, .history-patient-main small { overflow-wrap: anywhere; }
  .therapist-qr-panel { padding: 18px 15px; }
  .therapist-qr-panel img { width: 124px; height: 124px; }
  .therapist-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); margin-bottom: 8px; border-radius: 10px; }
  .therapist-dialog form { max-height: calc(100dvh - 16px); overflow-y: auto; }
  .dialog-heading, .dialog-body { padding: 16px; }
  .dialog-actions { position: sticky; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line-soft); }
  .dialog-actions button { flex: 1; min-height: 48px; }
}

@media (max-width: 420px) {
  .therapist-shell { width: calc(100% - 12px); gap: 12px; }
  .therapist-panel { border-radius: 8px; }
  .therapist-page .topbar__inner { padding: 9px 0 10px; }
  .therapist-switcher { margin-bottom: 0; }
  .therapist-switcher input { height: 42px; }
  .therapist-profile { display: grid; grid-template-columns: 82px minmax(0, 1fr); padding: 14px; gap: 12px; }
  .therapist-profile-photo { width: 82px; height: 105px; align-self: start; }
  .therapist-profile-copy { display: contents; }
  .therapist-profile-identity { align-self: center; }
  .therapist-profile-identity h2 { margin-top: 3px; font-size: 21px; }
  .therapist-profile-identity > small { font-size: 12px; }
  .therapist-profile-bio { grid-column: 1 / -1; }
  .therapist-profile-bio p { font-size: 12px; line-height: 1.6; }
  .therapist-profile-bio p:first-child { margin-top: 3px; }
  .therapist-panel-heading { align-items: flex-start; }
  .therapist-search-panel .therapist-panel-heading { flex-direction: row; align-items: center; }
  .therapist-search-panel .therapist-panel-heading .therapist-primary { width: auto; min-height: 38px; padding: 0 13px; flex: 0 0 auto; }
  .therapist-search { padding: 13px 14px; flex-direction: row; align-items: center; }
  .therapist-search input { height: 44px; }
  .therapist-search .therapist-primary { width: auto; min-height: 44px; padding: 0 17px; flex: 0 0 auto; }
  .therapist-history-panel .therapist-panel-heading { flex-direction: row; align-items: center; }
  .history-actions { width: auto; flex: 0 0 auto; }
  .history-actions .therapist-export { min-height: 38px; padding: 0 10px; font-size: 12px; }
  .history-actions .therapist-refresh { min-height: 38px; padding: 0 9px; }
  .manual-record { flex-direction: column; gap: 6px; }
  .manual-history-item { align-items: flex-start; }
  .history-count { max-width: 42%; }
  .arrival-actions button { min-height: 40px; padding: 0 12px; font-size: 13px; }
  .therapist-panel-heading { padding: 14px; }
  .therapist-panel-heading h2 { font-size: 18px; }
  .manual-record-list, .manual-history-list { padding-left: 14px; padding-right: 14px; }
  .history-filter { padding: 12px 14px 6px; }
  .history-filter input { height: 42px; }
  .therapist-qr-panel { flex-direction: column; align-items: flex-start; }
  .therapist-qr-panel img { width: min(176px, 52vw); height: min(176px, 52vw); align-self: center; }
}

.overview-page .panel { min-height: 0; }
.overview-kpis {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.overview-kpi {
  min-height: 96px;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfbfd;
}
.overview-kpi__label { color: var(--secondary); font-size: 12px; font-weight: 600; }
.overview-kpi__value {
  margin-top: 8px;
  color: var(--text);
  font-size: 28px;
  line-height: 1.1;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.overview-kpi__hint { margin-top: 8px; color: var(--tertiary); font-size: 12px; }
.overview-breakdown {
  padding: 0 20px 18px;
  display: grid;
  gap: 6px;
  color: var(--secondary);
  font-size: 13px;
}
.overview-trend {
  padding: 0 16px 18px;
  display: grid;
  gap: 10px;
}
.overview-trend__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}
.overview-trend__head h3 { font-size: 15px; }
.overview-trend__head p { color: var(--secondary); font-size: 12px; }
.overview-trend__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding: 0 4px;
  color: var(--secondary);
  font-size: 12px;
}
.overview-trend__legend span { display: inline-flex; align-items: center; gap: 6px; }
.overview-trend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.overview-trend__swatch--queue { background: var(--blue); }
.overview-trend__swatch--arrive { background: var(--green); }
.overview-trend__swatch--alert { background: var(--red); }
.overview-trend__chart-wrap {
  position: relative;
  height: 180px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfbfd;
}
.overview-trend__chart-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.overview-trend__hint {
  padding: 0 4px;
  color: var(--secondary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-height: 1.45em;
}
.overview-alerts { padding: 14px 16px 18px; display: grid; gap: 10px; }
.overview-alert {
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfbfd;
}
.overview-alert--warning { border-color: #ffc8ad; background: var(--orange-soft); }
.overview-alert--danger { border-color: #f5b4bb; background: #fff2f3; }
.overview-alert__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.overview-alert__head h3 { font-size: 15px; }
.overview-alert__head span { color: var(--secondary); font-size: 12px; font-weight: 600; }
.overview-alert ul { margin: 10px 0 0; padding-left: 18px; }
.overview-alert li { margin: 4px 0; color: var(--text); font-size: 13px; line-height: 1.45; }
.overview-assumptions { padding: 12px 20px 18px; }
.overview-assumptions summary {
  cursor: pointer;
  font-size: 15px;
  font-weight: 650;
}
.overview-assumptions ul { margin: 12px 0 0; padding-left: 18px; color: var(--secondary); font-size: 13px; line-height: 1.55; }
.overview-assumptions li + li { margin-top: 6px; }

@media (max-width: 1050px) {
  .overview-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .overview-kpis { padding: 10px; grid-template-columns: 1fr 1fr; gap: 8px; }
  .overview-kpi { min-height: 84px; padding: 12px; }
  .overview-kpi__value { font-size: 24px; }
  .overview-breakdown, .overview-assumptions, .overview-trend { padding-left: 12px; padding-right: 12px; }
  .overview-trend__chart-wrap { height: 160px; }
  .overview-alerts { padding: 10px 12px 14px; }
}

.report-page .panel { min-height: 0; }
.report-page .topbar__inner { flex-wrap: wrap; }
.report-page .overview-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
a.secondary-button {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}
.report-banner {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}
.report-banner--cross {
  background: #fff6d6;
  border: 1px solid #f0d78c;
  color: #6b5300;
}
.report-banner--empty {
  background: #f4f4f5;
  border: 1px solid var(--line);
  color: var(--secondary);
}
.report-table-wrap { overflow-x: auto; padding: 0 16px 18px; }
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.report-table th, .report-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  font-size: 13px;
}
.report-table th:first-child, .report-table td:first-child { text-align: left; }
.report-table thead th {
  font-size: 12px;
  color: var(--secondary);
  font-weight: 650;
  background: #fbfbfd;
}
.report-table tfoot td { font-weight: 650; }
.report-caveats {
  margin: 0;
  padding: 0 20px 18px 38px;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.55;
}
.report-caveats li + li { margin-top: 6px; }

@media print {
  .report-actions, .topnav, .current-time { display: none !important; }
  .topbar {
    position: static;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: white;
  }
  body { background: white; }
  .panel { box-shadow: none; break-inside: avoid; }
  .report-table thead { display: table-header-group; }
  .report-table tfoot { display: table-footer-group; }
  @page { size: A4 portrait; margin: 12mm; }
}
