:root {
  --navy: #183153;
  --navy-deep: #10243d;
  --ink: #162b3c;
  --muted: #627788;
  --line: #d9e2e7;
  --mist: #f3f7f8;
  --paper: #ffffff;
  --teal: #13a89e;
  --teal-dark: #087e78;
  --teal-soft: #e5f5f3;
  --amber: #c87818;
  --amber-soft: #fff3df;
  --red: #b23a3a;
  --red-soft: #fff0ef;
  --shadow: 0 16px 36px rgba(24, 49, 83, .08);
  --radius: 16px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--mist); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid rgba(19, 168, 158, .55); outline-offset: 3px; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 20; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 0 0 8px 8px; text-decoration: none; }
.skip-link:focus { top: 0; }
.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; }

.site-header { background: var(--navy); color: #fff; }
.header-inner, .page-shell, .footer-inner { max-width: 1220px; margin: 0 auto; padding-left: 28px; padding-right: 28px; }
.header-inner { height: 78px; display: flex; align-items: center; justify-content: space-between; }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 37px; height: 37px; display: flex; align-items: center; gap: 3px; padding: 7px; border: 1px solid rgba(255,255,255,.28); border-radius: 11px; }
.brand-mark span { display: block; width: 5px; border-radius: 4px; background: var(--teal); }
.brand-mark span:nth-child(1) { height: 10px; opacity: .75; }
.brand-mark span:nth-child(2) { height: 20px; }
.brand-mark span:nth-child(3) { height: 14px; opacity: .85; }
.eyebrow, .section-kicker { margin: 0; font-size: 10px; font-weight: 800; letter-spacing: .17em; line-height: 1.4; }
.site-header .eyebrow { color: #9bb4c6; margin-bottom: 1px; }
.brand-lockup h1 { margin: 0; font-size: 17px; letter-spacing: .06em; font-weight: 800; }
.header-note { color: #c8d6e0; font-size: 12px; display: flex; align-items: center; gap: 8px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(19, 168, 158, .18); }

.page-shell { padding-top: 30px; padding-bottom: 58px; }
.hero-panel { position: relative; overflow: hidden; min-height: 246px; padding: 38px 42px; border-radius: 20px; color: #fff; background: var(--navy); box-shadow: var(--shadow); display: flex; align-items: flex-end; justify-content: space-between; }
.hero-panel::after { content: ""; position: absolute; width: 380px; height: 380px; right: 11%; top: -180px; border: 1px solid rgba(19,168,158,.22); border-radius: 50%; box-shadow: 0 0 0 28px rgba(19,168,158,.045), 0 0 0 68px rgba(19,168,158,.035), 0 0 0 112px rgba(19,168,158,.026); pointer-events: none; }
.hero-panel > * { position: relative; z-index: 1; }
.hero-panel .section-kicker { color: #8aa6b9; margin-bottom: 14px; }
.hero-panel .section-kicker span { color: var(--teal); padding: 0 5px; }
.hero-panel h2 { margin: 0; font-size: clamp(31px, 4vw, 47px); line-height: 1.14; letter-spacing: -.035em; font-weight: 800; }
.hero-panel h2 em { color: #62d5ca; font-style: normal; }
.hero-copy { max-width: 565px; margin: 16px 0 0; color: #bdcdda; font-size: 14px; }
.hero-side { display: flex; align-items: center; gap: 25px; min-width: 240px; padding: 18px 0 0 30px; }
.hero-stat { display: flex; flex-direction: column; gap: 2px; }
.hero-stat span { color: #fff; font-size: 37px; font-weight: 800; line-height: 1; letter-spacing: -.05em; }
.hero-stat small { color: #a9c0ce; font-size: 11px; }
.hero-substat { display: block; margin-top: 7px; color: #62d5ca; font-size: 10px; font-weight: 800; }
.hero-substat span { color: inherit; font-size: inherit; letter-spacing: 0; }
.hero-rule { height: 45px; width: 1px; background: rgba(255,255,255,.25); }

.card { background: var(--paper); border: 1px solid rgba(217,226,231,.9); border-radius: var(--radius); box-shadow: 0 7px 22px rgba(24,49,83,.045); }
.toolbar { position: relative; z-index: 2; margin-top: 18px; padding: 19px 22px 15px; display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.toolbar-group { display: flex; flex-direction: column; gap: 5px; }
.toolbar-group label { color: var(--navy); font-size: 12px; font-weight: 800; }
.month-picker { min-width: 265px; }
.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; right: 14px; top: 7px; color: var(--teal-dark); pointer-events: none; font-size: 18px; }
select { appearance: none; width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #fbfdfe; color: var(--navy); padding: 9px 35px 9px 12px; font-size: 15px; font-weight: 800; }
.control-hint { color: var(--muted); font-size: 11px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.button { min-height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 8px 13px; font-weight: 800; font-size: 12px; letter-spacing: .01em; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--teal-dark); box-shadow: 0 5px 12px rgba(8,126,120,.18); }
.button-primary:hover { background: #056c68; }
.button-secondary { color: var(--navy); background: #fff; border-color: var(--line); }
.button-secondary:hover, .button-quiet:hover { background: var(--teal-soft); border-color: #9bd9d4; }
.button-quiet { color: var(--muted); background: #fff; border-color: var(--line); }
.button-danger { color: var(--red); background: #fff; border-color: #f0d2d0; }
.button-danger:hover { background: var(--red-soft); }
.button span { font-size: 17px; line-height: 0; vertical-align: -1px; margin-right: 3px; }
.save-state { width: 100%; display: flex; align-items: center; gap: 7px; padding-top: 5px; color: var(--muted); font-size: 11px; border-top: 1px solid #eef2f4; }
.save-indicator { width: 7px; height: 7px; border-radius: 50%; background: #a9b7be; }
.save-indicator.is-saved { background: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }

.summary-section, .records-section { padding-top: 42px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 16px; }
.section-kicker { color: var(--teal-dark); }
.section-heading h2 { margin: 3px 0 0; color: var(--navy); font-size: 24px; line-height: 1.2; letter-spacing: -.025em; }
.section-meta { margin: 0 0 3px; color: var(--muted); font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; }
.metric-card { position: relative; overflow: hidden; padding: 19px 19px 16px; min-height: 139px; }
.metric-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--teal); }
.metric-card:nth-child(2)::before { background: #4c77a0; }
.metric-card:nth-child(3)::before { background: #8d78b4; }
.metric-card:nth-child(4)::before { background: #d49c38; }
.metric-label { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; font-weight: 800; }
.metric-icon { color: var(--teal-dark); font-size: 18px; font-weight: 900; }
.metric-value { display: block; margin-top: 6px; color: var(--navy); font-size: 31px; line-height: 1.05; font-weight: 800; letter-spacing: -.06em; }
.metric-value small { margin-left: 4px; font-size: 11px; letter-spacing: 0; color: var(--muted); font-weight: 700; }
.metric-foot { display: flex; justify-content: space-between; margin-top: 10px; color: var(--muted); font-size: 10px; }
.metric-foot strong { color: var(--navy); font-weight: 800; }
.summary-lower-grid { display: grid; grid-template-columns: 1fr 1.06fr; gap: 11px; margin-top: 11px; }
.comparison-card, .alert-card { padding: 19px; min-height: 190px; }
.card-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card-heading-row h3 { margin: 3px 0 0; color: var(--navy); font-size: 17px; }
.small-label { color: var(--muted); font-size: 11px; padding-top: 4px; }
.time-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.time-column { min-width: 0; }
.time-column-header { display: flex; align-items: center; gap: 8px; color: var(--navy); font-size: 12px; font-weight: 800; }
.time-dot { width: 9px; height: 9px; border-radius: 3px; background: #4c77a0; }
.time-dot.evening { background: #8d78b4; }
.time-values { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 9px; }
.time-value { padding: 8px; border-radius: 8px; background: var(--mist); }
.time-value b { display: block; color: var(--navy); font-size: 15px; line-height: 1.2; }
.time-value span { color: var(--muted); font-size: 10px; }
.count-badge { padding: 4px 9px; border-radius: 99px; color: var(--teal-dark); background: var(--teal-soft); font-size: 11px; font-weight: 800; }
.alert-summary { max-height: 108px; overflow-y: auto; margin-top: 12px; }
.alert-empty { display: flex; align-items: center; gap: 9px; min-height: 92px; color: var(--muted); font-size: 12px; }
.alert-empty-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--teal-dark); background: var(--teal-soft); font-weight: 900; }
.alert-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed #e5eaed; font-size: 11px; }
.alert-item:last-child { border-bottom: 0; }
.alert-item-main { display: flex; align-items: center; gap: 8px; }
.alert-item-marker { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--red); }
.alert-item strong { color: var(--navy); }
.alert-reasons { color: var(--red); text-align: right; }

.records-heading { align-items: center; }
.view-filters { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.filter-button { border: 0; border-radius: 7px; padding: 7px 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; }
.filter-button span { display: inline-block; min-width: 17px; margin-left: 3px; padding: 1px 4px; border-radius: 10px; background: #eef3f5; color: var(--muted); font-size: 10px; }
.filter-button.is-active { color: #fff; background: var(--navy); }
.filter-button.is-active span { color: var(--navy); background: #fff; }
.table-wrap { overflow: hidden; }
.readings-table { width: 100%; min-width: 1010px; border-collapse: collapse; table-layout: fixed; }
.readings-table th { padding: 12px 9px; color: #fff; background: var(--navy); text-align: left; font-size: 11px; letter-spacing: .02em; }
.readings-table th:first-child { padding-left: 17px; width: 104px; }
.readings-table th:nth-child(2) { width: 70px; }
.readings-table th:nth-child(3), .readings-table th:nth-child(4), .readings-table th:nth-child(5), .readings-table th:nth-child(6) { width: 91px; text-align: center; }
.readings-table th:nth-child(7) { width: 210px; }
.readings-table th:nth-child(8) { width: 115px; }
.readings-table th:last-child { width: 70px; }
.readings-table th small { display: block; color: #a9c0ce; font-size: 9px; font-weight: 500; }
.readings-table td { height: 60px; padding: 7px 9px; border-top: 1px solid #edf1f3; vertical-align: middle; font-size: 12px; }
.readings-table tbody tr:hover { background: #fbfefe; }
.readings-table tbody tr.row-alert { background: #fffaf9; }
.readings-table tbody tr.row-alert:hover { background: var(--red-soft); }
.readings-table td:first-child { padding-left: 17px; color: var(--navy); font-weight: 800; }
.date-weekday { display: block; color: var(--muted); font-size: 10px; font-weight: 500; }
.period-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--navy); font-size: 11px; font-weight: 800; }
.period-chip::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: #4c77a0; }
.period-chip.evening::before { background: #8d78b4; }
.reading-input, .notes-input { width: 100%; border: 1px solid transparent; border-radius: 7px; outline: none; background: #f5f8f9; color: var(--navy); transition: border .15s ease, background .15s ease; }
.print-value { display: none; color: #111; white-space: pre-wrap; word-break: break-word; }
.reading-input { padding: 8px 5px; text-align: center; font-weight: 800; }
.notes-input { padding: 8px 9px; font-size: 11px; }
.reading-input:hover, .notes-input:hover { background: #edf6f6; }
.reading-input:focus, .notes-input:focus { border-color: var(--teal); background: #fff; }
.reading-input.input-alert { border-color: #efb8b3; background: var(--red-soft); color: var(--red); }
.reading-input::-webkit-outer-spin-button, .reading-input::-webkit-inner-spin-button { margin: 0; }
.pp-cell { color: var(--muted); text-align: center; font-weight: 800; }
.pp-cell.has-value { color: var(--navy); }
.status-cell { font-size: 10px; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 6px; background: #f0f4f5; color: var(--muted); font-weight: 800; white-space: nowrap; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #a9b7be; }
.status-badge.complete { color: var(--teal-dark); background: var(--teal-soft); }
.status-badge.complete::before { background: var(--teal); }
.status-badge.alert { color: var(--red); background: var(--red-soft); }
.status-badge.alert::before { background: var(--red); }
.status-badge.partial { color: var(--amber); background: var(--amber-soft); }
.status-badge.partial::before { background: var(--amber); }
.clear-row { width: 28px; height: 28px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 18px; line-height: 1; }
.clear-row:hover { color: var(--red); background: var(--red-soft); }
.empty-filter { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); text-align: center; }
.empty-icon { width: 36px; height: 36px; display: grid; place-items: center; margin-bottom: 5px; border-radius: 50%; color: var(--teal-dark); background: var(--teal-soft); font-weight: 900; }
.empty-filter strong { color: var(--navy); font-size: 13px; }
.empty-filter span { font-size: 11px; }
.table-footnote { margin: 10px 2px 0; color: var(--muted); font-size: 11px; }
.legend-dot { display: inline-block; width: 7px; height: 7px; margin: 0 4px 0 12px; border-radius: 50%; vertical-align: 1px; }
.legend-dot:first-child { margin-left: 0; }
.legend-normal { background: var(--teal); }
.legend-alert { background: var(--red); }
.legend-line { display: inline-block; width: 13px; height: 1px; margin: 0 4px 3px 12px; background: var(--teal); }

.instructions { margin-top: 40px; overflow: hidden; }
.instructions details > summary { display: flex; align-items: center; gap: 12px; padding: 17px 20px; cursor: pointer; list-style: none; }
.instructions details > summary::-webkit-details-marker { display: none; }
.summary-icon { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: var(--teal-dark); background: var(--teal-soft); font-weight: 900; }
.instructions summary strong { display: block; color: var(--navy); font-size: 14px; }
.instructions summary small { display: block; color: var(--muted); font-size: 11px; }
.summary-chevron { margin-left: auto; color: var(--teal-dark); font-size: 20px; transition: transform .2s ease; }
.instructions details[open] .summary-chevron { transform: rotate(180deg); }
.instructions-content { display: grid; grid-template-columns: repeat(5, 1fr); gap: 18px; padding: 7px 20px 22px; border-top: 1px solid #edf1f3; }
.instruction-block { display: flex; flex-direction: column; gap: 8px; padding-top: 17px; }
.instruction-number { color: var(--teal); font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.instruction-block h3 { margin: 0; color: var(--navy); font-size: 12px; }
.instruction-block p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.instruction-block p strong { color: var(--navy); }

.site-footer { background: var(--navy-deep); color: #a9bdca; }
.footer-inner { min-height: 130px; display: flex; align-items: center; justify-content: space-between; gap: 25px; }
.footer-mark { display: flex; align-items: center; gap: 9px; color: #e6f0f3; white-space: nowrap; font-size: 13px; }
.footer-pulse { color: var(--teal); font-size: 28px; line-height: 1; transform: rotate(-12deg); }
.site-footer p { margin: 0; font-size: 11px; line-height: 1.75; }
.site-footer p strong { color: #e8c98d; }
.footer-range { color: #6f8a9b; font-size: 10px; font-weight: 800; letter-spacing: .08em; white-space: nowrap; }

@media (max-width: 900px) {
  .hero-panel { padding: 31px; }
  .hero-side { min-width: 200px; gap: 16px; padding-left: 18px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .instructions-content { grid-template-columns: repeat(3, 1fr); }
  .toolbar-actions { margin-left: auto; }
}
@media (max-width: 680px) {
  .header-inner, .page-shell, .footer-inner { padding-left: 16px; padding-right: 16px; }
  .header-inner { height: 68px; }
  .header-note { display: none; }
  .brand-lockup h1 { font-size: 15px; }
  .hero-panel { min-height: auto; padding: 27px 23px 24px; display: block; }
  .hero-panel::after { right: -170px; top: -125px; }
  .hero-panel h2 { font-size: 32px; }
  .hero-copy { font-size: 13px; }
  .hero-side { min-width: auto; padding: 25px 0 0; gap: 20px; }
  .hero-stat span { font-size: 29px; }
  .toolbar { padding: 16px; gap: 15px; }
  .month-picker { width: 100%; }
  .toolbar-actions { width: 100%; margin-left: 0; display: grid; grid-template-columns: repeat(2, 1fr); }
  .button { width: 100%; }
  .summary-section, .records-section { padding-top: 32px; }
  .section-heading { display: block; }
  .section-meta { margin-top: 8px; }
  .metric-grid { gap: 8px; }
  .metric-card { min-height: 126px; padding: 15px 13px; }
  .metric-value { font-size: 26px; }
  .summary-lower-grid { grid-template-columns: 1fr; }
  .time-comparison { gap: 12px; }
  .records-heading { display: block; }
  .view-filters { width: 100%; margin-top: 15px; overflow-x: auto; }
  .filter-button { flex: 1; min-width: max-content; padding: 7px 9px; }
  .table-wrap { overflow-x: auto; border-radius: 12px; }
  .readings-table { min-width: 1010px; }
  .instructions-content { grid-template-columns: 1fr; gap: 0; padding-bottom: 18px; }
  .instruction-block { display: grid; grid-template-columns: 35px 1fr; gap: 6px; }
  .instruction-number { padding-top: 2px; }
  .footer-inner { padding-top: 23px; padding-bottom: 23px; display: grid; grid-template-columns: 1fr auto; gap: 12px; }
  .site-footer p { grid-column: 1 / -1; grid-row: 2; }
  .footer-range { grid-column: 2; grid-row: 1; }
}

@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; color: #111; font-size: 10px; }
  .no-print, .site-header, .hero-side, .table-footnote, .site-footer, .button, .action-col, .readings-table td:last-child { display: none !important; }
  .page-shell { max-width: none; padding: 0; }
  .hero-panel { min-height: 0; padding: 0 0 12px; border-radius: 0; color: #111; background: #fff; box-shadow: none; border-bottom: 2px solid var(--navy); }
  .hero-panel::after { display: none; }
  .hero-panel .section-kicker { color: #555; }
  .hero-panel h2 { color: var(--navy); font-size: 25px; }
  .hero-panel h2 em { color: var(--teal-dark); }
  .hero-copy { color: #555; margin-top: 5px; font-size: 10px; }
  .summary-section, .records-section { padding-top: 15px; }
  .section-heading h2 { font-size: 16px; }
  .metric-grid { gap: 6px; }
  .metric-card, .comparison-card, .alert-card, .table-wrap { border: 1px solid #bbb; box-shadow: none; border-radius: 0; }
  .metric-card { min-height: 84px; padding: 9px; }
  .metric-value { font-size: 20px; margin-top: 3px; }
  .metric-foot { margin-top: 5px; }
  .summary-lower-grid { gap: 6px; margin-top: 6px; }
  .comparison-card, .alert-card { min-height: 105px; padding: 9px; }
  .time-comparison { margin-top: 7px; }
  .alert-summary { max-height: none; }
  .readings-table { min-width: 0; font-size: 9px; }
  .readings-table th { padding: 5px; font-size: 9px; }
  .readings-table td { height: 29px; padding: 3px 5px; font-size: 9px; }
  .readings-table th:first-child { padding-left: 5px; }
  .reading-input, .notes-input { padding: 3px; background: #fff; border: 0; font-size: 9px; }
  .field-edit { display: none; }
  .print-value { display: inline; }
  .status-badge { padding: 2px 4px; font-size: 8px; }
  .status-badge::before { display: none; }
}
