:root {
  font-family:
    "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "Segoe UI", system-ui, sans-serif;
  color: #1c312b;
  background: #f2f4f0;
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  --forest: #173b32;
  --forest-hover: #215044;
  --accent: #c8df8d;
  --muted: #4e6058;
  --line: #d2dcd3;
  --line-soft: #e3eae4;
  --paper: #ffffff;
  --surface-subtle: #f7f9f5;
  --error: #a5352a;
}

/* Dense worksheet tools share the existing hospital workspace palette. */
.connection[data-dirty="true"] {color:#875711;background:#fff3d7;padding:6px 12px;border-radius:4px;}
#save-workspace {min-width:80px;}
.export-lead {font-size:20px;font-weight:600;color:var(--forest);margin:0 0 24px;}
.export-contents {display:grid;grid-template-columns:100px 1fr;gap:16px;margin:0 0 24px;}
.export-contents dt {font-weight:600;}.export-contents dd {margin:0;line-height:1.7;}
.creator-credit {display:block;margin-top:8px;font-size:12px;color:#d4e2d6;}
#export-form .dialog-body label {display:flex;flex-direction:column;gap:8px;margin-bottom:16px;}
#export-form [data-period="range"] {display:grid;grid-template-columns:1fr 1fr;gap:16px;}
#export-form [hidden] {display:none!important;}
#export-dialog,#feedback-dialog,#confirm-dialog {max-width:600px;width:calc(100% - 32px);}
#feedback-dialog .dialog-body p,#confirm-dialog .dialog-body p {white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.8;}
button.danger-quiet {color:#963e32;background:transparent;border-color:var(--line);}
button.danger-quiet:hover:not(:disabled),button.danger,button.danger:hover:not(:disabled) {background:#963e32;color:white;}
.import-batch-link {justify-self:start;}
.worksheet .row-gutter input[type=checkbox] {width:16px;height:16px;margin:4px;accent-color:var(--forest);}
.worksheet th:first-child {text-align:center;}
.worksheet #select-day-visible {width:16px;height:16px;min-height:0;margin:4px;padding:0;accent-color:var(--forest);}
.worksheet tr:has([data-select-case]:checked) td {background:#edf5e8;}
button:disabled {cursor:default;}

.day-review { margin-bottom: 14px; }
.day-review .panel-head { flex-wrap: wrap; gap: 10px; }
.day-review details { margin-top: 8px; }
.review-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.workflow-chart { display: block; width: auto; height: 310px; max-width: none; min-width: 720px; font-size: 12px; }
.pareto-chart { display: block; width: 100%; min-width: 720px; font-size: 13px; }
.dialog-history { padding: 12px 24px; }
#review-form label { display: block; margin: 12px 0; }
#review-form input, #review-form textarea { width: 100%; }
@media print {
  .workflow-chart, .pareto-chart { min-width: 0; }
  .workflow-chart { width: 100%; height: auto; }
  #print-sheet .panel { break-inside: avoid; }
  #print-sheet .table-wrap, #print-sheet .chart-scroll { overflow: visible; }
  #print-sheet .count-note { color: #333; }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 6px;
  padding: 8px 14px;
  color: inherit;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.35;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

button:hover:not(:disabled) {
  background: #e8efe4;
  border-color: #b7c6b9;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2.5px solid #4a7856;
  outline-offset: 2px;
}

::selection {
  background: #d7e8b3;
}

input,
select,
textarea {
  caret-color: var(--forest);
  border: 1px solid #b8c6ba;
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: #1c312b;
  min-width: 0;
  font-size: 14px;
}

input::placeholder,
textarea::placeholder {
  color: #5d6c64;
}

input[readonly] {
  background: #f3f6f2;
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  color: #132a23;
}

h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.015em;
  line-height: 1.35;
}

code {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.92em;
  background: #e9efe7;
  padding: 1px 5px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 30;
  transform: translateY(-200%);
  padding: 10px 14px;
  background: #fff;
  color: var(--forest);
  border: 2px solid var(--forest);
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  transform: none;
}

/* Navigation Rail */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 164px;
  background: var(--forest);
  color: #e6eee2;
  padding: 22px 12px 18px;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand {
  display: flex;
  gap: 8px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 6px;
}

.brand svg {
  width: 28px;
  height: 30px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.3;
}

.brand-sub,
.rail-label,
nav button span,
.rail-bottom p,
.rail-backup {
  display: none;
}

nav {
  display: grid;
  gap: 6px;
  margin-top: 28px;
}

nav button {
  text-align: left;
  border: 0;
  background: none;
  color: #d4e2d6;
  padding: 11px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav button:hover:not(.active) {
  background: #244d42;
  color: #fff;
}
nav button.active:hover:not(:disabled) {background:var(--accent);color:#163020;}

nav button.active {
  background: var(--accent);
  color: #163020;
  font-weight: 700;
}

.rail-bottom {
  margin-top: auto;
  font-size: 12px;
  padding: 16px 8px 0;
  border-top: 1px solid #295246;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
}

.version {
  display: block;
  color: #a6bdb0;
  font-size: 11px;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.copyright-badge {
  display: block;
  color: #c9ddcf;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.copyright-panel {
  grid-column: 1 / -1;
}

/* Main Workspace */
main {
  margin-left: 164px;
  padding: 0 clamp(18px, 2.2vw, 36px);
  min-height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.slash {
  margin: 0 8px;
  color: #9aa89e;
}

.connection {
  font-size: 12px;
  color: var(--muted);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 14px;
  gap: 16px;
}

.intro {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13.5px;
  line-height: 1.6;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.primary {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}

.primary:hover:not(:disabled) {
  background: var(--forest-hover);
  border-color: var(--forest-hover);
}

.danger-button {
  color: var(--error);
  border-color: #dfbab4;
  background: #fff8f6;
  margin-right: auto;
}

.danger-button:hover:not(:disabled) {
  background: #fdebe7;
  border-color: #ce968d;
}

.icon-button {
  padding: 5px 11px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
}

/* Notice Banner */
#notice {
  background: #e3eed8;
  border: 1px solid #b5c99e;
  color: #1c3b27;
  padding: 10px 16px;
  margin-top: 12px;
  border-radius: 6px;
  font-size: 13.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  gap: 10px;
}

#notice[hidden] {
  display: none !important;
}

#notice.failure {
  color: #84291e;
  background: #fff1ed;
  border-color: #e0b4aa;
}

#notice button {
  padding: 4px 12px;
  margin-inline-start: 4px;
  background: #fff;
}

/* Schedule Toolbar & Date / Month Bars */
.schedule-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.date-bar,
.month-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.month-bar {
  margin-bottom: 14px;
}

.schedule-toolbar .date-label {
  display: none;
}

.schedule-toolbar #day {
  border-color: var(--line);
  background: var(--paper);
  font-size: 15px;
  width: 152px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 6px 10px;
}

.weekday-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  background: #e6ece4;
  color: #214035;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.month-picker {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}

.month-picker input[type="month"] {
  font-weight: 700;
  font-size: 14.5px;
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
}

.sheet-secondary {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13.5px;
}

.case-summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.case-summary strong {
  color: #1c312b;
  font-weight: 700;
}

.sheet-options {
  position: relative;
}

.sheet-options summary {
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-weight: 600;
  color: #1c312b;
  user-select: none;
}

.sheet-options summary:hover {
  background: #e8efe4;
}

.sheet-options > div {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 15;
  width: 220px;
  padding: 8px;
  background: var(--paper);
  box-shadow: 0 10px 28px #142e2626;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
}

.sheet-options button {
  display: block;
  width: 100%;
  text-align: left;
  border-color: transparent;
  padding: 8px 10px;
}

.sheet-options button:hover:not(:disabled) {
  background: #edf3ea;
}

/* Workbench & Sheet Tools */
.workbench {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px #173b320a;
}

.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
}

.sheet-tools {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
  flex-wrap: wrap;
}

.sheet-tools input[type="search"] {
  width: 220px;
  padding: 6px 10px;
  font-size: 13.5px;
}

.sheet-status,
.preparer-label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.sheet-status select {
  padding: 5px 8px;
  font-size: 13.5px;
  font-weight: 600;
}

.preparer-label {
  margin-inline-start: auto;
}

.preparer-label input {
  width: 124px;
  padding: 5px 8px;
  font-size: 13.5px;
  font-weight: 600;
}

.sheet-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Tables & Daily Worksheet */
.table-wrap {
  overflow-x: auto;
}

.worksheet-wrap {
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

th {
  font-size: 12px;
  color: #3f524a;
  font-weight: 700;
  background: #f4f7f2;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f5f9f2;
}

.num-col,
.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.action-cell {
  text-align: right;
  white-space: nowrap;
}

.exam {
  max-width: 340px;
  white-space: normal;
  line-height: 1.5;
}

.notes-cell {
  white-space: pre-wrap;
  max-width: 320px;
  color: #32473f;
}

/* Worksheet Specific Grid */
.worksheet {
  min-width: 720px;
  table-layout: fixed;
  font-size: 14px;
  white-space: normal;
}

.worksheet .col-tools { width: 52px; }
.worksheet .col-exam { width: auto; }
.worksheet .col-name { width: 114px; }
.worksheet .col-mrn { width: 92px; }
.worksheet .col-category { width: 108px; }
.worksheet .col-time,
.worksheet .col-imaging_time { width: 94px; }
.worksheet .col-dose { width: 64px; }
.worksheet .col-notes { width: auto; }
.worksheet .col-actions { width: 34px; }

.worksheet th {
  padding: 9px 5px;
  font-size: 12px;
  font-weight: 700;
  background: #eff3ec;
  color: #2c4239;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.worksheet th + th,
.worksheet td + td {
  border-left: 1px solid var(--line-soft);
}

.worksheet td {
  padding: 4px 2px;
  vertical-align: top;
  border-bottom: 1px solid #dfe6de;
}

.case-row:nth-child(even) {
  background: #fafcf9;
}

.case-row:focus-within,
.case-row:hover {
  background: #edf5ea;
}

/* Priority Color Indicator on Left Gutter */
.case-row .row-gutter {
  border-left: 3px solid transparent;
}
.case-row[data-priority="mpi"] .row-gutter { border-left-color: #2563eb; }
.case-row[data-priority="bone"] .row-gutter { border-left-color: #0d9488; }
.case-row[data-priority="red"] .row-gutter { border-left-color: #dc2626; }
.case-row[data-priority="orange"] .row-gutter { border-left-color: #ea580c; }
.case-row[data-priority="yellow"] .row-gutter { border-left-color: #ca8a04; }
.case-row[data-priority="black"] .row-gutter { border-left-color: #475569; }
.case-row[data-priority="unassigned"] .row-gutter { border-left-color: #94a3b8; }

.worksheet input,
.worksheet .cell-category select,
.worksheet textarea {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: 14px;
  line-height: 1.45;
  padding: 5px 3px;
  font-weight: 400;
  min-height: 32px;
}

.worksheet .cell-name input {
  font-weight: 600;
}
.worksheet .has-ink { position: relative; }
.worksheet .cell-ink { position: absolute; inset: 4px 2px; padding: 6px 4px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: break-word; pointer-events: none; overflow: hidden; }
.worksheet .has-ink:not(:focus-within) input,
.worksheet .has-ink:not(:focus-within) textarea { color: transparent; }
.worksheet .has-ink:focus-within .cell-ink { visibility: hidden; }

.worksheet input:hover,
.worksheet .cell-category select:hover,
.worksheet textarea:hover {
  border-color: #bdd0c0;
  background: #fff;
}

.worksheet input:focus,
.worksheet .cell-category select:focus,
.worksheet textarea:focus {
  background: #fff;
  border-color: #3d6b52;
  outline: 2px solid #4a785640;
  outline-offset: 0;
}

.worksheet input[type="time"] {
  font-variant-numeric: tabular-nums;
  padding-inline: 4px;
  font-size: 13.5px;
}

.worksheet input[type="time"]::-webkit-calendar-picker-indicator {
  width: 13px;
  height: 13px;
  margin: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0.65;
}

.worksheet input[type="time"]:not(:hover):not(:focus)::-webkit-calendar-picker-indicator {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.worksheet input[type="time"][data-empty="true"]:not(:hover):not(:focus)::-webkit-datetime-edit {
  color: #b4c0b7;
}

.worksheet .cell-mrn input,
.worksheet .cell-dose input {
  font-variant-numeric: tabular-nums;
}

.worksheet .cell-imaging_time input {
  font-weight: 700;
  color: #12352b;
}

.worksheet textarea {
  resize: none;
  overflow: hidden;
  min-height: 32px;
}

.worksheet [aria-invalid="true"],
input[aria-invalid="true"] {
  border: 1px solid var(--error) !important;
  background: #fff2ef !important;
}

.worksheet .row-gutter {
  text-align: center;
  padding: 5px 1px;
  vertical-align: middle;
  white-space: nowrap;
}

.worksheet .row-gutter button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  min-height: 26px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #566e61;
  font-size: 15px;
}

.worksheet .row-gutter button:hover:not(:disabled) {
  background: #dce8d8;
  color: var(--forest);
}

.drag-handle {
  cursor: grab;
  user-select: none;
}

.worksheet .row-gutter .insert-here {
  font-size: 13px;
  opacity: 0.65;
}

.worksheet .row-gutter .insert-here:hover,
.worksheet .row-gutter .insert-here:focus-visible {
  opacity: 1;
}

.worksheet .case-actions {
  padding: 5px 2px;
  text-align: center;
  vertical-align: middle;
}

.case-actions select {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-align-last: center;
  background: transparent;
  color: #486053;
  cursor: pointer;
}

.case-actions select:hover,
.case-actions select:focus {
  background: #e2ece0;
  border-color: #bdd0c0;
  color: var(--forest);
}

.case-actions option {
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
}

.case-cancelled {
  background: #fff5f2 !important;
}

.case-cancelled .cell-name::after {
  content: attr(data-status-label);
  
}

.case-row.case-cancelled .cell-name::after {
  content: "取消／未到";
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #9c3528;
  background: #fde5df;
  padding: 1px 6px;
  border-radius: 4px;
  margin: 2px 0 2px 4px;
}

.case-row[data-status="cancelled"] .cell-name::after {
  content: "已取消";
}

.case-row[data-status="no_show"] .cell-name::after {
  content: "未到";
}

.case-row[data-status="arrived"] .cell-name::after,
.case-row[data-status="completed"] .cell-name::after {
  content: attr(data-status-label);
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin: 2px 0 2px 4px;
}

.case-row[data-status="arrived"] .cell-name::after {
  background: #e1eff6;
  color: #1f5870;
}

.case-row[data-status="completed"] .cell-name::after {
  background: #e4f0dc;
  color: #315922;
}

.dragging {
  opacity: 0.45;
}

.drop-before {
  box-shadow: inset 0 3px #285948;
}

.drop-after {
  box-shadow: inset 0 -3px #285948;
}

.append-case {
  display: block;
  padding: 11px 14px;
  width: 100%;
  text-align: start;
  border: 0;
  border-top: 1px dashed var(--line);
  border-radius: 0;
  background: #f9fbf7;
  color: #365745;
  font-size: 13.5px;
  font-weight: 600;
}

.append-case:hover {
  background: #eef4ea;
}

.draft-row {
  background: #ecf5e6;
}

.draft-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--forest);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.draft-row input,
.draft-row textarea {
  background: #fff;
  border-color: #adc2a9;
}

.worksheet .draft-actions {
  padding: 4px 2px;
  text-align: center;
}

.draft-actions button {
  padding: 0;
  width: 28px;
  min-height: 26px;
  margin-bottom: 3px;
}

.draft-error-row td {
  padding: 0;
}

#inline-error:not(:empty) {
  padding: 8px 12px;
  color: var(--error);
  background: #fff2ef;
  font-size: 13px;
  font-weight: 600;
}

.sheet-empty {
  padding: 28px 18px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  background: #ebf0e6;
  color: #42543b;
  white-space: nowrap;
}

.badge.arrived {
  background: #e2eff5;
  color: #215970;
}

.badge.completed {
  background: #e4f0dc;
  color: #365c26;
}

.badge.cancelled {
  background: #e5eff9;
  color: #184f88;
}

.badge.no_show {
  background: #faebd9;
  color: #8a4f08;
}

.category-tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #eef2ec;
  color: #3f524a;
}

/* Panels, Cards & Reports */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px #173b3208;
}

.panel + .panel,
.panel + .workbench,
.workbench + .panel,
.panel + .report-layout {
  margin-top: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-head h2 {
  margin: 0;
}

.subtle {
  color: var(--muted);
  font-size: 12.5px;
}

.count-note,
.field-hint {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0;
  line-height: 1.65;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.summary-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.summary-item strong {
  font-size: 24px;
  font-weight: 700;
  color: var(--forest);
  font-variant-numeric: tabular-nums;
}

.summary-item span {
  font-size: 13px;
  color: var(--muted);
}

.trend-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.trend-title .count-note {
  margin: 4px 0 0;
}

.trend-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.trend-filters label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.trend-filters select {
  min-width: 150px;
  font-weight: 600;
}

.chart-scroll {
  overflow-x: auto;
}

.annual-chart-svg {
  width: 100%;
  min-width: 580px;
  max-height: 300px;
  font: 15px "Microsoft JhengHei", Arial, sans-serif;
  fill: #222;
}

.chart-grid { stroke: #e5eae6; stroke-width: 1; }
.chart-axis { fill: none; stroke: #44524c; stroke-width: 1.5; }
.chart-bar { fill: #3775ba; stroke: #0f4d92; stroke-width: 1; }
.chart-value { font-weight: 700; }
.chart-tick, .chart-unit { font-size: 13.5px; }
.chart-missing { fill: #6c7872; font-size: 12px; }

.report-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.report-versions summary,
.change-reasons summary,
.unregistered-panel summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  padding: 2px 0;
}

.event-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.event-list li {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}

.event-list time {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.event-list p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* Changes & Absence Analysis */
.change-analysis {
  margin-bottom: 16px;
}

.change-chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(28px, 1fr));
  gap: 8px;
  height: 156px;
  padding: 12px 0 4px;
}

.change-month {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.change-sum {
  font-size: 11.5px;
  font-weight: 700;
  color: #2c3e37;
  min-height: 16px;
}

.change-stack {
  height: 98px;
  width: min(30px, 78%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-bottom: 1px solid #5a6b63;
  background: #f3f6f2;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.change-stack span {
  display: block;
}

.change-cancel {
  height: var(--cancel);
  background: #3775ba;
}

.change-absence {
  height: var(--absence);
  background: #df9c43;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 13px;
  font-weight: 600;
}

.legend-cancel { color: #245d9c; }
.legend-absence { color: #9b630e; }

.change-reasons {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.stats-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.changes-table small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.unregistered-panel {
  margin-bottom: 16px;
  border-color: #dfbe9f;
  background: #fffaf5;
}

.unregistered-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.unregistered-item,
.deleted-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

.deleted-item small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

/* Settings View */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.file-picker-label {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

/* Dialogs & Modals */
dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  width: min(560px, 94vw);
  max-height: 90vh;
  color: inherit;
  background: var(--paper);
  box-shadow: 0 12px 32px #12292230;
}

dialog::backdrop {
  background: #14262066;
}

#import-dialog {
  width: min(460px, 94vw);
  overscroll-behavior: contain;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
}

.drawer-head h2 {
  margin-top: 2px;
}

.drawer-head .icon-button {
  border: 0;
  background: transparent;
}

.drawer-head .icon-button:hover {
  background: #e2ebe0;
}

.dialog-body,
.import-fields {
  padding: 20px 22px;
  display: grid;
  gap: 14px;
}

.deleted-list {
  display: grid;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
}

.form-grid {
  padding: 20px 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  max-height: calc(90vh - 140px);
  overflow-y: auto;
}

.form-grid label,
.import-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.form-grid label input[type="date"] {
  width: 100%;
}

.form-grid label small {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.wide {
  grid-column: 1 / -1;
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-subtle);
}

.error {
  color: var(--error);
  font-size: 13px;
  font-weight: 600;
  padding: 0 22px 10px;
  line-height: 1.5;
}

.error:empty {
  display: none;
}

.import-fields .error {
  padding: 0;
}

.report-definition {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--muted);
  padding: 18px 22px 6px;
}

/* Print Preview Modal & A4 Paper Sheet */
#print-sheet {
  display: none;
}

#print-preview {
  width: min(1080px, 95vw);
  max-width: 95vw;
  padding: 0;
  overscroll-behavior: contain;
  height: min(920px, 92dvh);
  max-height: 92dvh;
}

#print-preview[open] {
  display: flex;
  flex-direction: column;
}

#print-preview-body {
  overflow: auto;
  padding: 24px 16px;
  background: #dde3dc;
  flex: 1;
  min-height: 0;
}
#print-preview > .drawer-head, #print-preview > .drawer-actions, #print-options {flex: 0 0 auto;}
#print-options {display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 22px;border-bottom:1px solid var(--line);}
#print-options[hidden] {display:none;}
#print-error {margin:0;padding:0 22px;}
#print-error:not(:empty) {padding:12px 22px;}
.preview-empty {padding:24px;background:white;}

.paper-page {
  color: black;
  background: white;
  width: 210mm;
  max-width: none;
  margin: 0 auto 20px;
  padding: 10mm;
  font-family: "DFKai-SB", "標楷體", serif;
  letter-spacing: 0;
  line-height: normal;
}
.paper-form-title {
  height: 12mm;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
}
.paper-form-title h1 {grid-column:2;margin:0;color:black;font:700 14pt/1.4 "DFKai-SB", "標楷體", serif;white-space:nowrap;}
.paper-form-title > span {grid-column:3;justify-self:end;align-self:start;padding-top:4pt;font:7pt/1.4 "PMingLiU", "新細明體", serif;white-space:nowrap;}
.paper-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; white-space: normal; }
.paper-table col:nth-child(1) { width: 24%; }
.paper-table col:nth-child(2) { width: 8.3%; }
.paper-table col:nth-child(3) { width: 7.65%; }
.paper-table col:nth-child(4) { width: 5.96%; }
.paper-table col:nth-child(5), .paper-table col:nth-child(6), .paper-table col:nth-child(7) { width: 7.03%; }
.paper-table col:nth-child(8) { width: 33%; }
.paper-table th, .paper-table td {
  height: 12mm;
  padding: 1pt 3pt;
  font: 9pt/1.15 "DFKai-SB", "標楷體", serif;
  color: black;
  text-align: center;
  vertical-align: middle;
  border: .32pt solid black;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  background: white;
}
.paper-table .paper-meta-row th { height: 15mm; padding: 0; border: 0; }
.paper-table tbody tr:last-child td { border-bottom: .32pt solid black; }
.paper-form-meta {display:grid;grid-template-columns:1fr 1fr 1fr;align-items:center;height:15mm;font:12pt/1.4 "DFKai-SB", "標楷體", serif;text-align:left;}
.paper-form-meta > span:nth-child(2) {justify-self:center;}
.paper-sign-space {display:inline-block;min-width:23mm;min-height:1em;vertical-align:baseline;}
.paper-date {white-space:nowrap;font-size:11pt;font-weight:400;text-align:right;justify-self:end;}
.paper-table .paper-labels th {height:10mm;font-size:8pt;font-weight:bold;}
.paper-table .paper-labels th:nth-child(7) { font: 10.68pt "PMingLiU", "新細明體", serif; }
.paper-category { word-break: break-all; }
.paper-category font { white-space: pre-wrap; }
.paper-category font[color="#ff3333"], .paper-category font[color="#ff0000"] { font-size: 7.44pt; }

footer {
  margin-top: auto;
  padding: 20px 0 16px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: #b5c4b6;
  border-radius: 5px;
}

/* Responsive Breakpoints across Monitor Sizes */
@media (min-width: 1440px) {
  .report-layout {
    grid-template-columns: 1.45fr 1fr;
    align-items: start;
  }
}

@media (max-width: 1180px) {
  .sheet-hint {
    display: none;
  }
}

@media (max-width: 760px) {
  .rail {
    position: static;
    width: 100%;
    padding: 12px 16px;
  }
  .brand {
    font-size: 17px;
  }
  .rail-bottom {
    display: none;
  }
  nav {
    display: flex;
    margin-top: 10px;
    gap: 4px;
  }
  nav button {
    padding: 8px 10px;
    font-size: 13px;
    flex: 1;
    justify-content: center;
  }
  main {
    margin-left: 0;
    padding: 0 14px;
  }
  .page-head {
    flex-wrap: wrap;
    margin-top: 14px;
  }
  h1 {
    font-size: 22px;
  }
  .schedule-toolbar {
    flex-wrap: wrap;
  }
  .sheet-tools {
    flex-wrap: wrap;
    gap: 8px;
  }
  .sheet-tools input[type="search"] {
    width: 100%;
  }
  .preparer-label {
    margin-inline-start: 0;
  }
  .form-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .event-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  footer span {
    display: none;
  }
}

@media print {
  :root {
    background: white;
  }
  .rail,
  .topbar,
  .actions,
  .filters button,
  footer,
  .row-edit,
  #notice,
  .report-versions,
  .report-method {
    display: none !important;
  }
  main {
    margin: 0;
    padding: 0;
  }
  .workbench {
    border: 0;
    box-shadow: none;
  }
  th,
  td {
    padding: 8px;
  }
  .table-wrap {
    overflow: visible;
  }
  .summary {
    margin-bottom: 10px;
  }
  body {
    background: white;
    color: black;
  }
  @page {
    size: A4 portrait;
    margin: 0;
  }
  @page schedule {
    size: A4 portrait;
    margin: 0;
  }
  body.printing > * {
    display: none !important;
  }
  body.printing > #print-sheet {
    display: block !important;
    padding:12mm;
  }
  body.printing > #print-sheet:has(.paper-page),body.printing > #print-sheet:has(.prescription) {padding:0;}
  #print-sheet .paper-page {
    page: schedule;
    width: 210mm;
    margin: 0;
    padding: 10mm;
    box-shadow: none;
    break-after: page;
  }
  #print-sheet .paper-page:last-child {
    break-after: auto;
  }
  #print-sheet .paper-table {
    min-width: 0;
  }
  #print-sheet thead {
    display: table-header-group;
  }
  #print-sheet tr {
    break-inside: avoid;
  }
  #print-sheet .paper-labels { break-after: avoid; }
  #print-sheet .paper-table th,
  #print-sheet .paper-table td {
    print-color-adjust: exact;
  }
  #print-sheet .annual-chart-svg {
    min-width: 0;
  }
  #print-sheet .panel {
    border: 0;
    padding: 0;
    background: white;
    box-shadow: none;
    overflow: visible;
  }
  #print-sheet .trend-controls label,
  #print-sheet .trend-filters {
    display: none;
  }
}

.pharmacy-table {min-width:1450px;table-layout:fixed;background:var(--paper);}
.pharmacy-table td {vertical-align:top;padding:6px;border-right:1px solid var(--line-soft);}
.pharmacy-table th {padding:9px 6px;}
.pharmacy-table col:nth-child(1) {width:180px;}.pharmacy-table col:nth-child(2) {width:115px;}.pharmacy-table col:nth-child(3) {width:90px;}.pharmacy-table col:nth-child(4) {width:160px;}.pharmacy-table col:nth-child(5) {width:95px;}.pharmacy-table col:nth-child(6) {width:150px;}.pharmacy-table col:nth-child(7) {width:110px;}.pharmacy-table col:nth-child(8) {width:100px;}.pharmacy-table col:nth-child(9) {width:100px;}.pharmacy-table col:nth-child(10) {width:160px;}.pharmacy-table col:nth-child(11) {width:160px;}
.pharmacy-table input:not([type=checkbox]), .pharmacy-table textarea, .pharmacy-table select {width:100%;min-width:0;min-height:34px;padding:6px;border:1px solid transparent;border-radius:2px;background:transparent;font:inherit;}
.pharmacy-table :is(input,textarea,select):hover {border-color:var(--line);}
.pharmacy-table :is(input,textarea,select):focus {outline:2px solid var(--forest);outline-offset:-2px;background:white;}
.pharmacy-table textarea {resize:vertical;white-space:pre-wrap;}
.pharmacy-exam,.pharmacy-nursing {white-space:pre-wrap;overflow-wrap:anywhere;}.pharmacy-mrn {font-variant-numeric:tabular-nums;}
.pharmacy-table details {font-size:12px;margin-top:8px;}.pharmacy-table details label {display:block;}
.pharmacy-tools {display:flex;align-items:end;gap:12px;flex-wrap:wrap;padding:14px 0;}
.pharmacy-tools > label {display:grid;gap:4px;font-size:12px;font-weight:600;}
.pharmacy-actions {position:sticky;bottom:0;display:flex;justify-content:space-between;align-items:center;gap:12px;padding:14px 16px;background:var(--paper);border-top:1px solid var(--line);z-index:2;}
.pharmacy-actions p {margin:0;}.pharmacy-options {margin:18px 0;padding:14px 0;border-top:1px solid var(--line);}
.fixed-label-grid {display:flex;flex-wrap:wrap;gap:16px;margin-top:14px;}.fixed-label-grid label {display:grid;gap:4px;}.fixed-label-grid input {width:100px;}
.print-dates {margin-top:18px;}.print-dates label {display:inline-grid;gap:4px;margin:8px 16px 0 0;}
.check-label {display:inline-flex;align-items:center;gap:6px;font-size:13px;}.date-inline {display:inline-flex;align-items:center;gap:8px;font-weight:600;}
.brand-icon {width:36px;height:36px;flex:none;}.help-document {max-width:850px;background:var(--paper);padding:28px 36px;}.help-document section+section {margin-top:32px;padding-top:24px;border-top:1px solid var(--line);}.help-document h2 {margin-bottom:12px;}.help-document li {padding:5px 0;line-height:1.85;}.help-document p {line-height:1.85;}.help-document ol {padding-left:1.6em;}
@media(max-width:760px){.help-document{padding:20px;}.pharmacy-actions{flex-wrap:wrap;}.pharmacy-tools .sheet-hint{width:100%;}}
#handoff-folder {display:block;padding:12px;background:var(--surface-subtle);overflow-wrap:anywhere;margin-top:8px;}
#handoff-result {white-space:pre-wrap;overflow-wrap:anywhere;}.handoff-success {padding:16px;background:#edf4e9;color:var(--forest);border:1px solid var(--line);}
.drug-labels { display:flex; flex-wrap:wrap; gap:8mm; padding:5mm; background:white; }
.drug-label { width:55mm; padding:2mm; break-inside:avoid; font:10pt Arial,sans-serif; color:black; }
.drug-label strong { display:block; margin-bottom:2mm; }
.ink-blue { color:blue; } .ink-red { color:red; }
.prescription { background:white; color:black; padding:8mm; font:9pt Arial,sans-serif; }
.prescription h2 { text-align:center; }
.prescription table { width:100%; min-width:0; border-collapse:collapse; table-layout:fixed; }
.prescription th,.prescription td { border:1px solid black; padding:3px; overflow-wrap:anywhere; }
@media print { @page prescription { size:A4 landscape; margin:0; } .prescription { page:prescription; padding:8mm; } .drug-labels { gap:4mm; padding:0; } .drug-label { print-color-adjust:exact; } }

.prescription th:first-child { width:22%; }
.prescription th:nth-child(2) { width:7%; }
.prescription th:nth-child(3), .prescription th:nth-child(6) { width:4%; }
.prescription th:nth-child(4), .prescription th:nth-child(5) { width:7%; }
.prescription th:nth-child(7) { width:12%; }
.prescription th:nth-child(8) { width:9%; }
.prescription th:nth-child(9), .prescription th:nth-child(10), .prescription th:nth-child(11) { width:6%; }
.prescription th:nth-child(12) { width:10%; }
/* shortcut: 55mm labels need a hospital printer test before choosing a final stock-specific layout. */

.dashboard-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,400px),1fr)); gap:18px; }
.metric-bars {min-width:0;width:100%;} .metric-bars th {white-space:normal;}
#export-form .dialog-body label {display:block;margin:14px 0;}
@media print {.dashboard-grid {display:block;} .metric-bars svg {max-width:100%;} }

.note-inputs{display:flex;flex-wrap:wrap;gap:8px;padding:5px 0;}.note-inputs label{display:flex;align-items:center;gap:4px;font-size:12px;white-space:nowrap;}.worksheet .note-inputs input,.pharmacy-table .note-inputs input{width:76px;min-width:0;min-height:34px;background:white;border:1px solid var(--line);text-align:right;font-variant-numeric:tabular-nums;}.note-inputs select{min-width:76px;background:white;}.notes-free{margin:6px 0;font-size:12px;}[data-note-text]{white-space:pre-wrap;font-size:12px;color:var(--muted);}.pharmacy-table input[type=hidden]{display:none!important;}.pharmacy-table [data-ph-pick]{margin-bottom:5px;background:var(--surface-subtle);border:1px solid var(--line);font-size:12px;}.pharmacy-table [data-ph-nursing]{min-height:72px;}

#history-dialog {width:min(780px,94vw);max-height:90vh;}
#history-dialog .dialog-body {max-height:70vh;overflow:auto;}
#history-progress {width:100%;margin-top:20px;}
#history-month {max-width:150px;}
#history-result {overflow-wrap:anywhere;}
#content>.page-head{flex-wrap:wrap}#content>.page-head>div:first-child{flex:0 0 auto}#content>.page-head h1{white-space:nowrap}#content>.page-head>.actions{flex:1 1 560px;justify-content:flex-end;flex-wrap:wrap}
.change-month{border:1px solid transparent;background:transparent;padding:6px;display:flex;align-items:center;flex-direction:column;min-width:48px;height:auto;cursor:pointer}.change-month svg{width:100%;height:140px}.change-month:hover,.change-month[aria-pressed=true]{background:#eef5ef;border-color:#6f927d}.change-month:focus-visible{outline:2px solid #285b49;outline-offset:2px}.change-cancel-fill{fill:#a55235}.change-absence-fill{fill:#397789}.change-chart{height:auto;min-height:195px;overflow-x:auto}.coverage-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:6px;margin-top:16px}.coverage-grid>span{text-align:center;padding:10px 2px;border:1px solid var(--line);font-size:13px}.coverage-grid strong{display:block;margin-top:4px;font-size:11px;font-weight:400}.coverage-grid .covered{background:#eef5ef;color:#285b49}.coverage-grid .missing{color:var(--muted)}.help-flows img{width:100%;height:auto;display:block;margin:20px 0}.help-flows p{max-width:75ch;color:var(--muted);font-size:14px;line-height:1.7}.flow-steps{display:flex;align-items:center;gap:12px;list-style:none;padding:0;margin:24px 0;flex-wrap:wrap}.flow-steps li{padding:10px 16px;background:#eef5ef;border:1px solid var(--line)}.flow-steps li+li:before{content:'→';margin-left:-27px;margin-right:14px;color:#567265}.help-flows li{line-height:1.8}.help-flows section{margin-bottom:20px}@media(max-width:1100px){.coverage-grid{grid-template-columns:repeat(6,minmax(0,1fr))}}@media print{.coverage-grid{grid-template-columns:repeat(12,minmax(0,1fr))}.change-month{break-inside:avoid}}
.dashboard-grid{margin:20px 0;gap:18px}.dashboard-grid>.panel{margin:0}#keyword-settings>.table-wrap{max-height:520px;overflow:auto;border:1px solid var(--line)}#keyword-settings thead th{position:sticky;top:0;z-index:1;background:var(--surface-subtle)}
.dashboard-controls{display:flex;justify-content:space-between;gap:24px;align-items:end;flex-wrap:wrap}.dashboard-controls p,.chart-panel>p{color:var(--muted);font-size:13px}.dashboard-kpis{margin:24px 0}.dashboard-kpis strong{font-variant-numeric:tabular-nums}.dashboard-kpis small{font-size:18px;color:var(--muted)}.rank-bars{display:grid;gap:14px;margin-top:24px}.rank-row{display:grid;grid-template-columns:minmax(100px,1fr) minmax(100px,1fr) 48px;align-items:center;gap:12px;font-size:13px}.rank-row>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rank-row>strong{text-align:right;font-variant-numeric:tabular-nums}.rank-row svg{width:100%;height:22px}.chart-increase{fill:#285b49}.chart-decrease{fill:#a55235}.chart-empty{min-height:100px;display:grid;place-content:center}.chart-panel{min-width:0}.reminder-row{display:flex;align-items:end;gap:12px;flex-wrap:wrap;margin:16px 0}#keyword-settings input[type=color]{min-width:46px;width:46px;height:38px;padding:3px}#keyword-settings textarea{min-width:210px;min-height:74px}#keyword-settings [name=exam]{min-width:230px}#backup-settings{display:grid;gap:14px}#backup-settings>label:first-child{display:grid;gap:6px}#backup-status{overflow-wrap:anywhere}#content[aria-busy=true]{opacity:.65}

/* Keep complete exam names visible while using native keyboard suggestions. */
.worksheet .exam-entry { display: grid; }
.worksheet .exam-entry input { grid-area: 1 / 1; align-self: start; min-width: 0; }
.worksheet .exam-entry .cell-ink { position: static; grid-area: 1 / 1; padding: 6px 4px; margin: 4px 2px; }
.worksheet [data-schedule-time] { font-variant-numeric: tabular-nums; font-size: 13px; padding-inline: 3px; }
.worksheet [data-time-mode] { width: 100%; padding: 3px 0; font-size: 11px; }
.cell-notes > label { display: block; font-size: 12px; }
.cell-notes [data-phase] { max-width: 100%; }

.paper-page,.paper-page *,.paper-table th,.paper-table td,.paper-date,.paper-form-title > span {font-weight:700!important;}
.case-number{display:block;font-weight:700}.worksheet [data-mpi]{max-width:100%;font-size:12px}

.template-search {display:flex;align-items:center;gap:12px;margin:20px 0 8px;font-weight:600}.template-search input{width:min(440px,100%)}#template-search-result{color:var(--muted);min-height:22px}#template-rows tr[hidden]{display:none}.backup-places{padding:16px;background:var(--surface-subtle);margin:18px 0}.backup-places>span{display:block;color:var(--muted)}.backup-path{overflow-wrap:anywhere;font-weight:600;color:var(--forest)}.backup-simple>p{max-width:74ch}
.fortune-room{max-width:920px;margin:0 auto;padding:32px;background:#faf7ef;border:1px solid #ded6c2;text-align:center}.fortune-intro h2{font-size:24px;color:#173e35;margin:0 0 8px}.fortune-intro>p,.fortune-foot{color:#53665e}.fortune-stage{display:flex;flex-direction:column;align-items:center;gap:20px;margin:24px auto;max-width:680px}.fortune-holder img{width:240px;height:260px;object-fit:contain}.fortune-poem{width:100%;max-width:510px;background:#fffef9;border:1px solid #ccb67d;padding:24px 18px}.fortune-lot{color:#6d4c22;font-size:16px;font-weight:700}.fortune-poem h3{font-size:28px;color:#8b3443;margin:10px 0 18px}.fortune-verse p{font-size:23px;line-height:1.9;letter-spacing:.05em;margin:4px 0;color:#263f35}.fortune-tabs{display:flex;gap:12px}.fortune-tabs [aria-pressed=true]{background:#173e35;color:#fff;border-color:#173e35}.fortune-reading{text-align:left;background:white;padding:22px 26px;width:100%;border:1px solid var(--line)}.fortune-reading h3{color:#173e35;margin:0 0 10px}.fortune-reading p{line-height:1.9;margin:0;font-size:16px;white-space:pre-wrap}.fortune-source{max-width:680px;margin:26px auto 0;font-size:12px;color:#53665e;text-align:left}.fortune-source summary{cursor:pointer}.fortune-source p{line-height:1.8}.fortune-stage button{min-width:100px;min-height:42px}
@media print{.fortune-room{display:none}}

.fortune-tabs button[aria-pressed=true]:hover{background:#24564a;color:#fff;border-color:#24564a}

/* Screen reading size never changes the clinical paper layout. */
@media screen {
 :root{--reading-size:18px;font-size:16px}
 #content,dialog{font-size:var(--reading-size)}
 #content :is(input,select,textarea,button),dialog :is(input,select,textarea,button),.worksheet .cell-ink,.changes-table td{font-size:var(--reading-size);line-height:1.5}
 .worksheet :is(input,textarea),.worksheet .cell-ink{font-weight:600}
 #content :is(.quick-note-label,.field-hint,.sheet-hint,.subtle),dialog .field-hint{font-size:max(14px,calc(var(--reading-size) - 2px))}
 .table-wrap{max-width:100%;overflow:auto}.worksheet{min-width:1280px}.worksheet .col-name{width:128px}.worksheet .col-mrn{width:108px}.worksheet .col-time,.worksheet .col-imaging_time{width:116px}.worksheet .col-dose{width:90px}
 #content .worksheet :is([data-note-text],.notes-free,.note-inputs label,.cell-notes>label){font-size:var(--reading-size)}
 #content .worksheet th{font-size:max(14px,calc(var(--reading-size) - 2px))}
 .reading-control{display:flex;align-items:center;gap:6px;font-size:14px;white-space:nowrap}.reading-control select{padding:5px 7px;min-height:34px;font-size:14px}
 .topbar{height:auto;min-height:70px;flex-wrap:wrap;gap:10px}.topbar>.actions{flex-wrap:wrap}
 .rail{overflow-y:auto}.rail nav{flex:none}
 .rail nav a{display:flex;align-items:center;gap:12px;padding:11px 14px;text-decoration:none;color:#edf1e6;border-radius:7px;font-size:16px}.rail nav a:hover{background:#285348}.rail nav :is(button,a){font-size:16px}.rail nav a:focus-visible{outline:2px solid #ead9b2;outline-offset:-2px}




 .fortune-intro{padding-inline:80px}
 .fortune-holder{position:relative;width:240px;height:300px;margin-top:110px;isolation:isolate;transform-origin:50% 85%}
 .fortune-holder img{position:absolute;inset:auto 0 0;width:240px;height:260px;z-index:1}
 .fortune-chosen-stick{position:absolute;left:calc(50% - 12px);bottom:95px;width:24px;height:155px;background:linear-gradient(90deg,#b98346,#f5d79f 45%,#bb874c);border:1px solid #95652e;border-radius:5px 5px 2px 2px;box-shadow:2px 2px 3px #47301633;z-index:2;opacity:0;display:flex;align-items:center;flex-direction:column;padding-top:32px;color:#77331d;font:700 16px 'Microsoft JhengHei';transform-origin:50% 85%}
 .fortune-chosen-stick:before{content:'';position:absolute;inset:0 0 auto;height:25px;background:#933f3e;border-radius:4px 4px 0 0}
 .fortune-chosen-stick span{writing-mode:vertical-rl;letter-spacing:5px;margin-top:15px}
 .fortune-holder.drawing{animation:fortune-draw-shake 1.15s ease-in-out both}
 .drawing .fortune-chosen-stick{animation:fortune-stick-rise 2.4s cubic-bezier(.22,.7,.3,1) both}
 .fortune-poem.revealing{animation:fortune-reveal .42s ease-out both}
 .fortune-foot{font-size:16px;min-height:28px}
 @media(max-width:1199px){.fortune-intro{padding-inline:30px}.rail nav :is(button,a){padding-block:9px}}

 @media(max-height:720px){.rail nav{margin-top:12px;gap:3px}}
}
@keyframes fortune-draw-shake{0%,100%{transform:rotate(0)}12%,38%,64%{transform:rotate(-5deg) translateX(-2px)}25%,51%,77%{transform:rotate(5deg) translateX(2px)}90%{transform:rotate(-2deg)}}
@keyframes fortune-stick-rise{0%,42%{opacity:0;transform:translateY(0)}48%{opacity:1;transform:translateY(-14px)}65%{opacity:1;transform:translateY(-92px) rotate(-3deg)}83%{opacity:1;transform:translateY(-140px) rotate(7deg)}94%{opacity:1;transform:translateY(-155px) rotate(5deg) scale(1.1)}100%{opacity:0;transform:translateY(-170px) rotate(4deg) scale(1.12)}}
@keyframes fortune-reveal{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
@media(prefers-reduced-motion:reduce){.fortune-holder.drawing,.drawing .fortune-chosen-stick,.fortune-poem.revealing{animation:none!important}}
