:root {
  --ink: #173b32;
  --ink-deep: #0d2a24;
  --jade: #2f765f;
  --jade-light: #dcece4;
  --paper: #f7f3ea;
  --white: #fffefa;
  --gold: #bd8b3a;
  --orange: #c86b42;
  --blue: #46718a;
  --text: #24332f;
  --muted: #66736f;
  --line: #dbe2dc;
  --danger: #b33b3b;
  --shadow: 0 18px 55px rgba(20, 53, 44, .09);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--paper); font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; line-height: 1.65; }
a { color: var(--jade); text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(189, 139, 58, .35); outline-offset: 2px; }
.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.muted { color: var(--muted); }

.site-header { position: relative; overflow: hidden; padding: 58px 0 70px; color: white; background: linear-gradient(130deg, var(--ink-deep), var(--jade)); }
.site-header::before, .site-header::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.11); border-radius: 50%; }
.site-header::before { width: 360px; height: 360px; right: -80px; top: -220px; }
.site-header::after { width: 240px; height: 240px; right: 160px; bottom: -190px; }
.header-inner { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; }
.site-header h1 { margin: 0 0 8px; font-family: SimSun, serif; font-size: clamp(36px, 5vw, 58px); letter-spacing: .08em; }
.site-header p:not(.eyebrow) { max-width: 680px; margin: 0; color: rgba(255,255,255,.78); }
.progress-card { width: 270px; padding: 18px; border: 1px solid rgba(255,255,255,.17); border-radius: 16px; background: rgba(255,255,255,.09); backdrop-filter: blur(8px); }
.progress-card > span { color: rgba(255,255,255,.72); font-size: 13px; }
.progress-card strong { float: right; }
.progress-track { height: 7px; margin-top: 12px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.18); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #efc674; transition: width .25s ease; }

.main-content { position: relative; margin-top: -34px; padding-bottom: 60px; }
.notice-card, .form-section, .submit-card { border: 1px solid rgba(47,118,95,.12); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.notice-card { padding: 26px 30px; margin-bottom: 22px; }
.notice-card h2 { margin: 0; color: var(--ink); font-size: 19px; }
.notice-card ol { margin: 10px 0 0; padding-left: 22px; color: var(--muted); }
.error-summary { margin: 0 0 20px; padding: 18px 22px; border: 1px solid #e5aaaa; border-left: 5px solid var(--danger); border-radius: 12px; background: #fff4f2; color: #812d2d; }
.error-summary ul { margin: 6px 0 0; }
.form-section { padding: 34px; margin-bottom: 22px; }
.section-heading { display: flex; gap: 18px; align-items: flex-start; padding-bottom: 22px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.section-heading > span { display: grid; place-items: center; flex: 0 0 42px; height: 42px; border-radius: 12px; color: white; background: var(--jade); font-size: 13px; font-weight: 800; }
.section-heading h2 { margin: 0; color: var(--ink); font-family: SimSun, serif; font-size: 24px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.field-grid, .complaint-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.intake-stack, .question-stack { display: grid; grid-template-columns: 1fr; gap: 20px; }
.complaint-pair-grid, .history-pair-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.intake-stack .field { margin: 0; }
.single-row-choice { padding-bottom: 4px; }
.single-row-choice legend { margin-bottom: 10px; color: #3f504b; }
.complaint-grid { margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 17px; }
.field > span, .filter-form label > span { color: #3f504b; font-size: 14px; font-weight: 700; }
.field input, .field textarea, .field select, .filter-form input, .filter-form select { width: 100%; border: 1px solid #cfd9d2; border-radius: 11px; background: #fff; color: var(--text); transition: border .15s, box-shadow .15s; }
.field input, .field select, .filter-form input, .filter-form select { height: 46px; padding: 0 13px; }
.field textarea { padding: 12px 13px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus, .filter-form input:focus, .filter-form select:focus { border-color: var(--jade); box-shadow: 0 0 0 3px rgba(47,118,95,.11); outline: none; }
.field-error input, .field-error textarea { border-color: var(--danger); }
.field small, .inline-error { color: var(--danger); font-weight: 700; }
.field-wide { width: 100%; }
.choice-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 24px; }
fieldset { padding: 0; border: 0; }
legend { margin-bottom: 9px; font-size: 14px; font-weight: 700; }
.choice { display: inline-flex; margin: 0 8px 8px 0; cursor: pointer; }
.choice input, .symptom-tag input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: block; min-width: 70px; padding: 8px 15px; text-align: center; border: 1px solid var(--line); border-radius: 10px; background: #fafcf9; }
.choice input:checked + span { color: white; border-color: var(--jade); background: var(--jade); }
.tag-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.symptom-tag { cursor: pointer; }
.symptom-tag span { display: block; padding: 9px 14px; border: 1px solid #d5ddd7; border-radius: 999px; background: #fbfcfa; color: #42534e; font-size: 14px; transition: .15s; }
.symptom-tag:hover span { border-color: #8eb3a5; }
.symptom-tag input:focus-visible + span { outline: 3px solid rgba(189,139,58,.35); }
.symptom-tag input:checked + span { border-color: #91bdab; background: var(--jade-light); color: var(--ink); font-weight: 700; }
.symptom-section .field-wide { margin-top: 22px; }
.question-card { padding: 0 0 22px; border: 0; border-bottom: 1px solid var(--line); }
.question-card:last-child { padding-bottom: 0; border-bottom: 0; }
.question-card legend { margin-bottom: 12px; color: var(--ink); font-size: 16px; }
.conditional-note { margin: 15px 0 0; }
.conditional-note[hidden] { display: none; }
.upload-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.upload-stack { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 22px; }
.upload-box { display: flex; min-height: 130px; padding: 20px; flex-direction: column; justify-content: center; border: 1px dashed #9ab7aa; border-radius: 14px; background: #f7fbf8; cursor: pointer; }
.upload-box strong { color: var(--ink); }
.upload-box span { margin: 4px 0 12px; color: var(--muted); font-size: 12px; }
.upload-box input { width: 100%; font-size: 12px; }
.image-preview-grid, .detail-images { display: grid; grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); gap: 12px; margin-top: 16px; }
.image-preview, .detail-images a { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.image-preview img, .detail-images img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.image-preview span, .detail-images span { display: block; overflow: hidden; padding: 7px 9px; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.submit-card { padding: 28px 34px; text-align: center; }
.consent { display: flex; align-items: flex-start; justify-content: center; gap: 10px; max-width: 760px; margin: 0 auto 20px; text-align: left; }
.consent input { margin-top: 6px; accent-color: var(--jade); }
.primary-button, .secondary-button, .danger-button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: 0 22px; border-radius: 11px; font-weight: 800; cursor: pointer; }
.primary-button { border: 1px solid var(--jade); background: var(--jade); color: white; }
.primary-button:hover { background: #286650; }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.danger-button { width: 100%; border: 1px solid #e6bcbc; background: #fff3f1; color: var(--danger); }
.button-link { text-decoration: none; }
.submit-card > .primary-button { min-width: 260px; }
.submit-note-row { max-width: 760px; margin: 12px auto 0; color: var(--muted); font-size: 13px; text-align: left; }
.result-query-link { margin-right: 12px; color: var(--jade); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.result-query-link:hover { text-decoration: underline; }
.site-footer { padding: 24px 0; color: #82908b; text-align: center; background: var(--ink-deep); font-size: 13px; }
.public-search-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: end; }
.public-search-form .field { margin: 0; }
.compact-header { padding: 42px 0 54px; }
.public-result-main { position: relative; margin-top: -28px; padding-bottom: 60px; }
.public-search-card { padding: 24px; }
.result-list-card h2 { margin: 0 0 16px; }
.result-list { display: grid; gap: 10px; }
.result-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfa; color: var(--text); }
.result-row:hover { border-color: #91bdab; background: #f2f8f4; }
.result-row span, .result-row small { display: block; }
.result-row small { color: var(--muted); }
.result-row time { color: var(--muted); white-space: nowrap; }
.public-detail-list { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.public-detail-list div { display: grid; grid-template-columns: 160px minmax(0,1fr); gap: 18px; padding: 12px 0; border-bottom: 1px solid #edf0ed; }
.public-detail-list dt { color: var(--muted); }
.public-detail-list dd { margin: 0; font-weight: 700; }
.answer-category + .answer-category { margin-top: 26px; }
.answer-category h3 { padding: 9px 12px; margin: 0; border-radius: 8px; background: #edf3ef; color: var(--ink); }
.answer-row { padding: 16px 12px; border-bottom: 1px solid #edf0ed; }
.answer-row > strong { display: block; margin-bottom: 8px; }
.answer-row p { margin: 8px 0 0; white-space: pre-wrap; }
.answer-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.answer-tags span { padding: 5px 9px; border-radius: 7px; background: var(--jade-light); color: var(--ink); font-size: 13px; }
.public-detail-actions { display: flex; justify-content: center; gap: 12px; }

.success-shell, .login-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: radial-gradient(circle at 70% 15%, #e0ece5, transparent 36%), var(--paper); }
.success-card, .login-card { width: min(520px,100%); padding: 46px; text-align: center; border: 1px solid rgba(47,118,95,.12); border-radius: 24px; background: var(--white); box-shadow: var(--shadow); }
.success-mark, .brand-seal { display: grid; width: 68px; height: 68px; place-items: center; margin: 0 auto 20px; border-radius: 50%; color: white; background: var(--jade); font-size: 32px; font-weight: 900; }
.success-card h1, .login-card h1 { margin: 0; color: var(--ink); font-family: SimSun, serif; font-size: 34px; }
.record-code { margin: 28px 0 14px; padding: 18px; border-radius: 14px; background: #eef5f0; }
.record-code span, .record-code strong { display: block; }
.record-code strong { margin-top: 5px; color: var(--ink); font-size: 23px; letter-spacing: .08em; }
.error-code { color: #b7c7c0; font-size: 52px; font-weight: 900; }
.login-card form { margin-top: 28px; text-align: left; }
.login-card .primary-button { width: 100%; margin: 4px 0 20px; }
.login-error { padding: 10px; margin-top: 18px; border-radius: 9px; background: #fff0ee; color: var(--danger); }

.admin-page { background: #f3f5f3; }
.admin-menu-toggle, .admin-sidebar-close, .admin-sidebar-backdrop { display: none; }
.admin-sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; display: flex; width: 230px; padding: 24px 18px; flex-direction: column; color: white; background: var(--ink-deep); }
.admin-sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.admin-brand { display: flex; align-items: center; gap: 11px; margin: 0 10px 34px; color: white; font-size: 18px; }
.admin-brand span { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--jade); }
.admin-sidebar nav { display: grid; gap: 7px; }
.admin-sidebar nav a, .text-button { padding: 11px 14px; border: 0; border-radius: 9px; background: transparent; color: #b9cbc5; text-align: left; }
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { background: rgba(255,255,255,.09); color: white; }
.admin-sidebar form { margin-top: auto; }
.text-button { width: 100%; cursor: pointer; }
.admin-main { min-width: 0; min-height: 100vh; padding: 34px 38px 60px; margin-left: 230px; overflow-x: hidden; }
.admin-topbar, .detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 25px; }
.admin-topbar h1, .detail-header h1 { margin: 0; color: var(--ink); font-size: 31px; }
.filter-toggle { display: none; }
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { position: relative; overflow: hidden; min-height: 126px; padding: 23px; border-radius: 16px; background: white; box-shadow: 0 8px 28px rgba(15,48,39,.06); }
.stat-card::after { content: ""; position: absolute; width: 74px; height: 74px; right: -20px; bottom: -20px; border-radius: 50%; opacity: .12; background: currentColor; }
.stat-card span, .stat-card strong { display: block; }
.stat-card span { color: var(--muted); }
.stat-card strong { margin-top: 10px; color: var(--ink); font-size: 33px; }
.stat-card.jade { color: var(--jade); }.stat-card.gold { color: var(--gold); }.stat-card.orange { color: var(--orange); }.stat-card.blue { color: var(--blue); }
.admin-panel, .detail-card { margin-bottom: 20px; padding: 24px; border: 1px solid #e4e9e5; border-radius: 16px; background: white; box-shadow: 0 8px 28px rgba(15,48,39,.04); }
.filter-form { display: grid; grid-template-columns: repeat(4,minmax(140px,1fr)); gap: 14px; align-items: end; }
.filter-form label { display: grid; gap: 6px; }
.filter-actions { display: flex; gap: 8px; }
.filter-actions .primary-button, .filter-actions .secondary-button { flex: 1; }
.panel-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-toolbar h2 { margin: 0; color: var(--ink); font-size: 20px; }
.panel-toolbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.export-links { display: flex; gap: 10px; }
.export-links a { padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; }
.record-table-wrap { overflow-x: auto; }
.record-table { width: 100%; border-collapse: collapse; }
.record-table th { padding: 11px 12px; color: #71807b; text-align: left; background: #f7f9f7; font-size: 12px; }
.record-table td { padding: 15px 12px; border-bottom: 1px solid #edf0ed; }
.record-table td:first-child span { display: block; color: var(--muted); font-size: 12px; }
.row-link { font-weight: 700; white-space: nowrap; }
.status { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-pending { background: #fff2e7; color: #a85831; }.status-contacted { background: #e8f1f6; color: #35677f; }.status-completed { background: #e5f2e9; color: #286a4d; }
.mobile-records { display: none; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); }
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }
.pagination a { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 8px; background: #f2f5f2; }
.pagination a.active { color: white; background: var(--jade); }
.detail-header p { margin: 3px 0 0; color: var(--muted); }
.detail-layout { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 20px; align-items: start; }
.detail-card h2 { margin: 0 0 20px; color: var(--ink); font-size: 20px; }
.detail-card h3 { font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; margin: 0; }
.detail-grid div { padding-bottom: 12px; border-bottom: 1px solid #edf0ed; }
.detail-grid .wide { grid-column: span 2; }
.detail-grid dt { color: var(--muted); font-size: 12px; }
.detail-grid dd { margin: 4px 0 0; font-weight: 700; }
.sensitive-value { color: #9e532f; }
.chief-list { padding-left: 22px; }
.detail-text { margin-top: 18px; }
.detail-text p { margin: 5px 0 0; white-space: pre-wrap; }
.symptom-detail { display: grid; grid-template-columns: 110px 1fr; gap: 15px; padding: 13px 0; border-bottom: 1px solid #edf0ed; }
.symptom-detail div { display: flex; flex-wrap: wrap; gap: 6px; }
.symptom-detail span { padding: 4px 8px; border-radius: 7px; background: #edf5f0; font-size: 13px; }
.sticky-card { position: sticky; top: 20px; }
.sticky-card hr { margin: 22px 0; border: 0; border-top: 1px solid var(--line); }
.clinic-alert { margin: 0 0 18px; padding: 13px 16px; border-radius: 10px; font-weight: 700; }
.clinic-alert-error { border: 1px solid #e7b2ad; color: #9d2f28; background: #fff1ef; }
.clinic-inline-form, .clinic-filter, .rx-summary { display: grid; grid-template-columns: repeat(4,minmax(140px,1fr)) auto; gap: 12px; align-items: end; }
.clinic-inline-form label, .rx-summary label, .threshold-form label { display: grid; gap: 7px; font-weight: 700; }
.clinic-inline-form input, .clinic-inline-form select, .clinic-filter input, .clinic-filter select, .rx-summary input, .rx-row input, .rx-row select, .threshold-form input { min-height: 44px; padding: 8px 11px; border: 1px solid #cfdad5; border-radius: 9px; background: white; }
.threshold-form, .import-form, .clinic-actions, .rx-finance { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.clinic-filter { margin: 18px 0; grid-template-columns: minmax(220px,1fr) 180px auto auto; }
.medicine-category { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.category-decoction { color: #1f6955; background: #dceee7; }.category-herb { color: #7b5420; background: #f8e9c9; }
.medicine-danger { background: #fff0ee; }.medicine-low { background: #fff9e9; }.danger-text { color: #bf3028; font-weight: 800; }.warning-text { color: #a16b0c; font-weight: 800; }
.rx-list { display: grid; gap: 8px; margin-top: 14px; }.rx-list-item { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #dce5e1; border-radius: 9px; }.rx-list-item > a { display: grid; gap: 3px; }.rx-list span { color: var(--muted); font-size: 12px; }.rx-delete-link { border: 0; color: #b33730; background: transparent; font-weight: 800; cursor: pointer; }
.rx-summary { grid-template-columns: minmax(0,2fr) minmax(90px,.55fr) minmax(120px,.75fr); margin-bottom: 18px; }
.rx-summary input { width: 100%; min-width: 0; }
.rx-instructions { grid-column: 1 / -1; }
.rx-items { display: grid; gap: 10px; margin-bottom: 12px; }
.prescription-editor, .rx-items, .rx-row, .rx-row > * { min-width: 0; }
.rx-row { display: grid; grid-template-columns: minmax(150px,.7fr) minmax(280px,2fr) minmax(110px,.55fr) auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid #dfe7e3; border-left-width: 5px; border-radius: 12px; transition: background-color .16s ease,border-color .16s ease; }
.medicine-picker { position: relative; min-width: 0; }
.medicine-picker [data-medicine-search] { width: 100%; }
.medicine-search-results { position: absolute; z-index: 30; top: calc(100% + 5px); right: 0; left: 0; max-height: 280px; overflow-y: auto; padding: 6px; border: 1px solid #cddbd5; border-radius: 10px; background: white; box-shadow: 0 14px 32px rgba(20,55,44,.16); }
.medicine-search-option { display: flex; width: 100%; justify-content: space-between; gap: 12px; padding: 10px 11px; border: 0; border-radius: 7px; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.medicine-search-option:hover, .medicine-search-option:focus { background: #edf6f2; outline: none; }
.medicine-search-option small { color: var(--muted); white-space: nowrap; }
.medicine-search-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.rx-row.rx-type-decoction { border-color: #a8d1c4; border-left-color: #2f7d68; background: #f1f8f5; }
.rx-row.rx-type-herb { border-color: #e5c78d; border-left-color: #c58a2b; background: #fff8e9; }
.rx-row.rx-type-external { border-color: #e7b5b0; border-left-color: #bf3e34; background: #fff5f3; }
.rx-row.rx-type-decoction [data-category-select] { color: #1f6955; border-color: #8dc2b1; background: #deeee8; font-weight: 800; }
.rx-row.rx-type-herb [data-category-select] { color: #835916; border-color: #d9b66f; background: #f9e7bd; font-weight: 800; }
.rx-remove { min-height: 40px; border: 0; color: #a52f29; background: transparent; cursor: pointer; }
.rx-lifecycle-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 18px; padding-top: 18px; border-top: 1px solid #e4e9e5; }
.rx-lifecycle-actions .danger-button { width: auto; }
.rx-confirm-actions { align-items: stretch; }
.self-dispense-button, .pharmacy-copy-button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: 0 20px; border-radius: 11px; font-weight: 800; cursor: pointer; }
.self-dispense-button { border: 1px solid #b88936; color: #765017; background: #fff5df; }
.pharmacy-copy-button { border: 1px solid #2f765f; color: white; background: #2f765f; }
.self-dispense-status { color: #94631b; }
.copy-pharmacy-status { align-self: center; color: var(--jade); font-size: 13px; font-weight: 800; }
.rx-finance { margin: 18px 0; padding: 14px; border-radius: 10px; background: #f1f7f4; font-weight: 800; }
.prescription-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.rx-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.rx-badge-confirmed { color: #1e684f; background: #ddefe7; }.rx-badge-draft { color: #8a5d15; background: #fae9c6; }
.record-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.follow-up-button { min-height: 32px; padding: 0 11px; border: 1px solid #85bbaa; border-radius: 8px; color: #236a55; background: #f0f8f5; font-weight: 800; cursor: pointer; }
.follow-up-button:hover { color: white; background: #2f7d68; }
.visit-group-list { display: grid; gap: 12px; margin-top: 16px; }
.visit-group { overflow: hidden; border: 1px solid #d8e6e0; border-radius: 13px; background: #fff; }
.visit-group > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; background: #f2f8f5; cursor: pointer; list-style: none; }
.visit-group > summary::-webkit-details-marker { display: none; }
.visit-group > summary span:first-child { display: grid; gap: 3px; min-width: 0; }
.visit-group > summary strong { color: #0d483a; font-size: 18px; }
.visit-group > summary small { color: var(--muted); font-size: 12px; }
.visit-summary-meta { flex: none; color: #477064; font-size: 13px; font-weight: 800; }
.visit-group-body { display: grid; gap: 12px; padding: 12px; }
.visit-group-body .rx-list { margin: 0; }
.visit-rx-actions { display: flex; align-items: center; gap: 9px; flex: none; }
.visit-rx-actions > a { color: #8b5d10; font-size: 13px; font-weight: 800; text-decoration: none; }
.visit-medicine-summary { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.visit-medicine-chip { display: inline-flex; min-height: 24px; align-items: center; padding: 3px 7px; border-radius: 999px; color: #276653; background: #e8f3ef; font-size: 12px; line-height: 1.2; }
.visit-medicine-chip.medicine-herb { color: #815812; background: #fff0cf; }
.visit-medicine-chip.medicine-external { color: #a43b32; background: #fff0ed; }
.record-row-actions .follow-up-button, .mobile-rx-actions .follow-up-button { display: inline-flex; align-items: center; text-decoration: none; }
.case-export-link { color: #9a6818; font-weight: 800; white-space: nowrap; }
.mobile-rx-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.record-row-actions form, .mobile-rx-actions form { margin: 0; }
.record-delete-button { padding: 0; border: 0; color: var(--danger); background: transparent; font: inherit; font-weight: 800; cursor: pointer; white-space: nowrap; }
.record-delete-button:hover { text-decoration: underline; }
.doctor-settings-form { display: grid; max-width: 620px; gap: 14px; }
.doctor-settings-form label { display: grid; gap: 8px; font-weight: 800; }
.doctor-settings-form input { min-height: 48px; padding: 10px 13px; border: 1px solid #cfdad5; border-radius: 10px; }
.doctor-settings-form p { margin: 0; color: var(--muted); }
.doctor-settings-form .primary-button { justify-self: start; }
.follow-up-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.follow-up-card { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.follow-up-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.follow-up-card-head h2, .follow-up-card-head p { margin: 0; }
.follow-up-card-head p { margin-top: 5px; color: var(--muted); }
.follow-up-visit-label { display: inline-flex; margin-bottom: 7px; padding: 4px 9px; border-radius: 999px; color: #1f6955; background: #e1f0ea; font-size: 12px; font-weight: 900; }
.follow-up-medicines { display: flex; flex-wrap: wrap; gap: 8px; }
.medicine-chip { padding: 7px 10px; border-radius: 999px; font-weight: 750; }
.medicine-chip-decoction { color: #236a55; background: #e5f2ed; }
.medicine-chip-herb { color: #8b5d10; background: #fff0cf; }
.follow-up-instructions { margin: 0; padding-top: 12px; border-top: 1px solid #e3e9e6; }
.follow-up-card form { margin-top: auto; }
.prescription-entry-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.prescription-entry-actions a { display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.follow-up-pulse { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px 18px; align-items: end; }
.follow-up-pulse label { display: grid; grid-column: 1 / -1; gap: 8px; font-weight: 800; }
.follow-up-pulse textarea[name="pulse_description"] { width: 100%; min-height: 108px; padding: 13px 14px; border: 1px solid #9bc8ba; border-radius: 11px; background: #fbfefd; font: inherit; font-size: 17px; line-height: 1.65; resize: vertical; }
.followup-note-form { display: grid; gap: 12px; }
.followup-note-form label { display: grid; gap: 8px; font-weight: 800; }
.followup-note-form textarea { width: 100%; min-height: 120px; padding: 13px 14px; border: 1px solid #9bc8ba; border-radius: 11px; background: #fbfefd; font: inherit; font-size: 17px; line-height: 1.65; resize: vertical; }
.followup-note-form .secondary-button { justify-self: start; }
.followup-note-list { display: grid; gap: 12px; }
.followup-note-list article { padding: 12px; border: 1px solid #dce7e2; border-radius: 10px; background: #f7fbf9; }
.followup-note-list time { color: var(--muted); font-size: 12px; }
.followup-note-list p { margin: 6px 0 0; white-space: pre-wrap; }
.follow-up-card-actions { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.follow-up-card-actions form { margin: 0; }
.inventory-search-field { position: relative; min-width: 0; }
.inventory-search-results { position: absolute; z-index: 40; top: calc(100% + 5px); right: 0; left: 0; display: block; max-height: 280px; overflow-y: auto; padding: 6px; border: 1px solid #cddbd5; border-radius: 10px; background: white; box-shadow: 0 14px 32px rgba(20,55,44,.16); }
.inventory-search-results[hidden] { display: none; }
.inventory-search-option { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 0; border-radius: 7px; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.inventory-search-option:hover { background: #edf6f2; }
.inventory-search-option small { color: var(--muted); white-space: nowrap; }
.inventory-header-actions { flex-wrap: wrap; min-width: 0; justify-content: flex-end; }
.inventory-header-actions a { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 8px 14px; font-weight: 800; white-space: nowrap; }
.medicine-editor-panel { padding: 0; overflow: visible; }
.medicine-editor-section { padding: 24px; }
.medicine-editor-section + .medicine-editor-section { border-top: 1px solid var(--line); }
.medicine-editor-heading { margin-bottom: 18px; }
.medicine-editor-heading h2, .medicine-editor-heading p { margin: 0; }
.medicine-editor-heading p { margin-top: 5px; }
.medicine-editor-form { grid-template-columns: repeat(4,minmax(0,1fr)); }
.medicine-editor-form > *, .medicine-editor-form input, .medicine-editor-form select { min-width: 0; }
.medicine-editor-form input, .medicine-editor-form select { width: 100%; }
.medicine-editor-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; min-width: 0; }
.medicine-editor-actions .primary-button { min-height: 44px; max-width: 100%; padding-inline: 24px; white-space: nowrap; }
.medicine-table th:last-child, .medicine-table td:last-child { width: 92px; text-align: right; white-space: nowrap; }
.medicine-delete-button { min-height: 34px; padding: 0 12px; border: 1px solid #e6bcbc; border-radius: 8px; color: var(--danger); background: #fff3f1; font-weight: 800; cursor: pointer; }
.medicine-delete-button:hover { background: #ffe7e3; }
.pulse-save-status { align-self: center; color: var(--muted); font-size: 13px; }
.follow-up-pulse .primary-button { display: inline-flex; align-items: center; justify-content: center; }
.follow-up-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 28px 0 14px; }
.follow-up-section-heading h2, .follow-up-section-heading p { margin: 0; }
.follow-up-section-heading p { margin-top: 5px; color: var(--muted); }
.follow-up-section-heading > span { color: #8b5d10; font-weight: 800; }

/* Public consultation result: compact doctor overview. */
.public-result-header { padding: 30px 0 44px; }
.public-result-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.public-result-heading h1 { margin-bottom: 0; }
.public-result-meta { display: flex; align-items: flex-end; gap: 3px; margin: 0; flex-direction: column; color: rgba(255,255,255,.8); font-size: 13px; }
.public-result-card { padding: 20px; margin-bottom: 12px; }
.public-result-card h2 { margin-bottom: 12px; font-size: 18px; }
.public-fact-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; margin: 0; }
.public-fact-grid > div { min-width: 0; padding: 8px 10px; border-radius: 8px; background: #f2f6f3; }
.public-fact-grid dt { color: var(--muted); font-size: 11px; }
.public-fact-grid dd { overflow-wrap: anywhere; margin: 2px 0 0; color: var(--ink); font-weight: 800; }
.public-fact-grid .public-fact-occupation { grid-column: span 2; }
.public-complaint-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 14px; }
.public-detail-line { min-width: 0; padding: 6px 0; border-bottom: 1px solid #edf0ed; }
.public-detail-line-wide { grid-column: 1 / -1; }
.public-detail-line strong { color: var(--muted); font-size: 12px; }
.public-detail-line p { overflow-wrap: anywhere; margin: 2px 0 0; white-space: pre-wrap; }
.public-image-thumbnails { display: flex; flex-wrap: wrap; gap: 6px; }
.public-image-thumbnails a { display: block; overflow: hidden; width: 58px; height: 58px; border: 1px solid var(--line); border-radius: 7px; background: #eef3ef; }
.public-image-thumbnails img { display: block; width: 100%; height: 100%; object-fit: cover; }
.public-result-main .answer-category + .answer-category { margin-top: 14px; }
.public-result-main .answer-row { padding: 9px 8px; }
.public-result-main .answer-row > strong { margin-bottom: 5px; }
.public-result-main .answer-tags { margin-top: 5px; }

/* Public pharmacy picking list: designed for one-handed mobile use. */
.pharmacy-page { min-width: 0; background: #eef3f0; }
.pharmacy-shell { width: min(760px,calc(100% - 24px)); margin: 0 auto; padding: 24px 0 40px; }
.pharmacy-hero { padding: 24px; border-radius: 18px; color: white; background: linear-gradient(135deg,var(--ink-deep),var(--jade)); box-shadow: var(--shadow); }
.pharmacy-hero h1 { overflow-wrap: anywhere; margin: 3px 0; font-size: clamp(24px,5vw,34px); }
.pharmacy-hero > p:last-child { margin: 0; color: rgba(255,255,255,.75); }
.pharmacy-card { padding: 20px; margin-top: 14px; border: 1px solid #dce5e0; border-radius: 16px; background: white; box-shadow: 0 8px 28px rgba(15,48,39,.05); }
.pharmacy-facts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.pharmacy-facts > div { min-width: 0; padding: 10px 12px; border-radius: 10px; background: #f3f7f5; }
.pharmacy-facts .wide { grid-column: 1 / -1; }
.pharmacy-facts span, .pharmacy-facts strong { display: block; }
.pharmacy-facts span { color: var(--muted); font-size: 12px; }
.pharmacy-facts strong { overflow-wrap: anywhere; color: var(--ink); }
.pharmacy-list-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.pharmacy-list-heading h2, .pharmacy-list-heading p { margin: 0; }
.pharmacy-list-heading p { color: var(--muted); font-size: 13px; }
.pharmacy-list-heading > strong { flex: 0 0 auto; color: var(--jade); }
.pharmacy-items { display: grid; gap: 10px; }
.pharmacy-item { display: grid; grid-template-columns: 36px minmax(110px,1.2fr) minmax(105px,.8fr) minmax(135px,1fr) auto; gap: 10px; width: 100%; min-width: 0; align-items: center; padding: 14px; border: 1px solid #ccd9d3; border-radius: 13px; color: var(--text); background: #fbfdfc; text-align: left; cursor: pointer; transition: .15s ease; }
.pharmacy-item:active { transform: scale(.995); }
.pharmacy-checkmark { display: grid; width: 30px; height: 30px; place-items: center; border: 2px solid #aabbb4; border-radius: 50%; color: transparent; font-weight: 900; }
.pharmacy-medicine strong, .pharmacy-medicine small { display: block; }
.pharmacy-medicine strong { color: var(--ink); font-size: 17px; }
.pharmacy-medicine small { color: var(--muted); }
.pharmacy-dose, .pharmacy-total { color: var(--muted); }
.pharmacy-state { justify-self: end; color: #9a6818; font-weight: 800; }
.pharmacy-item.is-checked { border-color: #18201e; color: white; background: #202725; }
.pharmacy-item.is-checked .pharmacy-checkmark { border-color: white; color: #202725; background: white; }
.pharmacy-item.is-checked .pharmacy-medicine strong, .pharmacy-item.is-checked .pharmacy-medicine small, .pharmacy-item.is-checked .pharmacy-dose, .pharmacy-item.is-checked .pharmacy-total, .pharmacy-item.is-checked .pharmacy-state { color: white; }
.pharmacy-footnote { color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .filter-form { grid-template-columns: repeat(2,1fr); }
  .detail-layout { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .follow-up-grid { grid-template-columns: 1fr; }
  .medicine-editor-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .clinic-admin-page .admin-topbar { align-items: flex-start; flex-wrap: wrap; }
  .inventory-header-actions { width: 100%; justify-content: flex-start; }
}

@media (max-width: 720px) {
  .visit-group > summary { align-items: flex-start; padding: 12px; }
  .visit-summary-meta { white-space: nowrap; }
  .visit-group-body { padding: 10px; }
  .visit-group-body .rx-list-item { align-items: flex-start; gap: 9px; }
  .visit-group-body .rx-list-item > a { min-width: 0; overflow-wrap: anywhere; }
  .visit-rx-actions { align-items: flex-end; flex-direction: column; }
  .clinic-inline-form, .clinic-filter, .rx-summary, .rx-row { grid-template-columns: 1fr; }
  .rx-instructions { grid-column: auto; }
  .prescription-entry-actions, .follow-up-pulse { grid-template-columns: 1fr; }
  .follow-up-pulse label { grid-column: auto; }
  .follow-up-pulse .primary-button { width: 100%; }
  .rx-row.has-known-medicine { grid-template-columns: 1fr 1fr; }
  .rx-row.has-known-medicine [data-medicine-select] { grid-column: 1 / -1; }
  .rx-row.has-known-medicine .rx-remove { width: 100%; }
  .container { width: min(100% - 22px, 1120px); }
  .site-header { padding: 38px 0 56px; }
  .header-inner { align-items: stretch; flex-direction: column; gap: 22px; }
  .progress-card { width: 100%; }
  .form-section, .submit-card { padding: 22px 17px; border-radius: 16px; }
  .notice-card { padding: 20px; }
  .section-heading { gap: 12px; }
  .section-heading > span { flex-basis: 36px; height: 36px; }
  .section-heading h2 { font-size: 20px; }
  .field-grid, .complaint-grid, .choice-row, .upload-grid { grid-template-columns: 1fr; gap: 0; }
  .complaint-pair-grid, .history-pair-grid { grid-template-columns: 1fr; }
  .upload-grid { gap: 12px; }
  .tag-grid { gap: 8px; }
  .symptom-tag span { padding: 8px 11px; font-size: 13px; }
  .success-card, .login-card { padding: 34px 22px; }
  .admin-page { width: 100%; max-width: 100%; overflow-x: hidden; }
  .admin-menu-toggle { position: fixed; z-index: 50; top: 12px; left: 12px; display: grid; width: 46px; height: 46px; place-items: center; padding: 0; border: 1px solid rgba(47,118,95,.22); border-radius: 12px; color: white; background: var(--jade); box-shadow: 0 8px 24px rgba(13,42,36,.18); font-size: 23px; line-height: 1; cursor: pointer; }
  .admin-sidebar-backdrop { position: fixed; z-index: 55; inset: 0; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(8,28,23,.52); backdrop-filter: blur(2px); }
  .admin-sidebar-backdrop[hidden] { display: none; }
  .admin-sidebar { position: fixed; z-index: 60; inset: 0 auto 0 0; width: min(82vw,300px); height: 100dvh; padding: 18px 16px; align-items: stretch; flex-direction: column; transform: translateX(-100%); box-shadow: 16px 0 38px rgba(7,26,21,.28); transition: transform .22s ease; visibility: hidden; }
  .admin-page.sidebar-open { overflow: hidden; }
  .admin-page.sidebar-open .admin-sidebar { transform: translateX(0); visibility: visible; }
  .admin-sidebar-head { gap: 10px; }
  .admin-brand { margin: 0; }
  .admin-sidebar-close { display: grid; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.18); border-radius: 10px; color: white; background: rgba(255,255,255,.08); font-size: 30px; line-height: 1; cursor: pointer; }
  .admin-sidebar nav { display: grid; margin-top: 28px; }
  .admin-sidebar nav a, .admin-sidebar .text-button { min-height: 48px; display: flex; align-items: center; }
  .admin-sidebar form { margin-top: auto; }
  .admin-main { width: 100%; max-width: 100%; padding: 74px 10px 38px; margin-left: 0; overflow-x: hidden; }
  .admin-main > * { min-width: 0; max-width: 100%; }
  .admin-panel, .detail-card { padding: 16px; border-radius: 13px; }
  .admin-topbar h1, .detail-header h1 { font-size: 25px; }
  .filter-toggle { display: block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 105px; padding: 17px; }
  .stat-card strong { font-size: 27px; }
  .filter-panel { display: none; }
  .filter-panel.is-open { display: block; }
  .filter-form { grid-template-columns: 1fr; }
  .record-table-wrap { display: none; }
  .clinic-admin-page .record-table-wrap { display: block; max-width: 100%; overflow-x: auto; }
  .mobile-records { display: grid; gap: 10px; }
  .mobile-record-card { padding: 15px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); }
  .mobile-record-card > a { display: block; color: var(--text); }
  .mobile-record-card > a > div { display: flex; justify-content: space-between; gap: 10px; }
  .mobile-record-card > div { display: flex; justify-content: space-between; }
  .mobile-record-card > .prescription-badges { justify-content: flex-start; }
  .mobile-record-card > form { margin-top: 10px; }
  .mobile-record-card p { margin: 7px 0; }
  .mobile-record-card small { color: var(--muted); }
  .panel-toolbar { align-items: flex-start; gap: 12px; flex-direction: column; }
  .export-links, .inventory-header-actions, .clinic-actions, .follow-up-card-actions { width: 100%; flex-wrap: wrap; }
  .export-links a, .inventory-header-actions a { flex: 1 1 auto; text-align: center; }
  .detail-header { align-items: flex-start; gap: 12px; flex-direction: column; }
  .detail-grid { grid-template-columns: repeat(2,1fr); }
  .detail-grid .wide { grid-column: span 2; }
  .symptom-detail { grid-template-columns: 1fr; gap: 7px; }
  .public-search-form { grid-template-columns: 1fr; }
  .result-row { align-items: flex-start; flex-direction: column; }
  .result-row time { white-space: normal; }
  .public-detail-list div { grid-template-columns: 1fr; gap: 3px; }
  .public-detail-actions { align-items: stretch; flex-direction: column; }
  .public-result-header { padding: 14px 0 34px; }
  .public-result-header .container, .public-result-main { width: calc(100% - 12px); }
  .public-result-heading { align-items: flex-start; gap: 4px; flex-direction: column; }
  .public-result-heading .eyebrow { display: none; }
  .public-result-heading h1 { font-size: 21px; }
  .public-result-meta { align-items: flex-start; gap: 0 10px; flex-flow: row wrap; font-size: 10px; }
  .public-result-main { margin-top: -22px; padding-bottom: 24px; }
  .public-result-card { padding: 9px; margin-bottom: 6px; border-radius: 9px; box-shadow: none; }
  .public-result-card h2 { margin-bottom: 6px; font-size: 14px; }
  .public-fact-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; }
  .public-fact-grid > div { padding: 4px 5px; border-radius: 5px; }
  .public-fact-grid dt { font-size: 9px; }
  .public-fact-grid dd { margin-top: 0; font-size: 11px; line-height: 1.25; }
  .public-fact-grid .public-fact-occupation { grid-column: span 2; }
  .public-complaint-grid { gap: 2px 8px; }
  .public-detail-line { padding: 3px 0; font-size: 11px; line-height: 1.35; }
  .public-detail-line strong { font-size: 10px; }
  .public-detail-line p { display: inline; margin-left: 3px; }
  .public-detail-line .answer-tags { display: inline-flex; margin-left: 4px; vertical-align: middle; }
  .public-result-main .answer-category + .answer-category { margin-top: 7px; }
  .public-result-main .answer-category h3 { padding: 4px 6px; border-radius: 5px; font-size: 11px; }
  .public-result-main .answer-row { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 3px 6px; padding: 4px 5px; font-size: 10px; }
  .public-result-main .answer-row > strong { margin: 1px 0 0; font-size: 10px; }
  .public-result-main .answer-tags { gap: 3px; margin: 0; }
  .public-result-main .answer-tags span { padding: 2px 5px; border-radius: 5px; font-size: 10px; }
  .public-result-main .answer-row p { flex-basis: 100%; margin: 1px 0 0; }
  .public-result-main .symptom-detail { gap: 3px; padding: 4px 0; font-size: 10px; }
  .public-result-main .symptom-detail div { gap: 3px; }
  .public-result-main .symptom-detail span { padding: 2px 5px; font-size: 10px; }
  .public-image-thumbnails a { width: 44px; height: 44px; }
  .public-detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .public-detail-actions .button-link { min-height: 34px; padding: 0 8px; border-radius: 7px; font-size: 11px; }
  .rx-confirm-actions > * { width: 100%; }
  .pharmacy-shell { width: calc(100% - 12px); padding: 6px 0 24px; }
  .pharmacy-hero, .pharmacy-card { padding: 14px; border-radius: 13px; }
  .pharmacy-hero h1 { font-size: 23px; }
  .pharmacy-facts { gap: 7px; }
  .pharmacy-facts > div { padding: 8px; }
  .pharmacy-list-heading { flex-direction: column; gap: 4px; }
  .pharmacy-item { grid-template-columns: 34px minmax(0,1fr) auto; gap: 6px 9px; min-height: 112px; padding: 12px 10px; }
  .pharmacy-checkmark { grid-row: 1 / 3; }
  .pharmacy-dose { grid-column: 2; }
  .pharmacy-total { grid-column: 2; }
  .pharmacy-state { grid-column: 3; grid-row: 1 / 4; }
}
