:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page-bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #18202a;
  --muted: #56616f;
  --border: #7a8694;
  --border-subtle: #e7ebef;
  --link: #0b57a3;
  --brand: #18202a;
  --button: #1456a0;
  --button-hover: #0d477f;
  --button-text: #ffffff;
  --input-bg: #ffffff;
  --input-text: #18202a;
  --focus: #a44f00;
  --message-bg: #e8f3ff;
  --message-text: #163b63;
  --error: #a11919;
  --notice-bg: #fff7df;
  --notice-border: #b58700;
  --notice-text: #5f4700;
  --shadow: 0 1px 2px rgb(15 23 42 / 8%);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #111827;
  --text: #f8fafc;
  --muted: #cbd5e1;
  --border: #64748b;
  --border-subtle: #475569;
  --link: #93c5fd;
  --brand: #f8fafc;
  --button: #2563eb;
  --button-hover: #1d4ed8;
  --button-text: #ffffff;
  --input-bg: #111827;
  --input-text: #f8fafc;
  --focus: #fbbf24;
  --message-bg: #172554;
  --message-text: #dbeafe;
  --error: #fca5a5;
  --notice-bg: #422006;
  --notice-border: #d97706;
  --notice-text: #fef3c7;
  --shadow: 0 1px 2px rgb(0 0 0 / 35%);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page-bg); color: var(--text); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; min-width: 0; }
.topbar nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
a { color: var(--link); }
.brand { color: var(--brand); font-weight: 700; text-decoration: none; }
.container { max-width: 1100px; margin: 2rem auto; padding: 0 1rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 3rem auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: .75rem; border-bottom: 1px solid var(--border-subtle); text-align: left; }
form p { display: grid; gap: .35rem; }
input, select, textarea { padding: .65rem; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg); color: var(--input-text); }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button, .button { display: inline-block; padding: .65rem .9rem; border: 0; border-radius: 6px; background: var(--button); color: var(--button-text); text-decoration: none; cursor: pointer; }
button:hover, .button:hover { background: var(--button-hover); }
.inline-form { display: inline; }
.link-button { background: transparent; color: var(--link); padding: 0; }
.link-button:hover { background: transparent; text-decoration: underline; }
.actions { display: flex; gap: .5rem; margin: 1rem 0; flex-wrap: wrap; }
.message { background: var(--message-bg); color: var(--message-text); padding: .75rem; border-radius: 6px; margin-bottom: 1rem; }
.errorlist { color: var(--error); }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.report-card { display: grid; gap: .4rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; text-decoration: none; box-shadow: var(--shadow); }
.report-card span { color: var(--muted); }
.report-filter { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; align-items: end; margin-bottom: 1rem; }
.report-filter p { margin: 0; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1rem 0; }
.summary-card { display: grid; gap: .35rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; box-shadow: var(--shadow); }
.summary-card span { color: var(--muted); }
.summary-card strong { font-size: 1.25rem; }
.number { text-align: right; white-space: nowrap; }
.notice { padding: .75rem; background: var(--notice-bg); color: var(--notice-text); border: 1px solid var(--notice-border); border-radius: 6px; }
.totals-panel { margin-top: 1rem; }
.theme-control { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; color: var(--muted); }
.theme-control select { min-width: 8rem; padding: .45rem .6rem; }
.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 (max-width: 900px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; }
}
@media (max-width: 700px) {
  .grid-two { grid-template-columns: 1fr; }
  .topbar { padding: 1rem; }
  .topbar nav { gap: .75rem; }
  .container { margin-top: 1rem; }
}

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-header h1 { margin-top: 0; }
.form-card { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: .75rem; }
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
legend { padding: 0 .35rem; font-weight: 700; }
code { overflow-wrap: anywhere; background: var(--surface-alt); color: var(--text); border: 1px solid var(--border-subtle); border-radius: 4px; padding: .1rem .3rem; }
dl { display: grid; gap: .65rem; }
dt { color: var(--muted); font-weight: 600; }
dd { margin: .15rem 0 0; }
.pagination { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; }
.message.error { background: var(--notice-bg); color: var(--error); border: 1px solid var(--notice-border); }
small { color: var(--muted); }

@media (max-width: 700px) {
  .page-header { flex-direction: column; }
}
