:root {
  --canvas: #f3f0e8;
  --surface: #fffdf8;
  --surface-muted: #ece8de;
  --ink: #172625;
  --muted: #68716e;
  --line: #d7d3c7;
  --teal: #1e5a56;
  --teal-dark: #154541;
  --rust: #b95832;
  --danger: #a33f31;
  --success: #2d6b4c;
  --radius: 7px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); font: 14px/1.5 "Noto Sans CJK SC", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }

.site-header { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(20px, calc((100% - 1440px) / 2)); color: #fff; background: var(--teal-dark); }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; font: 18px "STSong", serif; }
.brand strong { display: block; font: 600 18px "STSong", "Songti SC", serif; letter-spacing: .08em; }
.brand small, .source-note { display: block; color: rgba(255,255,255,.7); font-size: 11px; }

main { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 14px 0 28px; }
.query-bar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 12px; border: 1px solid var(--line); background: var(--surface); }
.search-form { flex: 1; display: flex; align-items: center; gap: 8px; max-width: 760px; }
.search-form > label { flex: none; font-weight: 700; }
.search-input-wrap { flex: 1; min-width: 180px; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.search-input-wrap:focus-within { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(30,90,86,.1); }
.search-input-wrap svg { width: 17px; fill: none; stroke: var(--teal); stroke-width: 1.8; }
.search-input-wrap input { width: 100%; border: 0; outline: 0; background: transparent; }
.primary-button, .export-button { height: 36px; padding: 0 18px; border: 0; border-radius: var(--radius); color: #fff; background: var(--teal); font-weight: 700; }
.primary-button:hover, .export-button:hover { background: var(--teal-dark); }
.primary-button:disabled, .export-button:disabled { opacity: .55; cursor: wait; }
.quick-search { display: flex; gap: 6px; }
.quick-search button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: transparent; font-size: 12px; }

.status-region:not(:empty) { margin-top: 10px; padding: 9px 12px; border-left: 3px solid var(--teal); background: var(--surface); }
.status-region.error { border-color: var(--danger); color: var(--danger); }
.status-region.loading::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border: 2px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.results { margin-top: 10px; }
.report-summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 12px; border: 1px solid var(--line); background: var(--surface); }
.summary-main, .summary-actions { display: flex; align-items: center; gap: 14px; }
.summary-main > strong { padding-right: 14px; border-right: 1px solid var(--line); }
.summary-main span { color: var(--muted); white-space: nowrap; }
.summary-main b { color: var(--teal); font: 600 16px Georgia, serif; }
.hydration-status { font-size: 12px; }
.failure-count { padding: 3px 7px; border: 1px solid #dfb4ab; border-radius: 4px; color: var(--danger); background: #fff7f5; }
.failure-count b { color: inherit; }
.text-button { padding: 4px 7px; border: 0; color: var(--teal); background: transparent; font-size: 12px; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--danger); }
.export-button { height: 32px; padding: 0 13px; }

.filter-bar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-top: 0; background: #faf8f2; overflow-x: auto; }
.filter-tabs { display: flex; flex: none; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.filter-tabs button { padding: 5px 9px; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: #fff; font-size: 12px; white-space: nowrap; }
.filter-tabs button:last-child { border-right: 0; }
.filter-tabs button.active { color: #fff; background: var(--teal); }
.filter-bar label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.filter-bar input { width: 118px; height: 28px; padding: 0 7px; border: 1px solid var(--line); border-radius: 4px; background: #fff; outline: 0; }
.filter-bar input:focus { border-color: var(--teal); }
.filter-note { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }

.export-panel { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(180px, 420px) auto; align-items: center; gap: 14px; margin-top: 8px; padding: 9px 12px; border: 1px solid #b9cfc9; background: #eef6f3; font-size: 12px; }
.export-panel strong { margin-right: 10px; }
.export-panel span { color: var(--muted); }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: #d6e3df; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--teal); transition: width .2s; }
.download-link { padding: 5px 10px; border-radius: 4px; color: #fff; background: var(--teal); text-decoration: none; font-weight: 700; }

.table-wrap { margin-top: 8px; border: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
.report-table { width: 100%; min-width: 1040px; border-collapse: collapse; table-layout: fixed; }
.report-table th { height: 34px; padding: 0 9px; border-bottom: 1px solid var(--line); color: #fff; background: var(--teal-dark); text-align: left; font-size: 12px; font-weight: 600; }
.report-table td { padding: 7px 9px; border-bottom: 1px solid #e3dfd5; vertical-align: top; font-size: 12px; overflow-wrap: anywhere; }
.report-table tbody tr:hover:not(.hospital-detail) { background: #f8f5ed; }
.report-table th:nth-child(1), .report-table td:nth-child(1) { width: 52px; text-align: center; color: var(--muted); }
.report-table th:nth-child(2) { width: 225px; }
.report-table th:nth-child(3) { width: 210px; }
.report-table th:nth-child(4) { width: 240px; }
.report-table th:nth-child(5) { width: 230px; }
.report-table th:nth-child(6) { width: 150px; }
.cell-primary { display: block; color: var(--ink); font-size: 13px; font-weight: 700; }
.cell-secondary { display: block; margin-top: 2px; color: var(--muted); line-height: 1.4; }
.generic-link { padding: 0; border: 0; color: var(--teal); background: transparent; font-weight: 700; }
.catalog-code { color: var(--rust); font: 600 10px Georgia, serif; }
.purchase-state { display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px; border-radius: 4px; font-weight: 700; }
.purchase-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #999; }
.purchase-state.purchased { color: var(--success); background: #e9f3ee; }
.purchase-state.purchased::before { background: var(--success); }
.purchase-state.none { color: var(--muted); background: #efeee9; }
.purchase-state.error { color: var(--danger); background: #fff0ed; }
.purchase-state.loading { color: var(--muted); }
.row-action { display: block; margin-top: 4px; padding: 0; border: 0; color: var(--teal); background: transparent; font-size: 11px; }
.row-action.danger { color: var(--danger); }
.integrity-warning { display: block; width: max-content; margin-top: 4px; padding: 1px 5px; border: 1px solid #e5c982; border-radius: 3px; color: #765313; background: #fff8df; font-size: 10px; line-height: 16px; }
.integrity-note { padding: 7px 12px; border-bottom: 1px solid #ead9a9; color: #765313; background: #fff8df; font-size: 11px; }
.hospital-detail td { padding: 0; background: #f7f5ef; }
.hospital-scroll { max-height: min(340px, 45vh); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.hospital-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 0; padding: 6px 52px; }
.hospital-item { display: flex; justify-content: space-between; gap: 10px; padding: 5px 9px; border-bottom: 1px dashed var(--line); }
.hospital-item span { color: var(--muted); white-space: nowrap; }
.empty-filter { padding: 34px; text-align: center; color: var(--muted); }

.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; }
.pagination button { height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--surface); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination span { color: var(--muted); font-size: 12px; }
footer { width: min(1440px, calc(100% - 32px)); margin: 0 auto; padding: 16px 0 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

@media (max-width: 800px) {
  main { width: calc(100% - 20px); padding-top: 10px; }
  .source-note, .quick-search, .filter-note { display: none; }
  .query-bar { align-items: stretch; }
  .search-form > label { display: none; }
  .report-summary { align-items: flex-start; flex-direction: column; }
  .summary-main { width: 100%; flex-wrap: wrap; gap: 8px 12px; }
  .summary-actions { width: 100%; justify-content: flex-end; }
  .filter-bar { align-items: flex-start; flex-wrap: wrap; overflow: visible; }
  .filter-bar label { flex: 1 1 150px; }
  .filter-bar input { width: 100%; }
  .export-panel { grid-template-columns: 1fr; }
  .hospital-scroll { max-height: 50vh; }
  .hospital-grid { grid-template-columns: 1fr; padding: 6px 12px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
