:root {
  color-scheme: light;
  --canvas: #f4f7f8;
  --surface: #fff;
  --ink: #142731;
  --muted: #526672;
  --line: #dce5e8;
  --soft: #eef5f5;
  --accent: #087269;
  --accent-ink: #fff;
  --danger: #a22638;
  --shadow: 0 8px 30px #172f3d08;
  --rail-width: 248px;
  --header-height: 68px;
}

:root[data-theme=sombre] {
  color-scheme: dark;
  --canvas: #111c24;
  --surface: #192933;
  --ink: #eef6f8;
  --muted: #b0c2cb;
  --line: #36505b;
  --soft: #233943;
  --accent: #81e3d3;
  --accent-ink: #102e31;
  --danger: #ffadba;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.55 "Segoe UI", system-ui, sans-serif;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid #29a89e; outline-offset: 3px; }
header {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--header-height);
  padding: 10px clamp(16px, 3vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
header b { margin-right: auto; font-size: 17px; letter-spacing: -.025em; overflow-wrap: anywhere; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #087269;
  color: white;
}
.brand-mark svg { width: 22px; height: 22px; }
main { max-width: 1440px; margin-inline: auto; padding: clamp(18px, 3vw, 44px); }
body.signed main { margin-left: var(--rail-width); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.035em; }
h1 { margin: 0 0 24px; font-size: clamp(30px, 4vw, 44px); }
h2 { margin: 0 0 18px; font-size: clamp(20px, 2.25vw, 26px); }
section, .panel {
  padding: clamp(16px, 2.15vw, 28px);
  margin: 18px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
section section { box-shadow: none; }
section:empty { display: none; }
label {
  display: inline-grid;
  max-width: 100%;
  gap: 6px;
  margin: 5px 12px 10px 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
input, select, textarea {
  min-height: 44px;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
button {
  min-height: 42px;
  margin: 3px 4px 3px 0;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
}
button.secondary, button.prev, button.next, header button, button[type=button] {
  background: var(--soft);
  border-color: var(--line);
  color: var(--ink);
}
button.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
button:enabled:hover { filter: brightness(.91); }
button:disabled { opacity: .5; cursor: default; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--soft); color: var(--muted); font-size: 13px; }
tbody tr:hover { background: var(--soft); }
td button { min-height: 34px; padding: 5px 9px; }
small { color: var(--muted); }
.line { margin: 8px 0; padding: 12px; border-radius: 12px; background: var(--soft); overflow-wrap: anywhere; }
.line small { display: block; }
details { margin: 8px 0; }
summary { padding: 5px 0; font-weight: 600; cursor: pointer; }
output { display: block; white-space: pre-line; font-weight: 600; }
#notice:not(:empty), #checkAlert:not([hidden]) {
  margin: 12px 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: var(--soft);
}
#notice[data-error=true] { border-left-color: var(--danger); color: var(--danger); }

#login {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  max-width: 940px;
  min-height: 465px;
  margin: clamp(26px, 8vh, 96px) auto 0;
  padding: 0;
  overflow: hidden;
  border-radius: 24px;
  box-shadow: 0 24px 65px #183a4c14;
}
.login-intro {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  min-width: 0;
  padding: clamp(28px, 5vw, 58px);
  background: radial-gradient(ellipse at 100% 100%, #14645e, transparent 70%), #112b3c;
  color: #fff;
}
.login-intro p { max-width: 28ch; color: #c3dedf; }
.login-intro h1 { margin: 18px 0 0; }
.login-intro .brand-mark { width: 48px; height: 48px; background: #23585c; }
.login-intro::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: -95px;
  bottom: -175px;
  width: 335px;
  aspect-ratio: 1;
  border: 1px solid #a6ece632;
  border-radius: 28%;
  box-shadow: 0 0 0 24px #a6ece610, 0 0 0 48px #a6ece60b;
  transform: rotate(27deg);
}
#loginForm { align-self: center; min-width: 0; padding: clamp(24px, 5vw, 54px); }
#loginForm h2 { margin-bottom: 20px; }
#loginForm label { display: grid; margin: 0 0 14px; }
#loginForm input, #enter { width: 100%; }
#enter { margin-top: 9px; }
#loginStatus:not(:empty) { margin-top: 12px; color: var(--danger); font-size: 14px; }

#rail {
  position: fixed;
  inset: var(--header-height) auto 0 0;
  z-index: 5;
  width: var(--rail-width);
  padding: 16px 12px;
  overflow: auto;
  overscroll-behavior: contain;
  background: #112b3c;
  color-scheme: dark;
  color: #edf7fb;
}
#rail nav { margin: 0; }
#rail details { margin: 0; padding: 7px 0; }
#rail details + details { border-top: 1px solid #ffffff14; }
#rail summary { padding: 7px 9px; color: #afc5d2; font-size: 13px; }
#rail a {
  display: block;
  padding: 7px 11px 7px 14px;
  border-left: 3px solid transparent;
  border-radius: 8px;
  color: #dceaf1;
  font-size: 14px;
  text-decoration: none;
}
#rail a:hover { background: #ffffff12; }
#rail a[aria-current=page] { border-left-color: #77e1d0; background: #245157; color: white; }
#drawerButton, #drawerClose { display: none; }
#rail #drawerClose { background: #244353; color: white; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(185px, 100%), 1fr)); gap: 12px; }
.metrics article {
  --metric: #087269;
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--metric);
  border-radius: 12px;
  background: var(--surface);
}
.metrics article:nth-child(2) { --metric: #5383c4; }
.metrics article:nth-child(3) { --metric: #b58035; }
.metrics article:nth-child(4) { --metric: #bd657b; }
.metrics article span { color: var(--muted); font-size: 14px; font-weight: 600; }
.metrics strong { display: block; margin: 4px 0; font-size: clamp(20px, 2.1vw, 29px); letter-spacing: -.04em; overflow-wrap: anywhere; }
.metrics small { display: block; }
.pages, .searchbar, #period { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pages { justify-content: flex-end; }
#period { align-items: flex-end; margin: 12px 0 20px; }
#period label, #period button { margin: 0; }
.document-brand { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); margin-bottom: 14px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.document-brand img { max-width: 96px; max-height: 44px; }
#directory li { margin: 8px 0; }
.barrow { display: grid; grid-template-columns: minmax(70px, 1fr) 2fr minmax(85px, 1fr); gap: 10px; align-items: center; padding: 6px 0; }
.barrow strong { text-align: right; }
.barrow meter { width: 100%; height: 16px; accent-color: var(--accent); }

@media (max-width: 760px) {
  header { gap: 6px; padding-inline: 10px; flex-wrap: wrap; }
  header b { flex: 1 1 90px; min-width: 0; font-size: 14px; }
  header button { padding: 7px; margin: 0; font-size: 12px; }
  header .brand-mark { width: 27px; height: 27px; border-radius: 8px; }
  header .brand-mark svg { width: 17px; }
  main { padding: 16px; }
  body.signed main { margin-left: 0; }
  #drawerButton, #drawerClose { display: inline-block; }
  #rail { top: 0; width: min(86vw, 310px); box-shadow: 0 0 0 100vmax #111c2490; }
  #rail:not(.open) { visibility: hidden; }
  body.drawer-open { overflow: hidden; }
  #login { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .login-intro { padding: 24px; }
  .login-intro h1 { font-size: 30px; }
  .login-intro p { margin-bottom: 0; }
  form label, .line label { width: 100%; margin: 4px 0 9px; }
  form label input, form label select { width: 100%; }
  #period label, .searchbar label { width: auto; flex: 1; min-width: 130px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metrics article { padding: 12px; }
  td, th { padding: 8px; }
}
@media (max-width: 340px) {
  .metrics { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  :root, :root[data-theme=sombre] { color-scheme: light; --ink: #000; --surface: white; --muted: #444; --soft: #eee; }
  header, #rail, nav, #notice, #summary, #reviews, #heading, button, .pages, .searchbar { display: none !important; }
  body.signed main { margin: 0; padding: 0; }
  section { border: 0; box-shadow: none; overflow: visible; }
  body { background: white; }
}

