:root {
  --blue: #2563eb; --blue-dark: #1d4ed8;
  --green: #16a34a; --green-dark: #15803d;
  --red: #dc2626; --amber: #d97706; --purple: #7c3aed;
  --gray-50: #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
  --gray-400: #94a3b8; --gray-600: #475569; --gray-900: #0f172a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--gray-50); color: var(--gray-900);
  padding-bottom: 90px; -webkit-text-size-adjust: 100%;
}
header {
  background: var(--gray-900); color: white; padding: 12px 16px;
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
header h1 { margin: 0; font-size: 16px; font-weight: 600; }
header .who { font-size: 12px; opacity: .75; margin-top: 2px; }
header button.link-btn {
  background: none; border: 1px solid rgba(255,255,255,.3); color: white;
  padding: 6px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
}
main { padding: 16px; max-width: 760px; margin: 0 auto; }
.card { background: white; border: 1px solid var(--gray-200); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 6px; }
.card .sub { font-size: 12px; color: var(--gray-600); margin: 0 0 10px; line-height: 1.5; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-600); margin: 12px 0 4px; }
label.req::after { content: " *"; color: var(--red); }
input[type=text], input[type=number], input[type=month], input[type=password], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--gray-200);
  border-radius: 8px; font-size: 16px; background: white;
}
textarea { min-height: 64px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 16px; border-radius: 10px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer; width: 100%; margin-top: 14px;
}
.btn:disabled { opacity: .55; }
.btn-primary { background: var(--blue); color: white; }
.btn-green { background: var(--green); color: white; }
.btn-red { background: var(--red); color: white; }
.btn-secondary { background: var(--gray-100); color: var(--gray-900); }
.btn-outline { background: white; color: var(--blue); border: 1px solid var(--blue); }
.btn-sm { width: auto; padding: 8px 12px; font-size: 13px; margin-top: 0; }

/* 大按鈕選擇（部位/側別，術前 30 秒內完成） */
.big-choice { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.big-choice button {
  flex: 1 1 calc(50% - 4px); min-height: 54px; padding: 12px 8px;
  border: 2px solid var(--gray-200); background: white; border-radius: 10px;
  font-size: 15px; font-weight: 600; color: var(--gray-900); cursor: pointer;
}
.big-choice button.sel { border-color: var(--blue); background: #eff6ff; color: var(--blue-dark); }
.big-choice.two button { flex: 1 1 calc(50% - 4px); }

.yn { display: flex; gap: 10px; margin-top: 4px; }
.yn button {
  flex: 1; padding: 13px 8px; border: 2px solid var(--gray-200); background: white;
  border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; color: var(--gray-900);
}
.yn button.sel-yes { border-color: var(--green); background: #f0fdf4; color: var(--green-dark); }
.yn button.sel-no { border-color: var(--red); background: #fef2f2; color: var(--red); }

.chk-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.chk-row:last-child { border-bottom: none; }
.chk-row input[type=checkbox] { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.chk-row label { margin: 0; font-weight: 500; color: var(--gray-900); font-size: 14px; }

.radio-list label {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px;
  border: 2px solid var(--gray-200); border-radius: 10px; margin: 8px 0 0;
  font-weight: 500; color: var(--gray-900); font-size: 14px; cursor: pointer;
}
.radio-list label.sel { border-color: var(--blue); background: #eff6ff; }
.radio-list input { width: 20px; height: 20px; flex-shrink: 0; }

.hint { font-size: 12px; color: var(--gray-600); margin-top: 4px; line-height: 1.5; }
.warn-box { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-top: 10px; }
.info-box { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--blue-dark); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-top: 10px; }

.pill { display: inline-block; font-size: 11px; padding: 3px 9px; border-radius: 10px; font-weight: 600; }
.pill-green { background: #f0fdf4; color: var(--green-dark); }
.pill-red { background: #fef2f2; color: var(--red); }
.pill-gray { background: var(--gray-100); color: var(--gray-600); }
.pill-amber { background: #fff7ed; color: var(--amber); }
.pill-purple { background: #f5f3ff; color: var(--purple); }
.pill-blue { background: #eff6ff; color: var(--blue-dark); }

.case-id-badge {
  display: inline-block; background: #eff6ff; color: var(--blue-dark);
  padding: 10px 16px; border-radius: 8px; font-weight: 700; font-size: 17px;
  letter-spacing: 1px; margin-top: 8px; font-family: ui-monospace, monospace;
}
.empty-state { text-align: center; color: var(--gray-400); padding: 28px 0; font-size: 13px; }

.photo-slot { border: 1px dashed var(--gray-200); border-radius: 10px; padding: 12px; margin-top: 10px; }
.photo-slot.filled { border-style: solid; border-color: var(--green); background: #f0fdf4; }
.photo-slot .slot-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.photo-slot .slot-desc { font-size: 12px; color: var(--gray-600); line-height: 1.5; margin-bottom: 8px; }
.photo-slot img.preview { width: 100%; max-width: 220px; border-radius: 8px; border: 1px solid var(--gray-200); margin-top: 8px; }

.mask-tool canvas { max-width: 100%; border-radius: 8px; border: 1px solid var(--gray-200); touch-action: none; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: white; padding: 11px 18px; border-radius: 20px;
  font-size: 13px; z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: .96; }

.module-entry {
  display: block; width: 100%; text-align: left; border: none; cursor: pointer;
  border-radius: 12px; padding: 18px; margin-bottom: 12px; color: white;
}
.module-entry .m-title { font-size: 17px; font-weight: 700; }
.module-entry .m-desc { font-size: 12.5px; opacity: .92; margin-top: 5px; line-height: 1.5; }
.module-entry .m-progress { font-size: 12px; opacity: .95; margin-top: 8px; font-weight: 600; }
.module-entry.blue { background: var(--blue); }
.module-entry.green { background: var(--green); }
.module-entry.red { background: var(--red); }
.module-entry.locked { background: var(--gray-400); cursor: not-allowed; }

.list-item { border-bottom: 1px solid var(--gray-100); padding: 12px 0; cursor: pointer; }
.list-item:last-child { border-bottom: none; }
.list-item .li-main { font-size: 14px; font-weight: 600; }
.list-item .li-meta { font-size: 12px; color: var(--gray-600); margin-top: 3px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-box { background: white; border: 1px solid var(--gray-200); border-radius: 10px; padding: 14px; text-align: center; }
.stat-box .num { font-size: 25px; font-weight: 700; color: var(--blue); }
.stat-box.warn .num { color: var(--red); }
.stat-box .lbl { font-size: 11.5px; color: var(--gray-600); margin-top: 3px; line-height: 1.4; }

/* 待完成提醒：有待辦時整格轉紅底並可點擊 */
.stat-box.alert { border-color: var(--red); background: #fef2f2; }
.stat-box.alert .num { color: var(--red); }
.stat-box.tappable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.stat-box.tappable:active { transform: scale(.97); }
.stat-box .tap-hint { font-size: 11px; color: var(--red); font-weight: 700; margin-top: 6px; }

/* 紅底圈圈數字 */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 7px; margin-left: 6px;
  background: var(--red); color: #fff; border-radius: 12px;
  font-size: 13px; font-weight: 700; line-height: 1; vertical-align: middle;
  box-shadow: 0 0 0 2px rgba(255,255,255,.6);
}

.progress-bar { background: var(--gray-100); border-radius: 6px; height: 8px; overflow: hidden; margin-top: 6px; }
.progress-bar .fill { background: var(--blue); height: 100%; }

details.more { margin-top: 12px; }
details.more > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--blue);
  padding: 8px 0; list-style: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }

.queue-banner {
  background: var(--amber); color: white; padding: 9px 16px; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.queue-banner button { background: rgba(255,255,255,.25); border: none; color: white; padding: 5px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; }

.back-link { background: none; border: none; color: var(--blue); font-size: 14px; cursor: pointer; padding: 8px 0; font-weight: 600; }
