:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --muted: #7b8794;
  --line: #e4e7ec;
  --line-soft: #f0f2f5;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --auto: #15803d;      --auto-bg: #e7f6ec;
  --review: #b45309;    --review-bg: #fdf1dd;
  --confirmed: #1d4ed8; --confirmed-bg: #e6ecfd;
  --corrected: #6d28d9; --corrected-bg: #efe8fd;
  --rejected: #b91c1c;  --rejected-bg: #fdeaea;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* author styles below set display on these elements, so restate the UA rule */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { line-height: 1.3; }

/* --- chrome --------------------------------------------------------------- */

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand__mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
}
.brand__text { font-weight: 600; }
.brand__sub { color: var(--muted); font-weight: 400; }

.nav { display: flex; gap: 4px; }
.nav__link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
}
.nav__link:hover { background: #f1f3f7; }
.nav__link.is-active { background: var(--confirmed-bg); color: var(--accent-dark); }

.page { max-width: 1280px; margin: 0 auto; padding: 22px 24px 64px; }

/* --- blocks --------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.card__title { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.card__title--sep { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.pagetitle { font-size: 19px; font-weight: 600; margin: 0; }

.cardhead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 14px;
}
.cardhead .card__title { margin: 0; font-size: 16px; }
.cardhead--plain { margin: 2px 0 14px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
code { font-family: var(--mono); background: #f1f3f7; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* --- tiles ---------------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid #cfd4dc;
  border-radius: 10px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  transition: border-color .12s, box-shadow .12s;
}
.tile:hover { box-shadow: 0 2px 6px rgba(16, 24, 40, .09); }
.tile__num { display: block; font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile__label { display: block; font-size: 12px; color: var(--muted); }
.tile.is-active { box-shadow: 0 0 0 2px rgba(37, 99, 235, .18); }
.tile--static { cursor: default; }
.tile--auto { border-left-color: var(--auto); }
.tile--review { border-left-color: var(--review); }
.tile--confirmed { border-left-color: var(--confirmed); }
.tile--corrected { border-left-color: var(--corrected); }
.tile--rejected { border-left-color: var(--rejected); }
.tile--auto .tile__num { color: var(--auto); }
.tile--review .tile__num { color: var(--review); }
.tile--confirmed .tile__num { color: var(--confirmed); }
.tile--corrected .tile__num { color: var(--corrected); }
.tile--rejected .tile__num { color: var(--rejected); }

/* --- controls ------------------------------------------------------------- */

.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  padding-bottom: 16px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
}
.filters__item { display: block; }
.filters__item--grow { flex: 1 1 220px; }
.filters__label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.filters__actions { display: flex; gap: 8px; margin-left: auto; }

input, select, .input {
  height: 34px;
  border: 1px solid #d6dae1;
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  width: 100%;
  min-width: 0;
}
select { min-width: 150px; }
input[type="number"] { width: 120px; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-weight: 500;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: #fff; border-color: #d6dae1; color: var(--ink-2); }
.btn--ghost:hover { background: #f7f8fa; }
.btn--ok { background: #fff; border-color: #bfe3c9; color: var(--auto); }
.btn--ok:hover { background: var(--auto-bg); }
.btn--danger { background: #fff; border-color: #f0c7c7; color: var(--rejected); }
.btn--danger:hover { background: var(--rejected-bg); }

/* --- tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.grid td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.grid tbody tr:hover { background: #fafbfc; }
.grid--compact th, .grid--compact td { padding: 7px 10px; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .empty { text-align: center; color: var(--muted); padding: 28px; }
.grid .kv__key { color: var(--ink-2); font-weight: 500; font-size: 13px; white-space: normal; }
.kv .kv__key { width: 34%; }
.plainlist { margin: 0; padding-left: 18px; }

.cell-file { max-width: 340px; }
.cell-name { max-width: 240px; }
.grid--tight { font-size: 12.5px; }
.grid--tight .cell-file { max-width: 190px; }
.grid--tight .filelink { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid--tight td { white-space: nowrap; }
.grid--tight .cell-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.filelink { color: var(--accent); text-decoration: none; font-weight: 500; }
.filelink:hover { text-decoration: underline; }
.cell-file .small { display: block; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge--auto { background: var(--auto-bg); color: var(--auto); }
.badge--review { background: var(--review-bg); color: var(--review); }
.badge--confirmed { background: var(--confirmed-bg); color: var(--confirmed); }
.badge--corrected { background: var(--corrected-bg); color: var(--corrected); }
.badge--rejected { background: var(--rejected-bg); color: var(--rejected); }

.pill {
  display: inline-block; min-width: 24px; padding: 2px 7px; border-radius: 999px;
  font-size: 12px; font-weight: 500; text-align: center;
}
.pill--error { background: var(--rejected-bg); color: var(--rejected); }
.pill--warn { background: var(--review-bg); color: var(--review); }

/* --- document card -------------------------------------------------------- */

.dochead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.back { font-size: 12.5px; color: var(--accent); text-decoration: none; }
.back:hover { text-decoration: underline; }
.dochead__title { font-size: 19px; font-weight: 600; margin: 6px 0 8px; word-break: break-word; }
.dochead__meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dochead__pos {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #f1f3f7; color: var(--ink-2); }
.chip--quiet { background: #fff; border: 1px solid var(--line); color: var(--muted); }

.doclayout {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(440px, 540px);
  gap: 16px;
  align-items: start;
}
@media (max-width: 1080px) { .doclayout { grid-template-columns: 1fr; } }

.viewer { position: sticky; top: 76px; }
.viewer__bar {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.viewer__title { font-size: 12px; color: var(--muted); }
.viewer__bar .muted { margin-left: auto; }
.viewer__body { max-height: calc(100vh - 190px); overflow: auto; border-radius: 8px; }
.pagebtns { display: flex; gap: 6px; }
.pagebtn {
  width: 30px; height: 30px; padding: 0;
  border: 1px solid #d6dae1; border-radius: 7px;
  background: #fff; color: var(--ink-2); font: inherit; cursor: pointer;
}
.pagebtn:hover { background: #f7f8fa; }
.pagebtn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pageimg { display: block; width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.noimg {
  padding: 64px 20px; text-align: center; color: var(--muted);
  background: #fafbfc; border: 1px dashed #d6dae1; border-radius: 8px;
}

.rightcol { min-width: 0; }

.issues__list { list-style: none; margin: 0; padding: 0; }
.issue { display: flex; gap: 9px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.issue:last-child { border-bottom: none; padding-bottom: 0; }
.issue__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.issue--error .issue__dot { background: #dc2626; }
.issue--warning .issue__dot { background: #d97706; }
.issue__body { flex: 1; min-width: 0; }
.issue__code { margin-top: 2px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.issues--clean { color: var(--auto); font-size: 13.5px; }

.field { padding: 9px 0; border-bottom: 1px dashed #eef0f3; }
.field:first-of-type { padding-top: 0; }
.field__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.field__label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.req { color: #dc2626; margin-left: 3px; }
.field__row { display: flex; align-items: center; gap: 8px; }
.field__was { margin-top: 4px; font-size: 11.5px; color: var(--corrected); }
.snippet {
  margin-top: 5px; font-family: var(--mono); font-size: 11px; line-height: 1.5;
  color: var(--muted); word-break: break-word;
}
.field--error .input { border-color: #dc2626; background: #fffbfb; }
.field--warning .input { border-color: #d97706; background: #fffdf7; }
.field--error .field__label, .field--warning .field__label { color: var(--ink); }

.conf { font-size: 11.5px; padding: 2px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.conf--high { background: var(--auto-bg); color: var(--auto); }
.conf--mid { background: var(--review-bg); color: var(--review); }
.conf--low { background: var(--rejected-bg); color: var(--rejected); }
.conf--none { background: #f1f3f7; color: var(--muted); }

.pagelink { font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.pagelink:hover { text-decoration: underline; }
.pagelink--off { color: #c3c9d2; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.empty-card { text-align: left; }
.field--note { border-bottom: none; padding-top: 14px; }
