:root {
  color-scheme: light dark;
  --ch-bg: light-dark(#f5f6f3, #171c19);
  --ch-paper: light-dark(#ffffff, #222a25);
  --ch-text: light-dark(#263c31, #e5eee8);
  --ch-muted: light-dark(#65736a, #abb9af);
  --ch-line: light-dark(#dce3dd, #39483e);
  --ch-soft: light-dark(#eaf0e9, #2d3b30);
  --ch-action: light-dark(#27583d, #b6d7bd);
  --ch-on: light-dark(#ffffff, #1c3122);
  --ch-warn: light-dark(#fbf2dc, #433c27);
  --ch-warntext: light-dark(#76571c, #e9d49c);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ch-text);
  background: var(--ch-bg);
}

a { color: var(--ch-action); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
strong { font-weight: 600; }

:focus-visible {
  outline: 2px solid var(--ch-action);
  outline-offset: 3px;
}

.ch-skip {
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 1;
  padding: 10px 14px;
  background: var(--ch-paper);
  border-radius: 7px;
  transform: translateY(-160%);
}

.ch-skip:focus { transform: translateY(0); }

.ch-top {
  display: flex;
  align-items: center;
  min-height: 84px;
  padding: 16px 24px;
  background: var(--ch-paper);
  border-bottom: 1px solid var(--ch-line);
}

.ch-brand { color: var(--ch-text); text-decoration: none; }
.ch-brand strong { display: block; font-size: 21px; letter-spacing: -.5px; }
.ch-brand span { display: block; color: var(--ch-muted); font-size: 12px; }

.ch-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: calc(100svh - 84px);
}

.ch-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 24px 16px;
  background: var(--ch-paper);
  border-right: 1px solid var(--ch-line);
}

.ch-menu-label {
  padding: 0 10px;
  font-size: 11px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--ch-muted);
}

.ch-section-label { margin-top: 24px; }
.ch-sidebar nav { display: grid; gap: 3px; }

.ch-sidebar nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 7px;
  color: var(--ch-text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.ch-sidebar nav a[aria-current="page"] {
  background: var(--ch-soft);
  font-weight: 600;
}

.ch-sidebar nav a:hover { background: var(--ch-soft); }
.ch-nav-empty { padding: 10px; font-size: 12px; }

.ch-user {
  margin-top: auto;
  padding: 22px 10px 0;
  border-top: 1px solid var(--ch-line);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ch-user span { display: block; margin-top: 4px; font-size: 12px; color: var(--ch-muted); }
.ch-user form { margin: 0; }

.ch-logout {
  min-height: 44px;
  max-width: 100%;
  padding: 12px 0;
  background: transparent;
  border: 0;
  color: var(--ch-muted);
  text-align: left;
}

.ch-logout:hover { color: var(--ch-action); }
.ch-main { min-width: 0; padding: 26px; overflow-wrap: anywhere; }
.ch-heading { margin-bottom: 24px; }
h1 { margin: 0 0 8px; font-size: 25px; font-weight: 600; line-height: 1.2; letter-spacing: -.6px; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
p { margin: 0 0 18px; color: var(--ch-muted); }
.ch-sub { font-size: 12px; color: var(--ch-muted); }
.ch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ch-box { min-width: 0; margin-top: 14px; padding: 18px; background: var(--ch-paper); border: 1px solid var(--ch-line); border-radius: 10px; }
.ch-empty { margin: 14px 0 0; }
.ch-listrow { padding: 14px 0 0; }
.ch-listrow p { margin: 4px 0 0; }
.ch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.ch-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.ch-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-left: auto; }

.ch-btn {
  display: inline-block;
  max-width: 100%;
  padding: 9px 13px;
  background: var(--ch-paper);
  border: 1px solid var(--ch-line);
  border-radius: 7px;
  color: var(--ch-text);
  text-decoration: none;
  text-align: center;
  white-space: normal;
}

.ch-btn:hover { background: var(--ch-soft); }
.ch-primary, .ch-primary:hover { background: var(--ch-action); border-color: var(--ch-action); color: var(--ch-on); }
.ch-pill { display: inline-block; padding: 4px 7px; border-radius: 5px; background: var(--ch-soft); font-size: 11px; }
.ch-pill.warn, .ch-alert { background: var(--ch-warn); color: var(--ch-warntext); }
.ch-alert { margin-bottom: 24px; padding: 14px 16px; border-radius: 8px; }
.ch-doc-scroll { max-width: 100%; overflow-x: auto; }
.ch-doc-table { width: 100%; min-width: 450px; border-collapse: collapse; text-align: left; font-size: 13px; }
.ch-doc-table th { font-weight: 500; color: var(--ch-muted); font-size: 12px; }
.ch-doc-table td, .ch-doc-table th { padding: 14px 10px; border-bottom: 1px solid var(--ch-line); vertical-align: top; }
.ch-doc-table th:first-child, .ch-doc-table td:first-child { padding-left: 0; }
.ch-number { font-variant-numeric: tabular-nums; }
.ch-panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.ch-journal-meta { display: block; margin-top: 5px; color: var(--ch-muted); font-size: 12px; }
.ch-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.ch-doc-scroll:focus-visible, .ch-table-frame:focus-visible { outline: 2px solid var(--ch-action); outline-offset: 3px; }

@media (max-width: 680px) {
  .ch-row > .ch-heading-actions { flex-basis: 100%; justify-content: flex-start; margin-left: 0; }
}

.ch-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; margin-top: 18px; }
.ch-field { min-width: 0; margin-top: 14px; }
.ch-fields .ch-field { margin-top: 0; }
.ch-field label { display: block; margin-bottom: 6px; color: var(--ch-muted); font-size: 12px; }
.ch-field input, .ch-field select, .ch-field textarea, .ch-sections input:not([type="checkbox"]):not([type="hidden"]) {
  width: 100%; min-width: 0; min-height: 44px; padding: 9px 10px;
  border: 1px solid var(--ch-line); border-radius: 6px; background: var(--ch-bg);
}
.ch-field textarea { resize: vertical; }
.ch-consent { margin-top: 16px; }
.ch-consent input, .ch-sections input[type="checkbox"] { width: 20px; height: 20px; vertical-align: middle; accent-color: var(--ch-action); }
.ch-consent label { margin-left: 8px; }
.ch-sections { min-width: 1080px; }
.ch-sections th, .ch-sections td { min-width: 140px; }
.ch-sections th:first-child, .ch-sections td:first-child { min-width: 60px; }
.ch-sections th:last-child, .ch-sections td:last-child { min-width: 80px; }
.ch-deleted td:not(:last-child), .ch-deleted th { opacity: .45; }
.ch-totals { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 18px; }
.ch-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.ch-details dt { font-size: 12px; color: var(--ch-muted); }
.ch-details dd { margin: 4px 0 0; }
.ch-comment { margin: 14px 0 0; white-space: pre-wrap; }
.ch-duplicates { margin-top: 18px; }
.errorlist { padding-left: 18px; margin: 6px 0 0; color: var(--ch-warntext); font-size: 12px; }
[aria-invalid="true"] { border-color: var(--ch-warntext) !important; }
.ch-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.ch-login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 32px 20px;
}

.ch-login { width: min(100%, 368px); }
.ch-login h1 {
  margin: 0;
  font-size: clamp(3rem, 10vw, 3.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.055em;
  text-align: center;
}

.ch-login h1 span { color: light-dark(#bd821d, #f7b846); }
.ch-login-cheese { display: block; width: 112px; margin: 0 auto 12px; }
.ch-login-description { margin: 12px 0 26px; font-size: 15px; text-align: center; }
.ch-login .ch-login-form { margin: 0; padding: clamp(18px, 6vw, 30px); border-radius: 16px; }
.ch-login-form h2 { margin-bottom: 22px; font-size: 20px; }
.ch-login-form .ch-alert { margin: 14px 0 0; }
.ch-login-form .ch-field { margin-top: 18px; }
.ch-login-form .ch-field label { color: var(--ch-text); font-size: 13px; font-weight: 600; }
.ch-login-form .ch-field input { font-size: 16px; }
.ch-login-form .ch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin-top: 24px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .ch-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .ch-shell { grid-template-columns: 170px minmax(0, 1fr); }
  .ch-top { padding: 16px 18px; }
  .ch-sidebar { padding: 20px 10px; }
  .ch-sidebar nav a { font-size: 13px; }
  .ch-user { padding: 18px 8px 0; }
  .ch-main { padding: 20px; }
}

@media (max-width: 480px) {
  .ch-shell { grid-template-columns: 120px minmax(0, 1fr); }
  .ch-sidebar { padding: 16px 5px; }
  .ch-sidebar nav a { padding: 10px 6px; font-size: 12px; }
  .ch-menu-label { padding: 0 6px; font-size: 11px; letter-spacing: 0; }
  .ch-nav-empty { padding: 10px 6px; }
  .ch-user { padding: 16px 6px 0; font-size: 12px; }
  .ch-main { padding: 14px 10px; }
  .ch-box { padding: 12px; }
  .ch-alert { padding: 12px; }
  .ch-btn { padding: 8px; }
  h1 { font-size: 20px; }
}

.ch-journal .ch-journal-meta { display: block; margin-top: 4px; }
.ch-journal .ch-page-number { align-self: center; color: var(--ch-muted); }

.ch-journal .ch-doc-table { min-width: 680px; }
.ch-journal td:first-child > a, .ch-journal td.ch-number { white-space: nowrap; }
