:root {
  --blue: #1677d2;
  --blue-dark: #0e65b8;
  --blue-light: #eef6fd;
  --header: #1677d2;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #eceff2;
  --text: #252b31;
  --muted: #7a838b;
  --danger: #b23b35;
  --viewer: #090b0c;
  --font: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: var(--font); background: #e8ebee; color: var(--text); font-size: 14px; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.mobile-app { position: relative; width: min(430px, 100vw); min-height: 100vh; margin: 0 auto; background: var(--bg); overflow: hidden; box-shadow: 0 0 18px rgba(37,48,58,.16); }
.screen { display: none; min-height: 100vh; background: var(--bg); }
.screen.active { display: block; }
.app-screen { padding-top: 64px; }

.login-brand { height: 170px; padding: 46px 28px 28px; background: var(--header); color: #fff; box-shadow: 0 2px 5px rgba(22,91,151,.2); }
.login-brand p { margin: 0 0 12px; font-size: 16px; letter-spacing: 1px; }
.login-brand h1 { margin: 0; font-size: 28px; font-weight: 600; }
.login-content { min-height: calc(100vh - 170px); padding: 18px 16px; background: var(--bg); }
.login-panel { padding: 24px 20px 22px; background: var(--panel); border-radius: 8px; box-shadow: 0 2px 10px rgba(38,58,74,.08); }
.login-panel h2 { margin: 0 0 22px; font-size: 20px; font-weight: 600; }
.login-panel form { display: grid; gap: 17px; }
.login-panel label > span { display: block; margin-bottom: 7px; color: #4d5b63; }
input[type="text"], input[type="tel"] { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #d9dfe4; border-radius: 5px; background: #fff; outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(23,104,168,.1); }
.form-error { margin: -3px 0 0; color: var(--danger); font-size: 13px; line-height: 1.5; }
.service-note { margin: 13px 4px 0; padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 12px; line-height: 1.7; text-align: left; }

.primary-button, .secondary-button { height: 42px; padding: 0 18px; border-radius: 5px; font-weight: 500; }
.primary-button { color: #fff; background: var(--blue); border: 1px solid var(--blue); }
.primary-button:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.primary-button:disabled { background: #a9b8c2; border-color: #a9b8c2; cursor: default; }
.secondary-button { color: #52616b; background: #fff; border: 1px solid #cfd7dc; }
.wide { width: 100%; margin-top: 4px; }

.app-header, .sub-header { position: fixed; top: 0; left: 50%; right: auto; z-index: 8; width: min(430px, 100vw); height: 64px; transform: translateX(-50%); color: #fff; background: var(--header); box-shadow: 0 2px 5px rgba(20,89,151,.18); }
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 0 17px; }
.app-header p { margin: 0 0 2px; color: var(--muted); font-size: 11px; }
.app-header h1, .sub-header h1 { margin: 0; font-size: 18px; font-weight: 600; }
.header-text-button, .back-button, .sub-header > button { border: 0; background: transparent; color: #fff; padding: 8px 0; }
.sub-header { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; padding: 0 15px; }
.sub-header h1 { text-align: center; }
.sub-header > :last-child { justify-self: end; text-align: right; }

.page-body { min-height: calc(100vh - 64px); padding: 14px; }
.page-body.with-bottom-nav { padding-bottom: 78px; }
.records-body { padding: 0; }
.records-screen { padding-top: 52px; }
.records-header { height: 52px; }
.patient-overview { display: flex; align-items: center; justify-content: space-between; min-height: 73px; margin: 12px 12px 0; padding: 14px 16px; background: var(--panel); border-radius: 8px; box-shadow: 0 2px 8px rgba(38,58,74,.07); }
.patient-overview > div { display: flex; align-items: baseline; gap: 10px; }
.patient-overview strong { font-size: 18px; }
.patient-overview span { color: var(--muted); }
.patient-overview p { max-width: 150px; margin: 0; color: #4f5f68; font-size: 12px; line-height: 1.5; text-align: right; }
.record-filter { display: flex; margin: 10px 12px; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(38,58,74,.06); overflow: hidden; }
.record-filter button { flex: 1; height: 42px; color: #66727a; background: #fff; border: 0; border-bottom: 3px solid transparent; }
.record-filter button.active { color: var(--blue); background: #fff; border-bottom-color: var(--blue); font-weight: 600; }
.record-list { margin: 0 12px 12px; background: var(--panel); border-radius: 8px; box-shadow: 0 2px 10px rgba(38,58,74,.07); overflow: hidden; }
.record-row { width: 100%; min-height: 84px; display: grid; grid-template-columns: 92px 1fr 46px; align-items: center; gap: 8px; padding: 13px 16px; color: var(--text); background: #fff; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.record-row:last-child { border-bottom: 0; }
.record-row:active { background: #f3f8fc; }
.record-time strong, .record-time span, .record-main strong, .record-main span { display: block; }
.record-time strong { color: #4d5860; font-size: 13px; font-weight: 500; }
.record-time span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.record-main { min-width: 0; }
.record-main strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 16px; font-weight: 600; }
.record-main span { margin-top: 7px; overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.record-type { justify-self: end; min-width: 34px; padding: 3px 0; color: var(--blue); background: var(--blue-light); border-radius: 3px; font-size: 12px; font-weight: 600; text-align: center; }

.bottom-nav { position: fixed; bottom: 0; left: 50%; right: auto; z-index: 8; display: grid; grid-template-columns: repeat(2, 1fr); width: min(430px, 100vw); height: 56px; transform: translateX(-50%); background: #fff; border-top: 1px solid #e1e5e8; box-shadow: 0 -2px 8px rgba(34,52,66,.07); }
.bottom-nav button { color: #717b82; background: #fff; border: 0; font-size: 12px; }
.bottom-nav button.active { color: var(--blue); background: #fff; font-weight: 600; border-top: 2px solid var(--blue); }

.detail-body { padding: 12px 12px 82px; }
.detail-lead { padding: 17px 16px; margin: 0 0 12px; background: var(--panel); border-radius: 8px; box-shadow: 0 2px 8px rgba(38,58,74,.07); }
.detail-lead div { display: flex; align-items: center; gap: 10px; }
.detail-lead div span { padding: 3px 7px; color: #fff; background: var(--blue); border-radius: 2px; font-size: 12px; }
.detail-lead strong { font-size: 18px; }
.detail-lead p { margin: 9px 0 0; color: var(--muted); }
.plain-section { margin: 0 0 12px; padding: 16px; background: var(--panel); border-radius: 8px; box-shadow: 0 2px 8px rgba(38,58,74,.07); }
.plain-section h2 { position: relative; margin: 0 0 14px; padding: 0 0 11px 10px; border-bottom: 1px solid var(--line); font-size: 16px; }
.plain-section h2::before { content: ""; position: absolute; top: 2px; bottom: 13px; left: 0; width: 3px; background: var(--blue); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; margin: 0; }
.detail-grid dt { color: var(--muted); font-size: 12px; }
.detail-grid dd { margin: 4px 0 0; font-size: 13px; word-break: break-all; }
.report-section h3 { margin: 16px 0 7px; font-size: 14px; }
.report-section > p { margin: 0; color: #384850; line-height: 1.85; text-align: justify; }
.report-sign { display: grid; gap: 6px; margin-top: 18px; padding-top: 12px; border-top: 1px solid #edf0f2; color: var(--muted); font-size: 12px; }
.detail-actions { position: fixed; bottom: 0; left: 50%; right: auto; z-index: 8; display: grid; grid-template-columns: .7fr .7fr 1.3fr; gap: 9px; width: min(430px, 100vw); padding: 10px 14px; transform: translateX(-50%); background: #fff; border-top: 1px solid #e1e5e8; box-shadow: 0 -2px 8px rgba(34,52,66,.07); }

.viewer-screen { position: relative; height: 100vh; min-height: 700px; overflow: hidden; color: #e6eaec; background: var(--viewer); }
.viewer-screen.active { display: flex; flex-direction: column; }
.viewer-header { height: 55px; flex: 0 0 55px; display: grid; grid-template-columns: 60px 1fr 60px; align-items: center; border-bottom: 1px solid #2c3437; padding: 0 12px; }
.viewer-header button { color: #c9d1d5; background: transparent; border: 0; padding: 8px 0; }
.viewer-header > div { text-align: center; min-width: 0; }
.viewer-header strong, .viewer-header span { display: block; }
.viewer-header strong { font-size: 15px; }
.viewer-header span { margin-top: 2px; color: #9da8ad; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-patient-bar { height: 32px; flex: 0 0 32px; display: flex; justify-content: space-between; align-items: center; padding: 0 10px; color: #b9c1c5; border-bottom: 1px solid #222a2d; font-size: 10px; }
.viewport-wrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 4px 28px 4px 4px; }
.viewport { position: relative; width: min(100%, calc(100vh - 300px)); aspect-ratio: 1; overflow: hidden; background: #000; border: 1px solid #364044; touch-action: none; }
.image-layer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; transform-origin: center; }
.image-layer img { width: 100%; height: 100%; object-fit: contain; user-select: none; pointer-events: none; filter: brightness(1) contrast(1); }
.measurement-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.measurement-line { stroke: #ffe05b; stroke-width: 2; }
.measurement-arm { fill: none; stroke: #ffe05b; stroke-width: 2; }
.measurement-point { fill: #ffe05b; }
.measurement-label { fill: #ffe05b; font: 14px Arial, sans-serif; paint-order: stroke; stroke: #000; stroke-width: 3px; stroke-linejoin: round; }
.overlay { position: absolute; z-index: 2; color: #f2f3d5; font-family: Arial, sans-serif; font-size: 9px; line-height: 1.45; text-shadow: 1px 1px #000; pointer-events: none; }
.top-left { top: 6px; left: 7px; }
.top-right { top: 6px; right: 7px; text-align: right; }
.bottom-left { left: 7px; bottom: 6px; }
.bottom-right { right: 7px; bottom: 6px; text-align: right; }
.orientation { position: absolute; z-index: 2; color: #d9e3e2; font: 11px Arial, sans-serif; text-shadow: 1px 1px #000; }
.orientation-left { left: 5px; top: 50%; }
.orientation-right { right: 5px; top: 50%; }
.orientation-top { top: 5px; left: 50%; }
.orientation-bottom { bottom: 5px; left: 50%; }
.slice-control { position: absolute; top: 8px; bottom: 8px; right: 3px; display: flex; flex-direction: column; align-items: center; gap: 5px; color: #89959a; font-size: 8px; }
.slice-control input { flex: 1; width: 18px; writing-mode: vertical-lr; direction: rtl; accent-color: #9bc3dc; }
.series-strip { height: 84px; flex: 0 0 84px; display: flex; gap: 7px; padding: 7px 9px; overflow-x: auto; border-top: 1px solid #252d30; }
.series-item { min-width: 117px; display: grid; grid-template-columns: 54px 1fr; grid-template-rows: 1fr 1fr; column-gap: 7px; align-items: center; padding: 5px; color: #c4ccd0; background: #14191b; border: 1px solid #394347; text-align: left; }
.series-item.active { border-color: #77acd0; color: #fff; }
.series-item img { width: 54px; height: 54px; grid-row: 1 / 3; object-fit: cover; }
.series-item span { align-self: end; font-size: 10px; }
.series-item small { align-self: start; color: #879399; font-size: 9px; }
.viewer-toolbar { height: 52px; flex: 0 0 52px; display: flex; overflow-x: auto; border-top: 1px solid #30393c; border-bottom: 1px solid #30393c; }
.viewer-toolbar button { min-width: 72px; color: #bbc4c8; background: #171c1e; border: 0; border-right: 1px solid #30393c; font-size: 11px; }
.viewer-toolbar button.active { color: #fff; background: #2d5d79; }
.viewer-hint { height: 27px; flex: 0 0 27px; margin: 0; display: flex; align-items: center; justify-content: center; color: #8f9a9e; font-size: 9px; }

.profile-card { padding: 19px 17px; background: var(--panel); border-radius: 8px; box-shadow: 0 2px 8px rgba(38,58,74,.07); }
.profile-card strong { font-size: 19px; }
.profile-card p { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.plain-menu { margin-top: 12px; background: var(--panel); border-radius: 8px; box-shadow: 0 2px 8px rgba(38,58,74,.07); overflow: hidden; }
.plain-menu button { width: 100%; min-height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; color: var(--text); background: #fff; border: 0; border-bottom: 1px solid #edf0f2; text-align: left; }
.plain-menu button:last-child { border-bottom: 0; }
.plain-menu button span { color: var(--muted); font-size: 12px; }

.modal-mask { position: fixed; top: 0; bottom: 0; left: 50%; z-index: 30; display: flex; align-items: flex-end; justify-content: center; width: min(430px, 100vw); padding: 16px; transform: translateX(-50%); background: rgba(17,25,30,.55); }
.modal-panel { width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; background: #fff; border-radius: 10px 10px 4px 4px; border: 0; box-shadow: 0 6px 20px rgba(15,33,46,.22); }
.modal-panel > header, .authorization-panel > header, #share-form-view > header, .share-result > header { padding: 19px 18px 15px; border-bottom: 1px solid var(--line); }
.modal-panel h2 { margin: 0; font-size: 18px; }
.modal-panel header p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.modal-panel footer { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 18px; border-top: 1px solid var(--line); }
.authorization-detail { margin: 0; padding: 8px 18px; }
.authorization-detail div { display: grid; grid-template-columns: 72px 1fr; gap: 9px; padding: 9px 0; border-bottom: 1px solid #edf0f2; }
.authorization-detail dt { color: var(--muted); }
.authorization-detail dd { margin: 0; line-height: 1.6; }
.consent-line { display: flex; gap: 9px; padding: 12px 18px 17px; color: #37464e; line-height: 1.55; }
.consent-line input { margin-top: 3px; accent-color: var(--blue); }
.option-list { padding: 10px 18px; }
.option-item { display: flex; align-items: flex-start; gap: 10px; padding: 13px 0; border-bottom: 1px solid #edf0f2; }
.option-item:last-child { border-bottom: 0; }
.option-item input { margin-top: 4px; accent-color: var(--blue); }
.option-item span, .option-item strong, .option-item small { display: block; }
.option-item small { margin-top: 5px; color: var(--muted); }
.task-progress { padding: 7px 18px 16px; }
.task-progress > div { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 12px; }
.task-progress i { display: block; height: 5px; overflow: hidden; background: #e5eaed; }
.task-progress b { display: block; width: 0; height: 100%; background: var(--blue); transition: width .2s; }
.form-block { padding: 15px 18px 4px; }
.field-title { display: block; margin-bottom: 10px; color: #4f5f68; }
.radio-line { display: inline-flex; align-items: center; margin-right: 15px; color: var(--text); }
.radio-line input { margin-right: 5px; accent-color: var(--blue); }
.choice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-row button { height: 36px; color: #4c5b63; background: #fff; border: 1px solid #c5ced3; border-radius: 3px; }
.choice-row button.active { color: var(--blue); border-color: var(--blue); background: var(--blue-light); }
.password-field { display: block; padding: 14px 18px 18px; }
.password-field span { display: block; margin-bottom: 8px; }
.share-result dl { margin: 0; padding: 9px 18px; }
.share-result dl div { display: grid; grid-template-columns: 84px 1fr; padding: 8px 0; }
.share-result dt { color: var(--muted); }
.share-result dd { margin: 0; text-align: right; }
.share-link-box { margin: 4px 18px 17px; padding: 11px; color: #3b4b54; background: #f4f6f7; border: 1px solid #d8dfe3; font-size: 12px; line-height: 1.5; word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: 90px; z-index: 50; transform: translateX(-50%); min-width: 150px; padding: 10px 14px; color: #fff; background: rgba(25,34,39,.9); border-radius: 3px; text-align: center; font-size: 12px; }

@media (max-width: 520px) {
  html, body { background: var(--bg); }
  .mobile-app { width: 100%; box-shadow: none; }
}

@media (max-height: 760px) {
  .viewer-screen { min-height: 640px; }
  .series-strip { height: 72px; flex-basis: 72px; }
  .series-item { min-width: 105px; grid-template-columns: 46px 1fr; }
  .series-item img { width: 46px; height: 46px; }
}
