:root {
  color-scheme: light dark;
  --bg: #f2f6f5; --surface: #fff; --text: #162b2a; --muted: #506866;
  --line: #bdceca; --primary: #0a665b; --primary-text: #fff; --soft: #e4f3ed;
  --header: #0e352f; --warn: #9b3330; --warn-bg: #fae9e5; --focus: #bb6514;
  font: 100% system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
}
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #10211f; --surface: #182f2c; --text: #eef8f3; --muted: #c4d8d2;
    --line: #57716b; --primary: #91e8ce; --primary-text: #13362e; --soft: #214740;
    --warn: #ffb7ae; --warn-bg: #482a29; --focus: #ffd092;
  }
}
html[data-theme="dark"] {
  --bg: #10211f; --surface: #182f2c; --text: #eef8f3; --muted: #c4d8d2;
  --line: #57716b; --primary: #91e8ce; --primary-text: #13362e; --soft: #214740;
  --warn: #ffb7ae; --warn-bg: #482a29; --focus: #ffd092;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; min-height: 2.75rem; }
button { cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip { position: fixed; inset-block-start: .5rem; inset-inline-start: .5rem; transform: translateY(-200%); z-index: 10; background: var(--surface); padding: .65rem; }
.skip:focus { transform: none; }
#header { background: var(--header); color: #fff; padding: max(.85rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 3rem) .95rem; }
.header-inner { margin: auto; max-width: 72rem; display: flex; justify-content: space-between; align-items: center; gap: .9rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; font-size: 1.25rem; font-weight: 800; }
.brand img { width: 2.6rem; height: 2.6rem; }
.header-tools, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.header-tools label { display: flex; align-items: center; gap: .45rem; }
#header select, #header button { background: #164c42; border-color: #70a197; color: white; }
#main { max-width: 72rem; margin: auto; padding: 1.45rem clamp(.8rem, 3vw, 2rem) 9rem; }
h1, h2, h3, p { margin-block: 0 .6rem; }
h1 { font-size: clamp(1.65rem, 4vw, 2.55rem); line-height: 1.25; }
h2 { font-size: 1.2rem; line-height: 1.35; }
h3 { font-size: 1.03rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; overflow-wrap: anywhere; }
.headline { display: flex; justify-content: space-between; align-items: center; gap: .85rem; flex-wrap: wrap; margin-block-end: 1.15rem; }
.headline p { margin: .25rem 0 0; }
.panel, .metric, .record { border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); padding: 1rem; min-width: 0; overflow-wrap: anywhere; }
.panel { margin-block-end: .85rem; }
.metrics, .cards, .columns { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%, 12.3rem),1fr)); gap: .73rem; margin-block: 0 .95rem; }
.columns { grid-template-columns: repeat(auto-fit,minmax(min(100%, 22rem),1fr)); align-items: start; }
.metric small { display: block; color: var(--muted); font-size: .94rem; }
.metric strong { font-size: clamp(1.14rem, 3vw, 1.65rem); display: inline-block; margin-block-start: .25rem; font-variant-numeric: tabular-nums; }
.metric.accent, .chip { background: var(--soft); }
.chip { border-radius: 5rem; padding: .22rem .65rem; font-size: .88rem; display: inline-block; }
.actions { margin-block: .55rem; }
button { display: inline-flex; justify-content: center; align-items: center; gap: .35rem; border: 1px solid var(--line); border-radius: .62rem; padding: .4rem .8rem; background: var(--surface); color: var(--text); font-weight: 680; text-align: center; }
button.primary { border-color: var(--primary); background: var(--primary); color: var(--primary-text); }
button.danger, .negative { color: var(--warn); }
.empty { padding-block: clamp(1.3rem, 5vw, 3.3rem); text-align: center; }
.empty .actions { justify-content: center; }
#nav { position: fixed; z-index: 2; inset-inline: 0; inset-block-end: 0; background: var(--surface); border-block-start: 1px solid var(--line); display: flex; gap: .15rem; justify-content: center; padding: .42rem .3rem max(.42rem, env(safe-area-inset-bottom)); flex-wrap: wrap; }
#nav button { border: none; font-size: .9rem; padding-inline: clamp(.34rem, 2vw, 1rem); }
#nav button[aria-current="page"] { background: var(--soft); text-decoration: underline; text-underline-offset: .23em; }
#status { position: fixed; z-index: 3; inset-block-end: max(6rem, calc(env(safe-area-inset-bottom) + 5rem)); inset-inline: 1rem; margin: auto; width: fit-content; max-width: calc(100% - 2rem); background: var(--header); color: white; padding: .5rem .9rem; border-radius: .6rem; overflow-wrap: anywhere; }
#status:empty { opacity: 0; pointer-events: none; }
dialog { width: min(calc(100% - 1.2rem), 46rem); max-height: 90dvh; padding: 0; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); color: var(--text); }
dialog::backdrop { background: #071d1bcc; }
.dialog-header { position: sticky; inset-block-start: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: .55rem; padding: .8rem 1rem; background: var(--surface); border-block-end: 1px solid var(--line); }
.dialog-header h2 { margin: 0; }
.dialog-body { padding: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%, 13.5rem),1fr)); gap: .7rem; }
.form-grid .wide { grid-column: 1/-1; }
label.field { display: grid; gap: .25rem; align-content: start; font-weight: 650; }
label.check { display: flex; gap: .5rem; align-items: center; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: .46rem; background: var(--surface); padding: .4rem .57rem; min-width: 0; }
input[type="checkbox"] { width: 1.18rem; min-height: 1.18rem; accent-color: var(--primary); }
input[type=date], input[inputmode=decimal] { direction: ltr; unicode-bidi: isolate; text-align: start; }
fieldset { border: 1px solid var(--line); margin: .65rem 0; border-radius: .65rem; min-inline-size: 0; }
legend { font-weight: 750; }
summary { cursor: pointer; padding-block: .5rem; font-weight: 700; }
.error { background: var(--warn-bg); color: var(--warn); border-radius: .5rem; padding: .45rem .65rem; margin-block: .55rem; }
.error:empty { display: none; }
.table-wrap { overflow: auto; max-width: 100%; margin-block: .55rem; }
table { border-collapse: collapse; width: 100%; }
caption { text-align: start; font-weight: 760; margin-block: .3rem; }
th, td { text-align: start; padding: .5rem; border-block-end: 1px solid var(--line); }
thead th { background: var(--soft); }
.record-row { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .55rem; padding: .5rem 0; border-block-end: 1px solid var(--line); }
.record-row:last-child { border-block-end: 0; }
meter { width: 100%; height: .75rem; accent-color: var(--primary); }
.logo, .thumb { max-width: 6rem; max-height: 4.5rem; object-fit: contain; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; }
#project-picker { max-width: min(65vw, 19rem); }
@media (max-width: 34rem) {
  .header-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
  .header-tools label { min-width: 0; }
  .header-tools button:only-child { grid-column: 2; }
  #project-picker { max-width: none; }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.8rem), 1fr)); }
}
@media (prefers-contrast: more) {
  :root { --line: #45605a; --muted: #304843; }
  html[data-theme="dark"] { --line: #b2d9cf; --muted: #e2fff8; }
  .panel, .metric, .record, input, select, textarea, button { border-width: 2px; }
  :focus-visible { outline-width: 4px; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) { --line: #b2d9cf; --muted: #e2fff8; }
}
@media (forced-colors: active) {
  #nav [aria-current="page"] { outline: 2px solid Highlight; }
  button.primary { border: 2px solid ButtonText; }
}
@media print {
  :root { color-scheme: light; --text: #102d28; --line: #a0b3af; --soft: #e9f5ef; }
  body.printing > :not(#print-report) { display: none !important; }
  body.printing #print-report { display: block !important; }
  body { background: white; color: #112721; font-size: 10pt; line-height: 1.34; }
  #print-report th, #print-report td { padding-block: .34rem; }
  #print-report header { background: #0e352f; color: white; padding: 1rem; print-color-adjust: exact; }
  #print-report h2 { margin-block: 1rem .3rem; }
  #print-report .table-wrap { overflow: visible; }
  #print-report h2 { break-after: avoid; }
  #print-report tr { break-inside: avoid; }
  #print-report thead { display: table-header-group; }
  @page { margin: 12mm; size: A4; }
}
