:root {
  color-scheme: dark;
  --on-accent: #14271a;
  --page: #101815;
  --ink: #eaf2ed;
  --edge: #394c42;
  --surface: #19251f;
  --soft: #b2c4b8;
  --result: #213d30;
  --control: #778d7f;
  --input-edge: #778d7f;
  --accent: #a2dfb6;
  --focus: #9bcaff;
  --hint: #b8d5c2;
  --error: #ffb8a9;
  --value: #c0f1ce;
  --rule: #526f5d;
  --panel: #26362d;
  --highlight: #294634;
}
:root[data-theme=light] {
  color-scheme: light;
  --on-accent: white;
  --page: #f6f8f7;
  --ink: #1b3028;
  --edge: #d4dfd8;
  --surface: white;
  --soft: #53665b;
  --result: #e1eee5;
  --control: #9cad9f;
  --input-edge: #7a8c80;
  --accent: #286044;
  --focus: #246bdb;
  --hint: #365741;
  --error: #8a3126;
  --value: #20583b;
  --rule: #c1d5c7;
  --panel: #edf3ef;
  --highlight: #deece2;
}
* { box-sizing: border-box }
body { margin: 0; background: var(--page); color: var(--ink); font: 1rem/1.5 "Segoe UI", sans-serif }
header { display: flex; align-items: center; gap: .6rem; padding: 1rem max(5vw, calc((100vw - 66rem)/2)); border-bottom: 1px solid var(--edge); background: var(--surface); font-size: 1.3rem; font-weight: 700 }
.mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background:var(--accent); color:var(--on-accent); font: italic bold 1.7rem Georgia }
main { width: min(90%, 66rem); margin: clamp(2rem,7vw,5rem) auto }
h1 { font-size: clamp(2rem,5vw,3.8rem); line-height: 1.08; letter-spacing: -.05em; margin: 0 }
p { color: var(--soft); margin: .8rem 0 2rem }
.grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.25rem }
form, section { padding: clamp(1.25rem,3vw,2rem); border-radius: 1.125rem; border: 1px solid var(--edge); background: var(--surface) }
section { background: var(--result) }
h2 { margin: 0; font-size: 1.2rem }
.title, dl div { display: flex; align-items: center; justify-content: space-between; gap: .5rem }
button { background: transparent; border: 1px solid var(--control); border-radius: .5rem; padding: .65rem; color: var(--accent); cursor: pointer; font: inherit }
.fields { margin-top: 1.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem }
label { min-width: 0; font-weight: 600 }
input { width: 100%; display: block; margin-top: .35rem; padding: .8rem; border: 1px solid var(--input-edge); border-radius: .5rem; color: inherit; font: inherit }
input:focus-visible, button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px }
small { display: block; font-weight: 400; color: var(--hint) }
[aria-invalid=true] + small { color: var(--error) }
strong { display: block; color: var(--value); font-size: clamp(2rem,4vw,3.1rem); letter-spacing: -.04em; margin: .5rem 0 1.4rem }
dl { margin: 0 }
dl div { padding: .6rem 0; border-top: 1px solid var(--rule) }
dd { margin: 0; text-align: right; font-weight: 600 }
@media(max-width: 720px) { .grid, .fields { grid-template-columns: 1fr } }
.actions { display:flex; flex-wrap:wrap; gap:.6rem; margin-top:1.4rem }
#save { background:var(--accent); color:var(--on-accent); border-color:var(--accent); font-weight:600 }
#save:disabled { opacity:.5; cursor:default }
#notice:not(:empty) { margin-top:.8rem }
.sheet { background:var(--surface); margin-top:1.25rem }
.sheet p { margin:.3rem 0 1.5rem }
table { width:100%; border-collapse:collapse; margin-top:1.3rem }
caption { background:var(--panel); padding:.8rem; text-align:left }
caption span { float:right }
th,td { text-align:left; padding:.6rem .45rem; border-bottom:1px solid var(--edge) }
td button { padding:.45rem; margin:.1rem }
@media(max-width:720px) {
  table,tbody,tr,td,caption { display:block }
  thead { position:absolute; clip-path:inset(100%); width:1px; height:1px; overflow:hidden }
  caption span { display:block; float:none }
  td[data-label] { display:flex; justify-content:space-between; gap:.5rem }
  td[data-label]::before { content:attr(data-label); color:var(--soft) }
  tr { margin-bottom:.8rem }
}
.month-nav { display:flex; flex-wrap:wrap; gap:.6rem; align-items:flex-end }
.month-nav label { max-width:100% }
.sheet h3 { margin:1.75rem 0 .65rem; font-size:1.4rem }
.summary { display:grid; grid-template-columns:1.35fr 1fr 1fr; gap:.65rem; margin-bottom:1.5rem }
.summary div { display:block; padding:1rem; background:var(--panel); border:0; border-radius:.65rem }
.summary div:first-child { background:var(--highlight) }
.summary dd { text-align:left; font-size:1.2rem }
.summary b { font-size:1.55rem; color:var(--value) }
.summary small { font-size:.9rem; font-weight:400 }
caption { overflow:auto }
@media(max-width:720px) {
  .summary { grid-template-columns:1fr }
  .month-nav label { flex-basis:100% }
  .month-nav button { flex:1 1 8rem }
}
.export-actions { display:flex; flex-wrap:wrap; align-items:flex-end; gap:.65rem; margin-bottom:1.5rem }
.export-actions input { max-width:100% }
.export-actions button:disabled { opacity:.5; cursor:default }
#printPages { display:none }
@page { size:A4 portrait; margin:0 }
@media print {
  body { margin:0; background:white }
  body > :not(#printPages) { display:none !important }
  #printPages { display:block }
  #printPages svg { display:block; width:210mm; height:296.9mm; break-after:page }
  #printPages svg:last-child { break-after:auto }
}
.pwa { display:flex; flex-wrap:wrap; align-items:center; gap:.6rem; margin-top:1rem; color:var(--hint) }
.pwa span:empty { display:none }
@media(max-width:720px) {
  .grid > *, .export-actions > *, .month-nav > * { min-width:0; max-width:100% }
  .grid { grid-template-columns:minmax(0,1fr) }
  .title { flex-wrap:wrap }
  .export-actions button { white-space:normal }
}

#themeToggle { margin-inline-start:auto; font-size:.94rem; font-weight:600 }
input { background:var(--page) }
input::placeholder { color:var(--soft) }
@media print { :root { color-scheme:light } }

