:root {
  --ink: #1b1b1b;
  --sub: #505050;
  --line: #1b1b1b;
  --hair: #b4b4b4;
  --paper: #ffffff;
  --shade: #f2f2f2;
  --red: #c4161c;
  --red-bg: #fbeaea;
  --link: #1a4fa0;
  --focus: #f5b800;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ececec; --sub: #a8a8a8; --line: #ececec; --hair: #555;
    --paper: #121212; --shade: #1e1e1e; --red: #ff6b6b; --red-bg: #3a1414;
    --link: #8db4ff; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto;
  max-width: 760px;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.7 "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

.unofficial {
  margin: 0 -16px;
  padding: 8px 16px;
  font-size: 13px;
  line-height: 1.5;
  border-bottom: 1px solid var(--hair);
  background: var(--shade);
}

.head {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 16px;
  padding: 20px 0 10px;
  border-bottom: 3px solid var(--line);
}
h1 { margin: 0; font-size: 26px; line-height: 1.3; letter-spacing: .02em; }
.year { font-size: 14px; color: var(--sub); }
.year select { margin-left: 6px; }

h2 {
  margin: 36px 0 12px;
  padding-bottom: 4px;
  font-size: 19px;
  border-bottom: 1px solid var(--line);
}
.small { font-size: 13.5px; color: var(--sub); }
strong { font-weight: 700; }

/* 表は罫線で読む */
table { border-collapse: collapse; width: 100%; }
.split th, .split td { border: 1px solid var(--line); padding: 10px 12px; vertical-align: top; width: 50%; text-align: left; }
.split thead th { background: var(--shade); font-size: 15px; }
.split .and { display: inline-block; margin: 2px 0; font-size: 13px; color: var(--sub); }

.choice { border: 0; margin: 16px 0 0; padding: 0; }
.choice legend { padding: 0; font-weight: 700; margin-bottom: 4px; }
.choice label { display: inline-flex; align-items: center; gap: 6px; margin: 4px 20px 4px 0; min-height: 36px; }
input[type=radio] { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }

.ledger th, .ledger td { border-bottom: 1px solid var(--hair); padding: 8px 6px; text-align: left; }
.totals th { font-weight: 400; width: 55%; }
.totals td { text-align: right; font-size: 20px; font-weight: 700; }
.totals tr:first-child th, .totals tr:first-child td { border-top: 1px solid var(--line); }
.totals .rest th, .totals .rest td { border-bottom: 2px solid var(--line); }
.totals input { width: 9em; text-align: right; font-size: 18px; font-weight: 700; }
.over { color: var(--red); }

.status:empty { display: none; }
.status, .stop {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-left: 6px solid var(--line);
  background: var(--shade);
}
.status.warn, .stop { border-left-color: var(--red); background: var(--red-bg); }
.status.warn strong, .stop strong { color: var(--red); }
.status p, .stop p { margin: 0 0 4px; }

.promo { margin: 18px 0 0; padding-top: 10px; border-top: 1px dashed var(--hair); }
.promo-label { margin: 0 0 2px; font-size: 12px; color: var(--sub); }
.promo-link { font-weight: 700; }

/* 入力 */
input[type=text], input[type=date], select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--ink); border-radius: 0; padding: 6px 8px; min-height: 40px;
}
.add { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.add label { display: flex; flex-direction: column; font-size: 14px; font-weight: 700; gap: 4px; }
.add label input, .add label select { width: 100%; font-weight: 400; }
.add .hint { font-weight: 400; font-size: 12.5px; line-height: 1.5; }
.add .field-error, .add .stop, .add .go { grid-column: 1 / -1; }
.field-error { margin: 0; color: var(--red); font-weight: 700; font-size: 14px; }
@media (max-width: 520px) { .add { grid-template-columns: 1fr; } }

button, .plain.file {
  font: inherit; cursor: pointer; border-radius: 0; min-height: 44px; padding: 8px 16px;
}
.go { justify-self: start; background: var(--ink); color: var(--paper); border: 2px solid var(--ink); font-weight: 700; padding: 8px 28px; }
.plain, .plain.file { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); display: inline-flex; align-items: center; }
.plain.file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.plain.file:focus-within { outline: 3px solid var(--focus); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.stop button { margin: 6px 8px 0 0; }

/* 一覧 */
.scroll { overflow-x: auto; }
.list { min-width: 560px; font-size: 15px; }
.list thead th { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.list .num { text-align: right; }
.list td.num { font-weight: 700; }
.list td { vertical-align: middle; }
.list tr.sixth td { background: var(--red-bg); }
.sent { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 36px; }
.sent input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.sent.todo { color: var(--red); font-weight: 700; }
.del { min-height: 36px; padding: 4px 10px; font-size: 13px; background: none; border: 1px solid var(--hair); color: var(--sub); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.foot { margin-top: 44px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--sub); }

.del { white-space: nowrap; }
.totals td { white-space: nowrap; }

/* 狭い画面：1件を2段で（日付・自治体／サイト・金額・申請書） */
@media (max-width: 600px) {
  .totals th { width: auto; }
  .totals input { width: 7.5em; }
  .list-wrap { overflow: visible; }
  .list { min-width: 0; }
  .list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .list tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "date city del" "site site amt" "sent sent sent";
    column-gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--hair);
  }
  .list tbody tr:first-child { border-top: 1px solid var(--line); }
  .list td { border: 0; padding: 0; }
  .list td:nth-child(1) { grid-area: date; color: var(--sub); }
  .list td:nth-child(2) { grid-area: city; font-weight: 700; }
  .list td:nth-child(3) { grid-area: site; color: var(--sub); font-size: 13.5px; }
  .list td:nth-child(4) { grid-area: amt; font-size: 17px; }
  .list td:nth-child(5) { grid-area: sent; }
  .list td:nth-child(6) { grid-area: del; }
}
@media (max-width: 600px) {
  .list tr.sixth { background: var(--red-bg); padding-left: 6px; padding-right: 6px; }
  .list tr.sixth td { background: none; }
  .list td:nth-child(4), .list td:nth-child(6) { justify-self: end; }
}

/* ---- 送り先・本人情報・e-Tax ---- */
.to { min-width: 620px; font-size: 14.5px; }
.to thead th, .etax thead th { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; }
.to input, .to select { width: 100%; min-height: 36px; padding: 4px 6px; font-size: 14px; }
.to td:first-child { font-weight: 700; white-space: nowrap; }
.notice { padding: 10px 14px; border-left: 6px solid var(--line); background: var(--shade); font-size: 14.5px; }
.add .wide { grid-column: 1 / -1; }
.add label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.add label.check input { width: 20px; height: 20px; accent-color: var(--ink); }
details summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.etax { min-width: 640px; font-size: 14.5px; }
.etax td:nth-child(2) { font-size: 12.5px; color: var(--sub); }
.etax tfoot th, .etax tfoot td { border-top: 2px solid var(--line); font-weight: 700; }
.etax .num { text-align: right; white-space: nowrap; }
h3 { font-size: 16px; margin: 20px 0 6px; }
.steps { padding-left: 1.6em; margin: 0; }
.steps li { margin: 4px 0; }
@media (max-width: 600px) { .list td:nth-child(5) { display: flex; align-items: center; justify-content: space-between; } }

/* ---- 申請書（印刷だけ） ---- */
#sheets { display: none; }
@media print {
  @page { size: A4; margin: 10mm 12mm; }
  body { max-width: none; padding: 0; background: #fff; color: #000; }
  body > :not(#sheets) { display: none !important; }
  #sheets { display: block; }
  .sheet { position: relative; page-break-after: always; break-after: page; font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif; font-size: 8.4pt; line-height: 1.45; color: #000; padding-right: 7mm; }
  .sheet:last-child { page-break-after: auto; break-after: auto; }
  .form-no { position: absolute; right: 0; top: 0; writing-mode: vertical-rl; font-size: 10pt; font-weight: 700; margin: 0; letter-spacing: .05em; }
  .sheet-title { display: flex; justify-content: center; align-items: center; gap: 6mm; font-size: 11pt; font-weight: 400; margin: 0 0 3mm; }
  .sheet-title .taxes { font-size: 9.5pt; line-height: 1.2; }
  .sheet-title.sub { margin-top: 3mm; }
  .sheet h2 { font-size: 10pt; font-weight: 400; margin: 3mm 0 1mm; border: 0; padding: 0; }
  .sheet .note { margin: 1mm 0; font-size: 7.6pt; }
  .sheet .ind { padding-left: 1.2em; }
  .f { width: 100%; border-collapse: collapse; }
  .f th, .f td { border: .3mm solid #000; padding: 1mm 1.5mm; font-weight: 400; text-align: left; vertical-align: middle; }
  .f th { text-align: center; white-space: nowrap; width: 17mm; }
  .head-t { border: .6mm solid #000; }
  .head-t .gap { border-top: 0; border-bottom: 0; width: 8mm; }
  .head-t .date-cell { height: 13mm; vertical-align: top; }
  .head-t .atena { display: inline-block; margin-left: 12mm; }
  .head-t .addr { width: 52mm; vertical-align: top; font-size: 9pt; }
  .head-t .name { font-size: 11pt; height: 9mm; }
  .head-t .sm { font-size: 7pt; }
  .head-t td:not([colspan]):not(.addr):not(.gap):not(.date-cell) { width: 5.2mm; }
  .head-t .birth { font-size: 9pt; }
  .eras { display: inline-block; font-size: 6.5pt; line-height: 1.3; vertical-align: middle; }
  .maru { border: .25mm solid #000; border-radius: 50%; padding: 0 .3mm; }
  .gift { border: .6mm solid #000; }
  .gift th { width: auto; }
  .gift td { height: 7mm; text-align: center; font-size: 10pt; }
  .gift .yen { text-align: right; }
  .chk { border: .6mm solid #000; margin-top: 2mm; }
  .chk td { padding: 2mm 3mm; font-size: 9.5pt; }
  .chk .box { width: 14mm; text-align: center; font-size: 13pt; }
  .cut { text-align: center; font-size: 7pt; margin: 3mm 0 1mm; border-top: .3mm dashed #000; padding-top: .6mm; }
  .recv { border: .6mm solid #000; }
  .recv td { height: 10mm; font-size: 10pt; }
  .recv .stamp { width: 40mm; vertical-align: top; text-align: center; font-size: 7.5pt; }
  .recv .sama { float: right; }
  .dantai { width: 70mm; margin: 2mm 0 0 auto; border: .6mm solid #000; }
  .dantai th { width: 22mm; }
}

.lead { flex-basis: 100%; margin: 4px 0 0; font-size: 15px; }
.certs { min-width: 600px; font-size: 14.5px; }
.certs thead th { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; }
.certs tr.lack td:first-child { box-shadow: inset 4px 0 0 var(--red); padding-left: 10px; }
.xmls { margin-bottom: 12px; }
.xmls th { font-weight: 400; }
.xmls td { text-align: right; width: 7em; }
.cert-sum strong { color: var(--red); }
.route { font-size: 12.5px; color: var(--sub); }
.promo .promo-link { display: block; margin: 2px 0; }
.promo .promo-link[hidden] { display: none; }
