/* Safety Cat design tokens: docs/design-system/MASTER.md */
:root {
  color-scheme: light;
  --paper: #f6f5f0;
  --surface: #fffefa;
  --ink: #253e35;
  --muted: #596b62;
  --green: #315c49;
  --green-hover: #254936;
  --wash: #eaf0e7;
  --line: #d9dfd4;
  --input-border: #a4b3a6;
  --red: #9b3e35;
  --red-wash: #faeee9;
  --amber: #80521b;
  --amber-wash: #f7efdb;
  --focus: #8b511c;
  --radius: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
html { scroll-padding-top: 100px; }
body { margin: 0; }
a { color: var(--green); text-underline-offset: 4px; }
a:hover { color: var(--green-hover); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a, summary { cursor: pointer; }
input, select, textarea { width: 100%; max-width: 100%; min-width: 0; min-height: 48px; padding: 11px 12px; color: var(--ink); border: 1px solid var(--input-border); border-radius: 6px; background: var(--surface); }
textarea { resize: vertical; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 2px; }
label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 8px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: "Noto Serif TC", "PMingLiU", "Songti TC", serif; font-size: clamp(1.9rem, 3vw, 2.65rem); letter-spacing: .05em; font-weight: 600; line-height: 1.4; }
h2 { font-size: 1.15rem; font-weight: 650; line-height: 1.55; }
h3 { font-size: 1rem; font-weight: 600; line-height: 1.8; margin: 0 0 16px; }
p { margin-bottom: 16px; }
dd { margin: 0; overflow-wrap: anywhere; }
.icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }
.site-header { max-width: 1380px; padding: 24px 40px; margin: auto; display: flex; justify-content: space-between; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; font-size: 1.35rem; line-height: 1.4; font-weight: 650; letter-spacing: .07em; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; background: var(--wash); border: 1px solid var(--line); border-radius: 50%; }
.brand-mark .icon { width: 29px; height: 29px; }
.brand-subtitle { display: block; font-size: .7rem; color: var(--muted); font-weight: 400; letter-spacing: .08em; }
.header-tools, .logout { display: flex; align-items: center; gap: 24px; }
.header-home { min-height: 44px; display: flex; align-items: center; text-decoration: none; font-size: .875rem; }
.logout { margin: 0; gap: 12px; }
.admin-name { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; max-width: 150px; }
.header-caption { color: var(--muted); font-size: .8rem; letter-spacing: .06em; }
.shell { max-width: 1300px; margin: auto; padding: 48px 40px 72px; min-height: calc(100vh - 205px); }
.narrow { max-width: 700px; }
.site-footer { max-width: 1220px; margin: auto; padding: 24px 0; border-top: 1px solid var(--line); display: flex; gap: 16px; justify-content: space-between; color: var(--muted); font-size: .75rem; }
.eyebrow { color: var(--muted); letter-spacing: .15em; font-size: .7rem; font-weight: 600; margin-bottom: 8px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.page-heading > div { min-width: 0; }
.page-description { margin: 10px 0 0; font-size: .9rem; color: var(--muted); }
.button { min-height: 44px; max-width: 100%; padding: 10px 18px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 6px; text-decoration: none; font-size: .875rem; font-weight: 600; line-height: 1.5; text-align: center; transition: background-color 160ms ease, border-color 160ms ease; }
.primary { color: var(--surface); background: var(--green); }
.primary:hover { background: var(--green-hover); color: var(--surface); }
.secondary { background: var(--surface); border-color: var(--input-border); color: var(--green); }
.secondary:hover, .quiet:hover { background: var(--wash); }
.quiet { border-color: var(--line); color: var(--green); background: transparent; }
.danger { background: var(--red); color: var(--surface); }
.danger:hover { background: var(--ink); color: var(--surface); }
.button:disabled { opacity: .7; cursor: wait; }
.export-button { flex-shrink: 0; }
.records-panel { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; }
.tabs { display: flex; gap: 32px; margin: 0 28px; border-bottom: 1px solid var(--line); }
.tabs a { display: flex; align-items: center; min-height: 64px; padding: 14px 0; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .875rem; border-bottom: 3px solid transparent; }
.tabs a[aria-current] { color: var(--green); border-bottom-color: var(--green); }
.filter-bar { display: grid; grid-template-columns: minmax(200px, 1fr) 150px 165px auto; align-items: end; gap: 16px; padding: 24px 28px; }
.search-input { position: relative; }
.search-input .icon { position: absolute; top: 15px; left: 13px; pointer-events: none; color: var(--muted); }
.search-input input { padding-left: 42px; }
.filter-bar > .button { min-height: 50px; }
.results-heading { padding: 0 28px 18px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .75rem; }
.results-heading p { margin: 0; }
.results-heading strong { color: var(--ink); font-size: 1rem; }
.results-heading a { padding: 8px 0; min-height: 44px; display: inline-flex; align-items: center; }
.applications { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .875rem; }
.applications th { background: var(--wash); padding: 13px 20px; text-align: left; color: var(--muted); font-size: .75rem; font-weight: 500; border-block: 1px solid var(--line); }
.applications th:first-child { width: 33%; padding-left: 28px; }
.applications th:nth-child(2) { width: 16%; }
.applications th:nth-child(3) { width: 18%; }
.applications th:nth-child(4) { width: 21%; }
.applications th:last-child { width: 12%; }
.applications td { padding: 24px 20px; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.applications td:first-child { padding-left: 28px; }
.applications tr:last-child td { border-bottom: 0; }
.applications tbody tr:hover { background: var(--paper); }
.application-id { font-size: .875rem; font-weight: 650; overflow-wrap: anywhere; letter-spacing: .015em; }
.summary { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: .85rem; }
.progress-label { color: var(--ink); font-weight: 600; white-space: nowrap; }
progress { width: 92px; max-width: 100%; height: 5px; display: block; margin-top: 11px; appearance: none; border: 0; border-radius: 5px; background: var(--wash); color: var(--green); }
progress::-webkit-progress-bar { background: var(--wash); border-radius: 5px; }
progress::-webkit-progress-value { background: var(--green); border-radius: 5px; }
progress::-moz-progress-bar { background: var(--green); border-radius: 5px; }
.badge { display: inline-flex; align-items: center; padding: 3px 10px; min-height: 28px; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 5px; font-size: .75rem; white-space: nowrap; }
.badge[data-state="submitted"] { color: var(--green); background: var(--wash); }
.badge[data-state="ready_to_submit"] { color: var(--amber); background: var(--amber-wash); }
.review-label { display: block; color: var(--amber); margin-top: 7px; font-size: .75rem; }
.review-label[data-review="初審通過"], .review-label[data-review="已結案"] { color: var(--green); }
.review-label[data-review="不適合"] { color: var(--red); }
.changed { display: block; margin-top: 8px; color: var(--red); font-size: .75rem; }
.time-label { color: var(--muted); font-size: .7rem; display: block; margin-bottom: 4px; }
time { font-variant-numeric: tabular-nums; font-size: .8rem; }
.row-button { padding: 8px 10px; background: var(--wash); color: var(--green); white-space: nowrap; }
.row-button:hover { color: var(--surface); background: var(--green); }
.row-button .icon { width: 16px; height: 16px; }
.pagination { border-top: 1px solid var(--line); padding: 20px 28px; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; }
.pagination > div { display: flex; gap: 8px; }
.empty { padding: 64px 24px; text-align: center; border-top: 1px solid var(--line); color: var(--muted); }
.empty > .icon { width: 40px; height: 40px; margin-bottom: 16px; color: var(--green); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.empty p { font-size: .875rem; }
.notice { padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--wash); font-size: .875rem; margin-bottom: 24px; }
.notice.error { color: var(--red); background: var(--red-wash); border-color: var(--red); }
.back-link { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 16px; font-size: .85rem; text-decoration: none; }
.detail-heading { margin-bottom: 24px; }
.detail-id { margin: 8px 0 0; font-size: .875rem; color: var(--muted); overflow-wrap: anywhere; }
.heading-status { text-align: right; flex-shrink: 0; }
.metadata { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin: 0 0 28px; padding-bottom: 24px; border-bottom: 1px solid var(--line); font-size: .8rem; }
.metadata dt { color: var(--muted); font-size: .7rem; margin-bottom: 5px; }
.reading-nav { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0; margin-bottom: 24px; background: var(--paper); border-bottom: 1px solid var(--line); }
.reading-nav a { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-decoration: none; font-size: .8rem; }
.reading-nav a:last-child { margin-left: auto; background: var(--wash); border-color: var(--input-border); }
.reading-nav a:hover { background: var(--wash); border-color: var(--green); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 40px; }
.answers { min-width: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.section-heading h2 { margin: 0; }
.section-heading > span { color: var(--muted); font-size: .75rem; }
.answer-group { display: flex; align-items: flex-start; gap: 14px; padding: 24px 0 18px; }
.answer-group:not(:first-of-type) { margin-top: 16px; }
.group-index { font-family: "Noto Serif TC", "PMingLiU", serif; color: var(--green); font-size: 1.6rem; line-height: 1.3; }
.answer-group h2 { font-size: 1rem; margin-bottom: 3px; }
.answer-group p { color: var(--muted); font-size: .75rem; margin: 0; }
.answer { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; scroll-margin-top: 12px; }
.question-number { color: var(--green); font-weight: 650; font-size: .75rem; margin-bottom: 10px; display: flex; gap: 12px; }
.question-number span { color: var(--muted); font-weight: 400; }
.answer-body { font-size: 1rem; line-height: 1.9; overflow-wrap: anywhere; white-space: pre-wrap; padding-top: 16px; border-top: 1px solid var(--line); }
.unanswered { color: var(--muted); font-size: .875rem; }
.review-panel { padding: 24px; background: var(--wash); border: 1px solid var(--line); border-radius: 10px; scroll-margin-top: 12px; }
.review-panel h2 { margin-bottom: 8px; }
.panel-description { font-size: .8rem; color: var(--muted); margin-bottom: 24px; }
.stack { display: flex; flex-direction: column; min-width: 0; }
.stack > label { margin-top: 18px; }
.stack > label:first-of-type { margin-top: 0; }
.notes-label { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 24px; margin-bottom: 8px; }
.notes-label label { margin: 0; }
.notes-label > span { font-size: .7rem; color: var(--muted); }
.notes-helper { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; font-size: .7rem; color: var(--muted); margin-top: 8px; }
.notes-helper > span:last-child { margin-left: auto; font-variant-numeric: tabular-nums; }
.save-state { margin: 20px 0 8px; font-size: .75rem; color: var(--muted); }
.save-state.is-dirty { color: var(--amber); font-weight: 600; }
.last-edit { font-size: .7rem; color: var(--muted); margin: 16px 0 0; }
.delete-link { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--input-border); }
.delete-link a { display: inline-flex; align-items: center; min-height: 44px; font-size: .8rem; }
.delete-link > span { display: block; color: var(--muted); font-size: .7rem; }
.danger-text { color: var(--red); }
.review-back { display: none; }
.muted { color: var(--muted); font-size: .85rem; }
.delete-summary { padding: 24px; margin: 28px 0; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); }
.delete-summary dt { color: var(--muted); font-size: .75rem; }
.delete-summary dd { margin: 4px 0 16px; }
.delete-summary dd:last-child { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.error-explanation { margin-top: 24px; }
.login { max-width: 1000px; display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: center; padding-top: 72px; padding-bottom: 88px; }
.login h1 { font-size: 2.25rem; margin-bottom: 24px; }
.lede { color: var(--ink); font-size: 1.2rem; line-height: 1.9; }
.login-caption { color: var(--muted); font-size: .85rem; line-height: 1.9; }
.login-rule { display: block; width: 52px; height: 2px; margin-top: 32px; background: var(--green); }
.login-form { border: 1px solid var(--line); border-radius: 12px; padding: 32px; background: var(--surface); }
.login-form h2 { margin: 0 0 6px; }
.login-form > .muted { margin-bottom: 24px; }
.login-form > .button { margin-top: 28px; }
.login > .notice { grid-column: 1 / -1; margin: 0; }
.skip { position: fixed; left: 12px; top: -100px; background: var(--green); color: var(--surface); padding: 12px; z-index: 20; }
.skip:focus { top: 12px; }
.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; }
@media (min-width: 801px) and (min-height: 950px) {
  .review-panel { position: sticky; top: 96px; }
}
@media (max-width: 1000px) {
  .site-header { padding-inline: 28px; }
  .shell { padding-inline: 28px; }
  .site-footer { margin-inline: 28px; }
  .filter-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .search-field { grid-column: 1 / -1; }
  .detail-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; }
  .review-panel { padding: 20px; }
  .applications td, .applications th { padding-inline: 12px; }
  .applications th:first-child, .applications td:first-child { padding-left: 24px; }
}
@media (max-width: 800px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .review-panel { position: static; }
  .review-back { display: inline-flex; min-height: 44px; align-items: center; margin-top: 12px; font-size: .8rem; }
  .metadata { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .applications, .applications tbody { display: block; width: 100%; }
  .applications thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .applications tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 16px; margin: 0 24px 16px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .applications td, .applications td:first-child { display: block; padding: 0; border: 0; }
  .applications td:first-child { grid-column: 1 / -1; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
  .applications td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; font-size: .7rem; color: var(--muted); margin-bottom: 8px; }
  .applications .row-action { align-self: end; justify-self: end; }
  .applications .time-label { display: none; }
  .review-label { display: inline-block; margin-left: 8px; }
  .heading-status .review-label { display: block; margin-left: 0; }
  .login { gap: 32px; }
}
@media (max-width: 600px) {
  .site-header { padding: 18px 20px; gap: 12px; }
  .brand { font-size: 1.15rem; gap: 9px; letter-spacing: .03em; }
  .brand-mark { width: 42px; height: 42px; }
  .brand-subtitle { font-size: .65rem; letter-spacing: 0; }
  .header-home, .header-caption { display: none; }
  .logout { gap: 8px; }
  .admin-name { max-width: 60px; font-size: .7rem; }
  .logout .button { padding-inline: 12px; }
  .shell { padding: 28px 20px 48px; }
  .page-heading { gap: 16px; margin-bottom: 24px; align-items: flex-start; }
  .page-description { font-size: .8rem; }
  .export-button { padding-inline: 12px; font-size: .8rem; margin-top: 20px; }
  .export-button .icon { display: none; }
  .records-panel { border-radius: 10px; }
  .tabs { margin-inline: 16px; gap: 20px; }
  .tabs a { font-size: .8rem; min-height: 58px; }
  .filter-bar { padding: 20px 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 12px; }
  .filter-bar > .button { grid-column: 1 / -1; min-height: 46px; }
  .results-heading { padding: 0 16px 16px; }
  .results-heading > span { display: none; }
  .applications tr { margin-inline: 12px; padding: 18px 16px; gap: 18px 12px; }
  .applications .application-id { font-size: .85rem; }
  .summary { font-size: .875rem; }
  .pagination { padding: 16px; }
  .pagination .button { padding-inline: 10px; font-size: .8rem; }
  .site-footer { margin-inline: 20px; flex-direction: column; gap: 6px; font-size: .7rem; }
  .eyebrow { font-size: .65rem; letter-spacing: .1em; }
  .detail-heading .heading-status { margin-top: 22px; }
  .detail-id { font-size: .8rem; }
  .metadata { font-size: .75rem; }
  .reading-nav { gap: 8px; padding-block: 10px; }
  .reading-nav a { flex: 1; padding: 9px 10px; white-space: nowrap; }
  .reading-nav a:last-child { margin-left: 0; }
  .section-heading { margin-bottom: 8px; }
  .section-heading h2 { font-size: 1rem; }
  .answer { padding: 20px; }
  .answer-group h2 { font-size: .95rem; }
  .answer-group p { font-size: .7rem; }
  .login { display: block; padding-top: 36px; }
  .login-intro { margin-bottom: 28px; }
  .login h1 { font-size: 2rem; margin-bottom: 12px; }
  .lede { font-size: 1rem; margin-bottom: 12px; }
  .login-caption, .login-rule { display: none; }
  .login-form { padding: 24px; }
  .login > .notice { margin-bottom: 24px; }
  .actions { flex-direction: column; }
}
@media (max-width: 400px) {
  html { scroll-padding-top: 132px; }
  .reading-nav a { flex-basis: 40%; }
  .tabs { gap: 16px; }
  .admin-name { display: none; }
  .review-label { display: block; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
