/* Association identity: onanip-onepage. Accounting and document layouts remain separate. */
:root {
  --paper: #F7F2E8;
  --brown: #5A321B;
  --olive: #758363;
  --gold: #D8A12B;
  --ink: #2B2A27;
  --muted: #6E6A62;
  --line: #E1D5C0;
  --light: #FFF9EE;
  --green: #536245;
  --serif: "Noto Serif CJK TC", "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; display: flex; flex-direction: column; line-height: 1.75; overflow-wrap: break-word; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--light); color: var(--brown); border-radius: 4px; padding: 9px 15px; min-height: 44px; font-size: 13px; font-weight: 600; line-height: 1.6; }
button:hover { background: #EFE6D4; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--brown); color: var(--light); border-color: var(--brown); }
.primary:hover { background: #714427; }
a { color: var(--brown); text-underline-offset: 5px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: 10px; z-index: 150; transform: translateY(-200%); padding: 10px 16px; background: var(--light); }
.skip-link:focus { transform: none; }

/* One sticky container adapts to the actual header height, including wrapped account names. */
.site-masthead { position: sticky; top: 0; z-index: 20; flex-shrink: 0; background: var(--paper); box-shadow: 0 3px 12px #5A321B0F; }
header { border-bottom: 1px solid var(--line); }
.header-inner, .nav-inner, .footer-inner { width: calc(100% - 72px); max-width: 1100px; margin-inline: auto; }
.header-inner { min-height: 92px; padding-block: 17px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { flex-shrink: 0; color: var(--brown); text-decoration: none; }
.brand-word { display: block; font-family: Georgia, serif; font-size: 30px; line-height: 1.05; letter-spacing: .08em; font-weight: 600; }
.brand-dot { color: var(--gold); }
.brand-name { display: block; margin-top: 7px; font-size: 11px; font-weight: 600; letter-spacing: .09em; }
.user-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px 12px; min-width: 0; }
.user-actions span { font-size: 12px; }
.user-actions .system-label { color: #536245; border-right: 1px solid var(--line); padding-right: 14px; letter-spacing: .05em; }
#user-name { color: var(--muted); overflow-wrap: anywhere; }
.user-actions button { padding: 8px 12px; }
nav { border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; gap: 8px; padding-block: 10px; }
nav button { min-width: 108px; border: 1px solid transparent; background: transparent; color: var(--muted); }
nav button:hover { background: #EFE6D4; color: var(--brown); }
nav .active { background: var(--brown); color: var(--light); }
nav .active:hover { background: #714427; color: var(--light); }
.home-link { margin-left: auto; padding: 10px 0 10px 16px; font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.home-link:hover { text-decoration: underline; }

main { flex: 1; width: calc(100% - 72px); max-width: 1100px; margin: 0 auto; padding: 40px 0 72px; }
h1, h2 { font-family: var(--serif); color: var(--brown); font-weight: 700; line-height: 1.5; letter-spacing: .04em; }
h1 { font-size: clamp(26px, 3vw, 34px); }
h2 { font-size: 21px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-heading h1, .section-heading h2 { margin: 0; }
.section-heading label { min-width: 110px; }
.eyebrow { display: flex; align-items: center; gap: 10px; font-size: 11px; letter-spacing: .13em; font-weight: 600; color: #536245; margin-bottom: 12px; }
[data-view] .eyebrow::before { display: inline-block; padding: 2px 8px; border-radius: 3px; background: var(--gold); color: var(--brown); font-family: Georgia, serif; letter-spacing: 0; }
[data-view="dashboard"] .eyebrow::before { content: "01"; }
[data-view="entry"] .eyebrow::before { content: "02"; }
[data-view="list"] .eyebrow::before { content: "03"; }
[data-view="projects"] .eyebrow::before { content: "04"; }
.card { background: var(--light); border: 1px solid var(--line); border-radius: 4px; padding: 26px; margin-bottom: 22px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.empty { text-align: center; padding: 40px; color: var(--muted); }

/* The original association photograph stays fully visible at every screen size. */
.login { display: grid; grid-template-columns: .85fr 1.3fr; border: 1px solid var(--line); margin: 4px 0 10px; }
.login-photo { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; background: #EAE8DC; min-width: 0; }
.login-photo img { display: block; max-width: 100%; width: auto; height: auto; max-height: 430px; object-fit: contain; }
.photo-caption { display: block; margin-top: 14px; color: var(--brown); font-size: 11px; letter-spacing: .07em; text-align: center; }
.login-copy { padding: 40px 12%; background-image: radial-gradient(#9C886917 .8px, transparent .8px); background-size: 6px 6px; }
.login h1 { font-size: clamp(32px, 3.8vw, 46px); line-height: 1.55; margin: 0 0 22px; }
.login p { color: var(--muted); font-size: 14px; margin: 20px 0; }
.login p.hint { font-size: 12px; margin-bottom: 0; }
.login .primary { padding: 12px 22px; }
.landscape { height: 60px; width: 180px; position: relative; margin-bottom: 24px; }
.sun { position: absolute; left: 21px; top: 0; width: 36px; height: 36px; background: var(--gold); border-radius: 50%; }
.mountain { position: absolute; left: 0; bottom: 0; width: 180px; height: 48px; background: var(--olive); clip-path: polygon(0 100%,40% 20%,54% 47%,65% 31%,100% 100%,65% 47%,54% 65%,40% 37%,0 100%); }
.hero-rule { height: 4px; background: linear-gradient(to right, var(--gold) 0 25%, transparent 25% 29%, #9AA88A 29% 100%); border-radius: 6px; margin: 4px 0 24px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 24px 0 28px; }
.stat { background: var(--light); border: 1px solid var(--line); border-top: 4px solid var(--olive); border-radius: 3px; padding: 21px; min-width: 0; }
.stat:nth-child(2) { border-top-color: var(--brown); }
.stat:nth-child(3) { border-top-color: var(--gold); }
.stat:nth-child(4) { border-top-color: #AF7855; }
.stat small { color: var(--muted); font-size: 12px; }
.stat strong { display: block; font-size: clamp(21px, 2.1vw, 29px); color: #536245; margin: 9px 0; font-variant-numeric: tabular-nums; line-height: 1.5; overflow-wrap: anywhere; }
.stat.expense strong { color: var(--brown); }
.stat .hint { font-size: 11px; }
.project-stat { padding: 18px 0; border-top: 1px solid var(--line); }
.project-stat:first-child { border-top: 0; }
.project-stat .line { display: flex; justify-content: space-between; gap: 18px; font-size: 14px; }
.project-stat .line strong { color: var(--brown); font-weight: 600; }
.project-stat .line span { font-variant-numeric: tabular-nums; flex-shrink: 0; }
.meter { background: #EAE8DC; height: 7px; border-radius: 2px; margin: 12px 0 6px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--olive); }
.meter.over span { background: #A25835; }
.form-card { max-width: 860px; border-top: 4px solid var(--olive); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
label { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 600; color: var(--brown); min-width: 0; }
input, select, textarea { padding: 11px 12px; border: 1px solid #CFBFA5; border-radius: 4px; width: 100%; background: #FFFCF6; color: var(--ink); min-width: 0; font-size: 14px; min-height: 44px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #82776A; opacity: 1; }
textarea { resize: vertical; }
.wide { grid-column: 1/-1; }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; padding: 22px; }
.table-wrap { padding: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--brown); background: #EFEBDD; font-size: 12px; font-weight: 600; }
th, td { padding: 17px; border-bottom: 1px solid var(--line); vertical-align: top; }
td small { display: block; color: var(--muted); margin: 3px 0; }
.table-wrap tbody tr:hover { background: #F5EEDD; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; font-size: 14px; }
.income { color: #536245; }
.expense { color: #8C492A; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 3px; background: #EBE6DA; color: #645B4C; margin-top: 6px; }
.badge.pending { background: #F5E6BE; color: #735016; }
.badge.approved { background: #E9EACF; color: #536245; }
.badge.paid, .badge.income { background: #E3E8D9; color: #42523B; }
.badge.void { background: #EFDFD4; color: #824729; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.actions button { padding: 6px 10px; min-height: 36px; font-size: 12px; }
.actions [data-action="approve"], .actions [data-action="pay"] { background: var(--brown); color: var(--light); border-color: var(--brown); }
.actions [data-action="approve"]:hover, .actions [data-action="pay"]:hover { background: #714427; }
.actions [data-action="void"] { color: #944728; }
.bank { background: #EEEBDD; color: #5C604D; padding: 6px 8px; font-size: 11px; border-left: 2px solid #A8B18F; border-radius: 2px; overflow-wrap: anywhere; }
.pagination { display: flex; justify-content: space-between; gap: 10px; padding: 16px 18px; align-items: center; font-size: 12px; color: var(--muted); }
.project-card { display: flex; justify-content: space-between; gap: 20px; align-items: center; border-left: 4px solid var(--olive); }
.project-card h2 { margin: 0 0 4px; }
.project-card.closed { background: #EFEEE4; border-left-color: #B2AB9B; }
.project-card .meta { font-size: 12px; color: var(--muted); }
.project-card > div { min-width: 0; }
.project-card > div:last-child > strong { color: var(--brown); display: block; margin-bottom: 8px; font-variant-numeric: tabular-nums; }

dialog { border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 4px; background: var(--light); color: var(--ink); box-shadow: 0 20px 80px #5A321B30; padding: 28px; max-width: 540px; width: calc(100% - 32px); max-height: 90dvh; overflow: auto; }
dialog::backdrop { background: #43281885; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.dialog-heading h2 { margin: 0; }
.dialog-heading > div { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.preview-dialog { max-width: 1100px; }
.paper-scroll { background: #EAE8DC; padding: 16px; overflow: auto; max-height: 65dvh; }
.paper { background: white; padding: 10mm; width: 200mm; min-height: 260mm; color: black; font-family: "Noto Sans TC","Microsoft JhengHei",sans-serif; font-size: 10pt; box-shadow: 0 0 4px #0002; line-height: 1.6; }
.paper.landscape { width: 287mm; min-height: 180mm; }
.paper h1 { font-size: 18pt; text-align: center; margin: 0; }
.paper h2 { font-size: 15pt; text-align: center; margin: 8px 0; }
.paper h1, .paper h2 { color: black; font-family: inherit; letter-spacing: -.03em; }
.paper p { font-size: 10pt; }
.paper th, .paper td { border: .5pt solid #333; padding: 5px; font-size: 9pt; overflow-wrap: anywhere; }
.paper th { background: #F3F3F3; color: #333; }
.paper thead { display: table-header-group; }
.paper tr, .paper .signature { break-inside: avoid; }
.paper .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper .signature td { height: 22mm; }
.paper .attachment { height: 85mm; border: .5pt dashed #888; display: flex; align-items: center; justify-content: center; color: #888; margin: 6mm 0; }
.paper .report-note { font-size: 9pt; color: #444; }

.busy { position: fixed; inset: 0; z-index: 100; background: #F7F2E8ED; display: flex; align-items: center; justify-content: center; padding: 22px; color: var(--brown); font-weight: 600; }
.busy::before { content: ""; border: 3px solid var(--line); border-top-color: var(--brown); width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%; margin-right: 12px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#message { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--brown); color: var(--light); padding: 13px 22px; border-radius: 4px; box-shadow: 0 4px 20px #43281825; width: max-content; max-width: calc(100% - 32px); z-index: 120; font-size: 14px; }
#message.error { background: #8E4132; }
.site-footer { background: #432818; color: #E3D6BF; padding: 26px 0; font-size: 12px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.site-footer strong { display: block; font-weight: 500; color: var(--light); font-size: 13px; }
.site-footer span:not(.sr-only) { display: block; font-size: 11px; margin-top: 5px; }
.footer-inner > div:last-child { text-align: right; }
.site-footer a { display: inline-block; color: #E3D6BF; margin-top: 4px; text-decoration: none; font-size: 11px; }
.site-footer a:hover { text-decoration: underline; }

@media (max-width: 820px) {
  .header-inner, .nav-inner, .footer-inner, main { width: calc(100% - 44px); }
  .header-inner { gap: 16px; }
  .user-actions { gap: 6px 8px; }
  .user-actions .system-label { border: 0; padding: 0; width: 100%; text-align: right; }
  nav button { min-width: 96px; }
  main { padding: 30px 0 56px; }
  .login-copy { padding: 32px 9%; }
  .login-photo { padding: 22px; }
  .login h1 { font-size: 34px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat strong { font-size: 27px; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .card { padding: 22px; }
  .table-wrap { padding: 0; }
  th, td { padding: 14px 12px; }
  .actions { max-width: 145px; }
  .project-card { align-items: flex-start; }
  .dialog-heading button { font-size: 12px; padding: 8px 10px; }
}
@media (max-width: 560px) {
  .header-inner, .nav-inner, .footer-inner, main { width: calc(100% - 36px); }
  .header-inner { padding-block: 15px; min-height: 82px; gap: 12px; flex-wrap: wrap; }
  .brand-word { font-size: 26px; }
  .brand-name { font-size: 10px; letter-spacing: .04em; }
  .user-actions { margin-left: auto; display: grid; grid-template-columns: auto auto; gap: 6px; }
  .user-actions .system-label { display: none; }
  .user-actions button { font-size: 12px; padding: 8px 10px; }
  #user-name { grid-column: 1/-1; font-size: 11px; max-width: 150px; text-align: right; }
  .nav-inner { gap: 4px; padding-block: 8px; }
  nav button { min-width: 0; flex: 1; padding: 9px 4px; font-size: 12px; }
  .home-link { display: none; }
  main { padding: 24px 0 44px; }
  .login { grid-template-columns: 1fr; margin-top: 0; }
  .login-copy { padding: 30px 24px; order: 1; }
  .login-photo { padding: 24px 18px; order: 2; }
  .login-photo img { max-height: 310px; }
  .login h1 { font-size: clamp(30px, 8.5vw, 38px); line-height: 1.5; }
  .login p { font-size: 13px; }
  .landscape { height: 48px; width: 150px; margin-bottom: 20px; }
  .sun { width: 32px; height: 32px; }
  .mountain { width: 150px; height: 42px; }
  .section-heading { align-items: flex-start; gap: 12px; }
  .section-heading .hint { max-width: 135px; text-align: right; }
  .section-heading label { min-width: 92px; }
  .eyebrow { font-size: 10px; margin-bottom: 10px; }
  h1 { font-size: 26px; }
  h2 { font-size: 19px; }
  .card { padding: 18px; }
  .table-wrap { padding: 0; }
  .stats { gap: 12px; }
  .stat { padding: 15px; }
  .stat strong { font-size: 24px; }
  .filters { gap: 12px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .wide { grid-column: auto; }
  .project-stat .line { flex-wrap: wrap; gap: 5px; }
  .project-card { flex-direction: column; align-items: stretch; gap: 12px; }
  .project-card .actions { max-width: none; }
  .project-card > div:last-child { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
  th, td { padding: 14px 9px; }
  .table-wrap th:nth-child(2) { width: 92px; }
  .table-wrap th:nth-child(3) { width: 90px; }
  .table-wrap .amount { font-size: 13px; }
  .table-wrap tbody tr { scroll-margin-top: 210px; }
  .actions { min-width: 78px; }
  .actions button { min-height: 44px; padding: 8px 9px; font-size: 12px; }
  .pagination { padding: 14px 12px; }
  .pagination button { font-size: 12px; padding: 8px 10px; flex-shrink: 0; }
  .pagination span { text-align: center; }
  .preview-dialog { padding: 14px; }
  .preview-dialog .dialog-heading { align-items: flex-start; flex-wrap: wrap; }
  .preview-dialog .dialog-heading > div { justify-content: flex-start; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .footer-inner > div:last-child { text-align: left; }
}
@media (max-width: 360px) {
  .header-inner, .nav-inner, .footer-inner, main { width: calc(100% - 28px); }
  .header-inner { gap: 10px; }
  .user-actions { gap: 5px; }
  .user-actions .system-label { font-size: 10px; }
  .stat strong { font-size: 21px; }
  .filters { padding: 15px; }
  .section-heading { flex-wrap: wrap; }
  .section-heading .hint { max-width: none; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .busy::before { animation: none; }
}

/* Preserve A4 accounting output, independent of the website theme. */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { display: block; background: white; min-height: 0; }
  body > *:not(#print-root) { display: none !important; }
  body > #preview-dialog { display: none !important; }
  #print-root { display: block !important; position: static; margin: 0; padding: 0; }
  #print-root .paper, #print-root .paper.landscape { width: 100%; min-height: 0; padding: 0; box-shadow: none; overflow: visible; }
  #print-root .paper th { background: #F3F3F3 !important; }
  #print-root .paper th, #print-root .paper td { padding: 3px 5px; line-height: 1.4; }
  .paper .signature { margin-top: 8mm; }
}
