﻿:root {
  --primary: #087f70;
  --primary-dark: #056558;
  --primary-soft: #e9f8f5;
  --ink: #132a27;
  --muted: #667a76;
  --line: #d9e5e2;
  --surface: #ffffff;
  --background: #f2f7f6;
  --danger: #bd2f3e;
  --warning: #a95b00;
  --shadow: 0 18px 48px rgba(20, 60, 53, 0.11);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--background);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--background); }
body { min-height: 100vh; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.loading-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #fff; background: rgba(7, 46, 41, 0.68); backdrop-filter: blur(3px); }
.spinner { width: 46px; height: 46px; border: 4px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 15%, #c9efe7 0, transparent 36%), linear-gradient(135deg, #eaf8f5, #f7fbfa 55%, #d8f0eb); }
.login-card { width: 100%; max-width: 460px; padding: 34px; border-radius: 22px; background: rgba(255,255,255,0.96); box-shadow: var(--shadow); }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; color: #fff; background: linear-gradient(145deg, #18a895, #076b5e); font-size: 29px; font-weight: 800; box-shadow: 0 9px 22px rgba(8,127,112,.25); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 22px; }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { margin: 20px 0 8px; font-size: clamp(25px, 5vw, 32px); }
.login-description { color: var(--muted); line-height: 1.7; }
.field-label { display: block; margin: 17px 0 7px; font-size: 14px; font-weight: 700; }
.text-input, .date-input, .select-input { width: 100%; min-height: 50px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; outline: none; }
.text-input:focus, .date-input:focus, .select-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(8,127,112,.11); }
.primary-button, .ghost-button, .tab-button, .back-button, .sign-button, .icon-button { border: 0; cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease; }
.primary-button { min-height: 48px; padding: 12px 20px; border-radius: 12px; color: #fff; background: var(--primary); font-weight: 700; box-shadow: 0 8px 20px rgba(8,127,112,.18); }
.primary-button:hover { background: var(--primary-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; transform: none; box-shadow: none; }
.primary-button.wide { width: 100%; margin-top: 8px; }
.ghost-button { min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fff; font-weight: 700; }
.ghost-button:hover { border-color: #9fc8c0; background: var(--primary-soft); }
.form-error { min-height: 22px; margin: 10px 0 0; color: var(--danger); font-size: 14px; }
.privacy-note { margin: 20px 0 0; color: #859591; font-size: 12px; line-height: 1.6; text-align: center; }
.app-shell { min-height: 100vh; }
.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px clamp(16px, 4vw, 48px); border-bottom: 1px solid rgba(208,225,221,.9); background: rgba(255,255,255,.94); backdrop-filter: blur(10px); }
.header-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-brand strong { display: block; font-size: 17px; }
.clinic-name { display: block; max-width: 48vw; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.today-label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.main-content { width: 100%; max-width: 1260px; margin: 0 auto; padding: clamp(18px, 4vw, 42px); }
.view-panel { animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.hero-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }

.hero-row h2 { margin: 0 0 6px; font-size: clamp(22px, 4vw, 31px); }
.hero-row.compact { margin-bottom: 14px; }
.muted { color: var(--muted); line-height: 1.6; }
.tabs { display: flex; gap: 8px; padding: 6px; margin: 22px 0 20px; border: 1px solid var(--line); border-radius: 15px; background: #fff; width: fit-content; max-width: 100%; }
.tab-button { min-height: 44px; padding: 9px 22px; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 700; }
.tab-button.active { color: #fff; background: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.list-toolbar, .search-row { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.list-toolbar label { color: var(--muted); font-weight: 700; }
.date-input { width: auto; }
.search-input { flex: 1; min-width: 0; }
.search-summary { margin: 10px 2px; font-size: 13px; }
.patient-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 18px; }
.patient-card { position: relative; display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: #fff; box-shadow: 0 5px 18px rgba(32,69,63,.05); }
.patient-card:hover { border-color: #8dc9bf; box-shadow: 0 11px 26px rgba(32,69,63,.1); }
.patient-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.patient-name { margin: 0; font-size: 20px; }
.patient-meta, .patient-line { color: var(--muted); font-size: 13px; line-height: 1.55; }
.patient-line strong { color: var(--ink); }
.status-pill { flex: none; padding: 5px 9px; border-radius: 999px; color: #086a5d; background: #e2f6f2; font-size: 12px; font-weight: 700; }
.patient-card .primary-button { width: 100%; min-height: 44px; }
.empty-state { padding: 38px 20px; margin-top: 18px; border: 1px dashed #bbd2cd; border-radius: 17px; color: var(--muted); background: rgba(255,255,255,.7); text-align: center; line-height: 1.7; }
.back-button { padding: 9px 0; color: var(--primary); background: transparent; font-weight: 700; }
.selected-patient-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; padding: 18px 20px; margin-bottom: 18px; border: 1px solid #c9e2dd; border-radius: 17px; background: linear-gradient(135deg, #f5fffd, #eaf8f5); }
.selected-patient-card .name { font-size: 21px; font-weight: 800; }
.selected-patient-card .item { color: var(--muted); font-size: 14px; }
.selected-patient-card .item strong { color: var(--ink); }
.agreement-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 13px; }
.agreement-card { display: flex; min-height: 130px; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 19px; border: 1px solid var(--line); border-radius: 17px; color: var(--ink); background: #fff; text-align: left; cursor: pointer; box-shadow: 0 5px 18px rgba(32,69,63,.05); }
.agreement-card:hover { border-color: #8dc9bf; background: #fbfffe; transform: translateY(-2px); }
.agreement-card strong { font-size: 18px; line-height: 1.45; }
.agreement-card span { color: var(--primary); font-size: 13px; font-weight: 700; }
.sign-toolbar { display: grid; grid-template-columns: auto 1fr minmax(210px, 280px); align-items: center; gap: 18px; margin-bottom: 16px; }
.sign-title h2 { margin: 0; font-size: clamp(21px, 3.5vw, 28px); }
.doctor-picker label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.notice { padding: 12px 15px; margin-bottom: 13px; border-radius: 12px; color: #6b4300; background: #fff4d8; line-height: 1.6; }
.agreement-stage { position: relative; overflow: auto; border: 1px solid var(--line); border-radius: 17px; background: #dfe8e6; box-shadow: var(--shadow); overscroll-behavior: contain; }
#agreement-frame { display: block; width: 920px; height: 800px; border: 0; background: #fff; transform-origin: top left; }

.sign-actions { position: sticky; bottom: 0; z-index: 10; display: grid; grid-template-columns: auto 1fr 1fr minmax(240px, 1.2fr); gap: 12px; padding: 14px 0 6px; background: linear-gradient(to top, var(--background) 75%, transparent); }
.sign-button { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: #fff; text-align: left; }
.sign-button:hover { border-color: #8dc9bf; }
.sign-button.patient { border-left: 5px solid #e67e22; }
.sign-button.doctor { border-left: 5px solid var(--primary); }
.sign-button-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; background: var(--primary-soft); font-size: 22px; }
.sign-button strong, .sign-button small { display: block; }
.sign-button small { margin-top: 3px; color: var(--muted); }
.sign-button.signed { background: #f2fff9; }
.save-button, .bottom-back-button { min-height: 68px; border-radius: 15px; }
.bottom-return { margin-top: 18px; text-align: center; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: rgba(6,37,33,.65); backdrop-filter: blur(4px); }
.modal-card { width: 100%; max-width: 900px; max-height: 96vh; overflow: auto; padding: 22px; border-radius: 20px; background: #fff; box-shadow: 0 25px 80px rgba(0,0,0,.25); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-header h2 { margin: 0; }
.icon-button { width: 42px; height: 42px; border-radius: 12px; color: var(--muted); background: #f0f5f4; font-size: 25px; }
.canvas-wrap { position: relative; height: clamp(240px, 42vh, 390px); margin: 14px 0 18px; border: 2px dashed #aac9c3; border-radius: 15px; overflow: hidden; background: #fff; touch-action: none; }
#signature-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.canvas-placeholder { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: #b3bebc; font-size: 25px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 500; width: auto; max-width: calc(100% - 28px); padding: 13px 18px; border-radius: 12px; color: #fff; background: #153b35; box-shadow: 0 12px 40px rgba(0,0,0,.2); transform: translateX(-50%); line-height: 1.5; }
.toast.error { background: #9e2936; }
@media (max-width: 900px) {
  .sign-toolbar { grid-template-columns: 1fr; gap: 6px; }
  .doctor-picker { max-width: 100%; }
  .sign-actions { grid-template-columns: 1fr 1fr; }
  .bottom-back-button { grid-column: 1 / -1; }
  .save-button { grid-column: 1 / -1; }
}
@media (max-width: 650px) {
  .app-header { padding: 10px 13px; }
  .today-label { display: none; }
  .main-content { padding: 16px 12px 24px; }
  .hero-row { align-items: stretch; flex-direction: column; }
  .hero-row .ghost-button { align-self: flex-start; }
  .tabs { width: 100%; }
  .tab-button { flex: 1; padding-inline: 8px; }
  .list-toolbar, .search-row { flex-wrap: wrap; }
  .date-input, .search-input { flex: 1 1 200px; width: 100%; }
  .patient-list, .agreement-list { grid-template-columns: 1fr; }
  .sign-actions { grid-template-columns: 1fr; }
  .save-button { grid-column: auto; }
  .modal-card { padding: 17px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions button { flex: 1; }
}





/* UI refresh based on the supplied healthcare reference */
:root {
  --primary: #245b47;
  --primary-dark: #194333;
  --primary-soft: #deece4;
  --accent: #f17852;
  --ink: #17362a;
  --muted: #6f8279;
  --line: #cbdcd2;
  --background: #e7efe9;
  --surface: #ffffff;
  --shadow: 0 18px 50px rgba(32, 73, 55, 0.12);
}
body {
  background:
    radial-gradient(circle at 88% 8%, rgba(89, 137, 112, 0.19) 0, rgba(89, 137, 112, 0) 30%),
    radial-gradient(circle at 8% 88%, rgba(73, 122, 96, 0.16) 0, rgba(73, 122, 96, 0) 34%),
    var(--background);
}
.app-header { border-bottom-color: rgba(36, 91, 71, 0.12); box-shadow: 0 8px 30px rgba(35, 75, 57, 0.08); }
.header-actions { flex-wrap: wrap; justify-content: flex-end; }
.main-nav { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: #edf4ef; }
.nav-button { min-height: 38px; padding: 7px 18px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-weight: 800; cursor: pointer; }
.nav-button.active { color: #fff; background: var(--primary); box-shadow: 0 7px 16px rgba(36, 91, 71, 0.2); }
.patient-card, .agreement-card, .signed-card { border-color: rgba(36, 91, 71, 0.13); border-radius: 22px; box-shadow: 0 12px 30px rgba(36, 91, 71, 0.08); }
.patient-card { overflow: hidden; }
.patient-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 7px; background: var(--primary); }
.patient-card:nth-child(4n+2)::before { background: var(--accent); }
.patient-card:nth-child(4n+3)::before { background: #c69a45; }
.patient-card:nth-child(4n+4)::before { background: #8b79b8; }
.agreement-card:nth-child(4n+1) { background: linear-gradient(145deg, #f9fcfa, #e6f2eb); }
.agreement-card:nth-child(4n+2) { background: linear-gradient(145deg, #fffaf7, #fbe5dc); }
.agreement-card:nth-child(4n+3) { background: linear-gradient(145deg, #fbfaff, #ebe7f7); }
.agreement-card:nth-child(4n+4) { background: linear-gradient(145deg, #fffdf7, #f7edcf); }
.selected-patient-card { border-radius: 22px; background: linear-gradient(145deg, #f9fffc, #deeee5); }
.tabs { border-radius: 999px; }
.tab-button.active { background: var(--primary); }
.primary-button { background: var(--primary); }
.primary-button:hover { background: var(--primary-dark); }
.ghost-button:hover { background: var(--primary-soft); border-color: #9ebcac; }
.signed-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.signed-card { display: grid; gap: 14px; padding: 20px; background: #fff; }
.signed-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.signed-card h3 { margin: 4px 0 0; font-size: 19px; line-height: 1.45; }
.signed-time { color: var(--primary); font-size: 13px; font-weight: 800; }
.upload-pill { flex: none; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.upload-pill.uploaded { color: #1e6545; background: #dff2e7; }
.upload-pill.pending { color: #97512f; background: #fde9df; }
.signed-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; color: var(--muted); font-size: 14px; }
.signed-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.signed-actions button { flex: 1 1 130px; min-height: 44px; }
.upload-error { padding: 9px 11px; border-radius: 10px; color: #9c3f2a; background: #fff0ea; font-size: 13px; line-height: 1.5; }
@media (max-width: 760px) {
  .app-header { align-items: flex-start; }
  .header-actions { gap: 8px; }
  .main-nav { order: -1; }
  .nav-button { min-height: 35px; padding-inline: 14px; }
  .signed-list { grid-template-columns: 1fr; }
}

/* Maintenance and editors */
.maintenance-grid { display: grid; gap: 18px; }
.maintenance-card { padding: 20px; border: 1px solid rgba(36, 91, 71, 0.14); border-radius: 22px; background: #fff; box-shadow: 0 12px 30px rgba(36, 91, 71, 0.08); }
.maintenance-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.maintenance-card h3 { margin: 0 0 5px; font-size: 20px; }
.maintenance-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.maintenance-list { display: grid; gap: 10px; }
.maintenance-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 15px; background: #f9fcfa; }
.maintenance-row strong, .maintenance-row small { display: block; }
.maintenance-row small { margin-top: 3px; color: var(--muted); }
.maintenance-row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.maintenance-row-actions button { min-height: 40px; padding: 8px 13px; }
.doctor-signature-preview { width: 130px; height: 58px; object-fit: contain; border-bottom: 1px solid #b9c9c0; background: #fff; }
.doctor-signature-row { grid-template-columns: minmax(160px, 1fr) 150px auto; }
.danger-button { color: #a33b2b; border-color: #e5b7ad; background: #fff8f5; }
.editor-modal-card { max-width: 900px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.editor-toolbar button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--primary); background: var(--primary-soft); cursor: pointer; }
.editor-textarea { width: 100%; min-height: 340px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; font-family: ui-monospace, Consolas, monospace; line-height: 1.6; resize: vertical; outline: none; }
.permission-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px 18px; margin: 14px 0 20px; }
.permission-list label { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: #f3f8f5; }
@media (max-width: 760px) {
  .maintenance-card-head, .maintenance-row, .doctor-signature-row { display: flex; flex-direction: column; align-items: stretch; }
  .doctor-signature-preview { width: 100%; }
  .permission-list { grid-template-columns: 1fr; }
}

.system-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: stretch; }
.editor-preview { min-width: 0; }
.editor-preview-title { margin-bottom: 7px; font-weight: 800; }
#agreement-preview-frame { width: 100%; height: 360px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
@media (max-width: 760px) {
  .editor-split { grid-template-columns: 1fr; }
  #agreement-preview-frame { height: 300px; }
}

.patient-detail-actions { display: flex; justify-content: flex-end; margin: -6px 0 16px; }

/* App Store inspired UI */
:root {
  --primary: #0071e3;
  --primary-dark: #005bb5;
  --primary-soft: #e8f2ff;
  --accent: #ff6b35;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --background: #f5f5f7;
  --surface: #ffffff;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}
body { background: #f5f5f7; color: #1d1d1f; }
.login-view { background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%); }
.login-card { border: 1px solid #e5e5e7; border-radius: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.08); }
.brand-mark { background: linear-gradient(145deg, #2997ff, #0066cc); box-shadow: 0 10px 24px rgba(0,113,227,.25); }
.app-header { background: rgba(255,255,255,.88); border-bottom: 1px solid #d2d2d7; box-shadow: none; }
.main-nav { background: #e8e8ed; padding: 3px; }
.nav-button { min-height: 36px; padding: 7px 17px; color: #4b4b50; }
.nav-button.active { color: #1d1d1f; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.14); }
.primary-button { background: #0071e3; box-shadow: 0 7px 18px rgba(0,113,227,.2); }
.primary-button:hover { background: #005bb5; }
.primary-button:disabled { background: #a1c9f5; opacity: .6; }
.ghost-button { border-color: #d2d2d7; background: #fff; }
.ghost-button:hover { border-color: #0071e3; background: #f5faff; }
.tabs { border-color: #e5e5e7; background: #e8e8ed; border-radius: 999px; }
.tab-button.active { color: #1d1d1f; background: #fff; box-shadow: 0 2px 7px rgba(0,0,0,.12); }
.patient-card, .agreement-card, .signed-card, .maintenance-card { border: 1px solid #e5e5e7; border-radius: 24px; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.055); }
.patient-card::before { display: none; }
.patient-card:hover, .agreement-card:hover { border-color: #b8d9fa; box-shadow: 0 13px 32px rgba(0,113,227,.12); }
.agreement-card:nth-child(n) { background: #fff; }
.selected-patient-card { border-color: #e5e5e7; border-radius: 22px; background: #fff; }
.status-pill, .upload-pill.uploaded { color: #087343; background: #e6f7ed; }
.upload-pill.pending { color: #9a4d00; background: #fff1df; }
.sign-button.patient { border-left-color: #ff9500; }
.sign-button.doctor { border-left-color: #0071e3; }
.sign-button.signed { background: #f0f8ff; }
.agreement-stage { border-color: #d2d2d7; border-radius: 22px; background: #e8e8ed; }
.app-header .clinic-name, .muted, .patient-meta, .patient-line { color: #6e6e73; }
h1, h2, h3, .patient-name { letter-spacing: -.02em; }

/* Cross-device clarity and older WebView compatibility */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.agreement-stage { -webkit-overflow-scrolling: touch; }
@media (max-width: 650px) {
  .app-header { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .header-brand { gap: 8px; flex: 1 1 auto; min-width: 0; }
  .header-brand strong { font-size: 0; white-space: nowrap; }
  .header-brand strong::after { content: '知情同意书'; font-size: 15px; }
  .brand-mark.small { width: 36px; height: 36px; border-radius: 11px; font-size: 19px; }
  .clinic-name { max-width: 100%; }
  .header-actions { gap: 5px; }
  .main-nav { padding: 2px; }
  .nav-button { min-height: 34px; padding: 6px 11px; font-size: 14px; }
  .header-actions .ghost-button { min-height: 38px; padding: 7px 11px; }
}
