/* Quanterra Regulation Assistant
   Design idea: the official regulation text is set like the printed UN document
   (serif, paragraph number hanging in the margin); everything around it is a quiet,
   precise engineering tool in one sans-serif. Approval blue for actions, a highlighter
   yellow reserved for "changed" and "simple explanation". */

:root {
  --paper: #eef1f0;        /* cool drawing-film grey */
  --surface: #ffffff;
  --ink: #17202b;
  --ink-2: #4a5663;
  --ink-3: #75808b;
  --rule: #d3d9d6;
  --rule-strong: #b7c0bc;
  --blue: #1d4f91;         /* approval-mark blue: links and main actions */
  --blue-dark: #153b6d;
  --blue-soft: #e5ecf6;
  --yellow: #ffe27a;       /* highlighter: explanations and changes */
  --yellow-soft: #fff6d1;
  --green: #2c7a4b;
  --green-soft: #e3f1e8;
  --orange: #a8570a;
  --orange-soft: #fbeedd;
  --red: #a32b2b;
  --red-soft: #f8e4e4;

  --sans: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;

  --r-s: 3px;              /* chips and tags */
  --r-m: 6px;              /* inputs, buttons, boxes */
  --r-l: 10px;             /* cards and dialogs */
  --topbar: 58px;
  --sidenav: 214px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  font-feature-settings: 'tnum' 0;
}
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--blue-dark); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 0.6em; }
code { font-size: 0.9em; background: var(--blue-soft); padding: 1px 4px; border-radius: var(--r-s); }
abbr { text-decoration: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 0.9rem; }

/* ---------------------------------------------------------------- boot and messages */
.boot { max-width: 560px; margin: 18vh auto; padding: 0 24px; color: var(--ink-2); font-family: var(--sans); }
.boot-error h1 { color: var(--ink); margin-bottom: 0.6rem; }
.loading { padding: 32px 0; color: var(--ink-2); }
.error-box { background: var(--red-soft); border: 1px solid #e6bcbc; border-radius: var(--r-m); padding: 14px 16px; margin: 16px 0; }
.error-box p { color: var(--red); }
.empty { border: 1px dashed var(--rule-strong); border-radius: var(--r-l); padding: 28px; text-align: center; color: var(--ink-2); background: rgba(255,255,255,0.5); }
.empty-title { font-weight: 600; color: var(--ink); }
.note { background: var(--yellow-soft); border-radius: var(--r-m); padding: 8px 12px; font-size: 0.9rem; }
.form-error { color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: var(--r-m); font-size: 0.9rem; }

/* ---------------------------------------------------------------- buttons and fields */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 0.92rem/1 var(--sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-m);
  padding: 9px 14px; cursor: pointer;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.is-on { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-dark); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-block { width: 100%; justify-content: center; padding: 11px 14px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn.danger { color: var(--red); }
.icon-btn { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--ink-2); cursor: pointer; padding: 4px 8px; border-radius: var(--r-m); }
.icon-btn:hover { background: var(--paper); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 0.85rem; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 0.8rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: var(--r-m); padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.field-compact select { padding: 6px 8px; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--ink-2); }
.inline-field select { width: auto; padding: 6px 8px; }
.inline-field input[type=checkbox] { width: auto; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 34px; height: 20px; border-radius: 10px; background: var(--rule-strong); position: relative; transition: background 0.15s; flex: none; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--blue); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------------------------------------------------------------- sign-in screens */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 12px; color: var(--blue); font-weight: 600; margin-bottom: 28px; }
.auth-brand span { color: var(--ink); }
.auth-card h1 { font-size: 1.4rem; margin-bottom: 18px; }
.auth-links { margin-top: 16px; font-size: 0.9rem; }
.auth-foot { margin-top: 18px; color: var(--ink-3); font-size: 0.85rem; }

/* ---------------------------------------------------------------- frame */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--blue); text-decoration: none; font-weight: 600; width: calc(var(--sidenav) - 20px); flex: none; }
.brand span { color: var(--ink); font-size: 0.95rem; line-height: 1.15; }
.top-search { flex: 1; max-width: 520px; }
.top-search input { background: var(--paper); border-color: transparent; }
.project-picker { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--ink-2); margin-left: auto; }
.project-picker select { width: auto; min-width: 150px; padding: 6px 8px; }
.user { position: relative; }
.user-btn { display: flex; flex-direction: column; align-items: flex-end; background: none; border: 0; cursor: pointer; font: inherit; padding: 4px 6px; border-radius: var(--r-m); }
.user-btn:hover { background: var(--paper); }
.user-name { font-weight: 500; font-size: 0.9rem; }
.user-role { font-size: 0.75rem; color: var(--ink-3); text-transform: capitalize; }
.user-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m); min-width: 170px; padding: 6px; box-shadow: 0 8px 24px rgba(23, 32, 43, 0.12); }
.user-menu a, .user-menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; font: inherit; color: var(--ink); text-decoration: none; border-radius: var(--r-s); cursor: pointer; }
.user-menu a:hover, .user-menu button:hover { background: var(--paper); }

.sidenav {
  position: fixed; top: var(--topbar); left: 0; bottom: 0; width: var(--sidenav);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 2px;
  border-right: 1px solid var(--rule); background: var(--paper);
}
.sidenav a { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: var(--r-m); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 0.93rem; }
.sidenav a:hover { background: rgba(255,255,255,0.7); color: var(--ink); }
.sidenav a.is-active { background: var(--surface); color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.count-pill { background: var(--blue); color: #fff; font-size: 0.75rem; border-radius: 9px; padding: 1px 7px; }
.content { margin-left: var(--sidenav); padding: 28px 36px 64px; }

.page { max-width: 900px; }
.page-wide { max-width: 1280px; }
.page-narrow { max-width: 620px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { margin-bottom: 6px; }
.lead { font-size: 1.05rem; color: var(--ink-2); max-width: 70ch; }
.official { font-family: var(--serif); font-style: italic; color: var(--ink-2); max-width: 75ch; }
.crumbs { display: flex; gap: 8px; font-size: 0.85rem; color: var(--ink-3); margin-bottom: 14px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-2); }
.count { font-size: 0.85rem; color: var(--ink-3); }
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 14px 0; }
.toolbar .count { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--r-m); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; font: 500 0.88rem var(--sans); padding: 7px 12px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button.is-on { background: var(--blue-soft); color: var(--blue-dark); }

/* ---------------------------------------------------------------- tags */
.cats { display: inline-flex; gap: 4px; flex-wrap: wrap; vertical-align: middle; }
.cat { font-size: 0.75rem; font-weight: 600; padding: 1px 5px; border: 1px solid var(--rule-strong); border-radius: var(--r-s); color: var(--ink-2); background: var(--surface); cursor: help; }
.type, .impact, .stage, .status, .badge-unreviewed, .method {
  display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 7px; border-radius: var(--r-s); white-space: nowrap;
}
.type-design { background: var(--blue-soft); color: var(--blue-dark); }
.type-test { background: #e7e3f4; color: #4a3a86; }
.type-information { background: var(--paper); color: var(--ink-2); border: 1px solid var(--rule); }
.impact-high { background: var(--red-soft); color: var(--red); }
.impact-medium { background: var(--orange-soft); color: var(--orange); }
.impact-low { background: var(--green-soft); color: var(--green); }
.stage, .status, .method { background: var(--paper); color: var(--ink-2); border: 1px solid var(--rule); }
.badge-unreviewed { background: #ececec; color: #555; border: 1px dashed #9a9a9a; }

/* ---------------------------------------------------------------- regulations list */
.reg-list { display: flex; flex-direction: column; gap: 14px; }
.reg-card {
  display: grid; grid-template-columns: 110px 1fr 200px; gap: 24px; align-items: center;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l);
  padding: 22px 26px; color: var(--ink); text-decoration: none;
}
.reg-card:hover { border-color: var(--blue); }
.reg-no { font-family: var(--serif); font-size: 3.4rem; line-height: 1; font-weight: 600; color: var(--blue); display: flex; flex-direction: column; }
.reg-no span { font-family: var(--sans); font-size: 0.8rem; font-weight: 500; color: var(--ink-3); margin-bottom: 4px; }
.reg-card h2 { font-size: 1.15rem; margin-bottom: 4px; }
.reg-short { color: var(--ink-2); margin-bottom: 10px; }
.facts { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; }
.facts > div { display: flex; gap: 10px; }
.facts dt { color: var(--ink-3); min-width: 140px; flex: none; }
.facts dd { margin: 0; }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px 32px; }
.reg-progress { font-size: 0.82rem; color: var(--ink-2); }
.bar { height: 6px; background: var(--paper); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.bar span { display: block; height: 100%; background: var(--green); }

/* ---------------------------------------------------------------- regulation page */
.reg-facts { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); padding: 20px 24px; margin-bottom: 28px; }
.reg-facts > * + * { margin-top: 16px; }
.scope h2 { font-size: 0.95rem; margin-bottom: 4px; }
.scope p { max-width: 80ch; }
.verbatim-inline { font-family: var(--serif); }
.legend summary { cursor: pointer; color: var(--blue); font-size: 0.9rem; }
.legend dl { margin: 10px 0 0; display: grid; gap: 4px; font-size: 0.88rem; }
.legend dl div { display: flex; gap: 10px; }
.legend dt { font-weight: 600; min-width: 32px; }
.legend dd { margin: 0; color: var(--ink-2); }
.plain-list { margin: 0; padding-left: 20px; }
.plain-list li + li { margin-top: 4px; }

.reg-layout { display: grid; grid-template-columns: 260px 1fr; gap: 32px; align-items: start; }
.toc { position: sticky; top: calc(var(--topbar) + 20px); max-height: calc(100vh - var(--topbar) - 40px); overflow: auto; padding-right: 8px; }
.toc h2 { font-size: 0.85rem; color: var(--ink-3); font-weight: 500; margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc-groups { display: flex; flex-direction: column; gap: 4px; }
.toc-group-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m);
  font: 600 0.92rem/1.3 var(--sans); color: var(--ink); padding: 9px 12px; cursor: pointer;
}
.toc-group-btn:hover { border-color: var(--rule-strong); }
.toc-group.is-open > .toc-group-btn { border-color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.toc-group-label { flex: 1; }
.toc-count { font: 500 0.75rem var(--sans); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.toc-chev { width: 16px; text-align: center; color: var(--ink-2); font-weight: 500; }
.toc-sub { padding: 4px 0 6px; }
.toc-sub .toc-sub { padding: 2px 0 2px 16px; }
.toc-row { display: flex; align-items: flex-start; gap: 2px; }
.toc-exp, .toc-exp-space { flex: none; width: 20px; height: 22px; margin-top: 1px; }
.toc-exp { border: 0; background: none; color: var(--ink-2); cursor: pointer; border-radius: var(--r-s); font: 500 0.95rem var(--sans); padding: 0; }
.toc-exp:hover { background: var(--surface); color: var(--ink); }
.toc-link { display: block; width: 100%; text-align: left; background: none; border: 0; font: 400 0.84rem/1.35 var(--sans); color: var(--ink-2); padding: 3px 6px; border-radius: var(--r-s); cursor: pointer; }
.toc-link:hover { background: var(--surface); color: var(--ink); }
.toc-no { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

.item-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); overflow: hidden; }
.sec-head { padding: 18px 20px 8px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; border-top: 1px solid var(--rule); scroll-margin-top: calc(var(--topbar) + 12px); }
.sec-head:first-child { border-top: 0; }
.sec-no { color: var(--blue); font-variant-numeric: tabular-nums; }
.sec-intro { flex-basis: 100%; font-weight: 400; font-family: var(--serif); color: var(--ink-2); font-size: 0.92rem; margin: 2px 0 0; }
.item-row a { display: grid; grid-template-columns: 92px 1fr; gap: 14px; padding: 10px 20px; color: var(--ink); text-decoration: none; border-top: 1px solid #edf0ef; }
.item-row a:hover { background: #f7f9fb; }
.item-no { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); padding-top: 1px; font-size: 0.9rem; overflow-wrap: anywhere; }
.item-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.item-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.item-preview { color: var(--ink-2); font-size: 0.92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------------------------------------------------------------- search and filters */
.search-row { display: flex; gap: 10px; }
.search-row input { font-size: 1rem; padding: 10px 12px; }
.filter-panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); padding: 18px 20px; margin-bottom: 12px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.filter-switches { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 14px; }
.filter-actions { margin-top: 12px; font-size: 0.88rem; }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.fchip { display: inline-flex; align-items: center; gap: 4px; background: var(--blue-soft); color: var(--blue-dark); font-size: 0.84rem; padding: 3px 4px 3px 10px; border-radius: var(--r-s); }
.fchip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 6px; }
.result-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.result { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m); padding: 12px 16px; color: var(--ink); text-decoration: none; }
.result:hover { border-color: var(--blue); }
.result-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.result-where { font-weight: 600; margin-right: 4px; }
.result-sec { font-size: 0.85rem; color: var(--ink-3); }
.result-preview { color: var(--ink-2); font-size: 0.92rem; }
.result-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 0.8rem; color: var(--ink-3); }

/* ---------------------------------------------------------------- requirement page */
.req-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.req-main { min-width: 0; }
.req-head { margin-bottom: 20px; }
.req-title { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 12px; }
.req-no { font-family: var(--serif); font-weight: 600; font-size: 2.1rem; line-height: 1; color: var(--blue); padding-top: 2px; white-space: nowrap; }
.req-title h1 { font-size: 1.45rem; }
.req-id { color: var(--ink-3); font-size: 0.88rem; margin: 4px 0 0; }
.req-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.block { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); padding: 20px 24px; margin-bottom: 16px; }
.block-title { font-size: 0.9rem; color: var(--ink-3); font-weight: 500; margin-bottom: 10px; }
.block-note { background: var(--yellow-soft); border-color: #f0dc95; }

/* The signature element: the regulation text as in the official document */
.verbatim { display: grid; grid-template-columns: 76px 1fr; gap: 14px; }
.verbatim-no { font-family: var(--serif); font-weight: 600; color: var(--ink-2); text-align: right; padding-top: 2px; overflow-wrap: anywhere; }
.verbatim-text { font-family: var(--serif); font-size: 1.04rem; line-height: 1.7; white-space: pre-wrap; max-width: 72ch; }
.verbatim-small { grid-template-columns: 1fr; }
.verbatim-small .verbatim-text { font-size: 0.95rem; }
.footnotes { margin: 14px 0 0 90px; padding-left: 18px; font-family: var(--serif); font-size: 0.85rem; color: var(--ink-2); }
.btn-explain { margin: 18px 0 0 90px; }
.simple { margin: 12px 0 0 90px; background: var(--yellow-soft); border-left: 4px solid var(--yellow); padding: 14px 18px; border-radius: 0 var(--r-m) var(--r-m) 0; max-width: 72ch; }
.simple p:last-child { margin-bottom: 0; }
.simple-note { font-size: 0.8rem; color: var(--ink-3); margin-top: 8px; }
.simple-inline { background: var(--yellow-soft); padding: 8px 12px; border-radius: var(--r-m); font-size: 0.92rem; }

.table-wrap { overflow-x: auto; }
.values { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.values th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 0.8rem; padding: 6px 10px; border-bottom: 1px solid var(--rule-strong); }
.values td { padding: 8px 10px; border-bottom: 1px solid #edf0ef; vertical-align: top; }
.values td:nth-child(2) { font-variant-numeric: tabular-nums; font-weight: 500; }

.refs { display: flex; flex-direction: column; gap: 8px; }
.ref { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--r-m); }
.ref-kind { font-size: 0.72rem; font-weight: 600; color: var(--ink-3); border: 1px solid var(--rule); border-radius: var(--r-s); padding: 1px 6px; background: var(--paper); }
.collapsible { border: 1px solid var(--rule); border-radius: var(--r-m); }
.collapsible.is-open { border-color: var(--rule-strong); }
.collapsible-head { display: flex; width: 100%; align-items: center; gap: 10px; background: none; border: 0; font: inherit; text-align: left; padding: 8px 12px; cursor: pointer; }
.collapsible-head:hover { background: #f7f9fb; }
.chev { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--rule-strong); border-radius: var(--r-s); font-size: 0.85rem; color: var(--ink-2); flex: none; }
.collapsible-title { flex: 1; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.collapsible-meta { font-size: 0.8rem; color: var(--ink-3); }
.collapsible-body { padding: 4px 14px 14px 40px; }
.collapsible-body > * + * { margin-top: 10px; }

.req-side { position: sticky; top: calc(var(--topbar) + 20px); display: flex; flex-direction: column; gap: 12px; }
.side-box { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); padding: 16px 18px; }
.side-box h2 { font-size: 0.85rem; color: var(--ink-3); font-weight: 500; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 0.84rem; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-s); padding: 2px 2px 2px 8px; }
.chip-proposed { border-style: dashed; border-color: var(--ink-3); background: var(--surface); }
.chip-x { border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 1rem; line-height: 1; padding: 0 5px; border-radius: var(--r-s); }
.chip-x:hover { color: var(--red); background: var(--red-soft); }
.chip-btn { border: 0; background: var(--blue-soft); color: var(--blue-dark); font: 500 0.75rem var(--sans); border-radius: var(--r-s); padding: 2px 6px; cursor: pointer; }
.chip-add { border: 1px dashed var(--rule-strong); background: none; color: var(--blue); font: 500 0.84rem var(--sans); padding: 2px 8px; border-radius: var(--r-s); cursor: pointer; }
.chip-add:hover { border-color: var(--blue); }
.new-name { background: var(--yellow-soft); padding: 10px 12px; border-radius: var(--r-m); }

.timeline-head { display: flex; justify-content: space-between; align-items: baseline; }
.comment-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; margin-bottom: 18px; }
.entries { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--rule); }
.entry { position: relative; padding: 0 0 16px 18px; }
.entry::before { content: ''; position: absolute; left: -6px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--rule-strong); }
.entry-comment::before { background: var(--blue); border-color: var(--blue); }
.entry-approved::before { background: var(--green); border-color: var(--green); }
.entry-sent_back::before, .entry-comment_deleted::before { background: var(--orange); border-color: var(--orange); }
.entry-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 0.85rem; }
.entry-type { font-weight: 600; }
.entry-who { color: var(--ink-2); }
.entry-when { color: var(--ink-3); }
.entry-text { margin: 4px 0 0; white-space: pre-wrap; max-width: 75ch; }
.entry-comment .entry-text { background: var(--paper); padding: 8px 12px; border-radius: var(--r-m); }
.entry-reason { margin: 4px 0 0; font-size: 0.9rem; color: var(--ink-2); }
.entry-reason span { font-weight: 600; }

/* ---------------------------------------------------------------- dialogs and toasts */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23, 32, 43, 0.35); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: var(--r-l); width: 100%; max-width: 480px; padding: 20px 22px 22px; box-shadow: 0 20px 50px rgba(23, 32, 43, 0.25); }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-m); font-size: 0.9rem; max-width: 380px; box-shadow: 0 8px 24px rgba(23, 32, 43, 0.25); }
.toast-error { background: var(--red); }

/* ---------------------------------------------------------------- smaller laptop screens */
@media (max-width: 1180px) {
  .req-layout { grid-template-columns: 1fr; }
  .req-side { position: static; }
  .reg-card { grid-template-columns: 90px 1fr; }
  .reg-progress { grid-column: 2; }
}
@media (max-width: 980px) {
  .reg-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: 260px; }
  .project-picker span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- version 2: review */
.form-error { white-space: pre-line; }
.embedded .req-layout-embedded { grid-template-columns: 1fr; }
.embedded .req-side { position: static; flex-direction: row; flex-wrap: wrap; }
.embedded .req-side .side-box { flex: 1 1 220px; }

.review-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); padding: 12px 16px; margin-bottom: 16px; }
.review-state { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.review-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.state { font-size: 0.8rem; font-weight: 600; padding: 3px 9px; border-radius: var(--r-s); }
.state-draft { background: var(--paper); color: var(--ink-2); border: 1px solid var(--rule-strong); }
.state-in_review { background: var(--blue-soft); color: var(--blue-dark); }
.state-approved { background: var(--green-soft); color: var(--green); }
.stuck { font-size: 0.75rem; font-weight: 600; padding: 2px 7px; border-radius: var(--r-s); background: var(--orange-soft); color: var(--orange); }

.changed-banner { background: var(--yellow-soft); border: 1px solid #efd680; border-left: 4px solid var(--yellow); border-radius: var(--r-m); padding: 10px 14px; margin-bottom: 14px; font-size: 0.92rem; }
.changed { background: var(--yellow-soft); box-shadow: 0 0 0 6px var(--yellow-soft); border-radius: var(--r-s); margin: 8px 0; }
.changed-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 4px; }
.changed-label { font-size: 0.72rem; font-weight: 600; background: var(--yellow); color: var(--ink); padding: 1px 6px; border-radius: var(--r-s); }
.changed-compare { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #e2c65e; display: flex; flex-direction: column; gap: 10px; }
.req-tags.is-changed { background: var(--yellow-soft); box-shadow: 0 0 0 6px var(--yellow-soft); border-radius: var(--r-s); }
.diff { white-space: pre-wrap; font-size: 0.92rem; line-height: 1.6; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m); padding: 8px 12px; }
.diff del { color: var(--red); background: var(--red-soft); text-decoration: line-through; }
.diff ins { color: var(--green); background: var(--green-soft); text-decoration: none; font-weight: 500; }
.diff-old { text-decoration: line-through; color: var(--red); }
.diff-new { color: var(--green); }
.entry-changes { margin-top: 6px; }
.entry-change { margin-top: 8px; }

.edit-form textarea { font-size: 0.95rem; }
.edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.cat-picker { border: 0; padding: 0; margin: 0; }
.cat-picker legend { font-size: 0.85rem; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.cat-options { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.cat-options label { display: inline-flex; align-items: center; gap: 5px; font-size: 0.9rem; cursor: pointer; }
.cat-options input { width: auto; }
.modal { max-height: 86vh; overflow: auto; }
.modal-backdrop { padding-top: 6vh; }

.review-page { max-width: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule-strong); margin-bottom: 4px; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; font: 500 0.95rem var(--sans); color: var(--ink-2); padding: 10px 14px 9px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--blue); border-bottom-color: var(--blue); }
.tab-count { font-size: 0.75rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 9px; padding: 0 7px; color: var(--ink-2); }
.tab.is-on .tab-count { background: var(--blue); border-color: var(--blue); color: #fff; }
.filter-panel-wrap .search-row-small { margin-bottom: 10px; }
.search-row-small input { font-size: 0.92rem; padding: 7px 10px; }
.filter-chips-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-chips-row .filter-chips { margin-bottom: 0; }
.filter-chips-row:not(:empty) { margin-bottom: 12px; }

.split { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 20px; align-items: start; }
.queue { position: sticky; top: calc(var(--topbar) + 16px); max-height: calc(100vh - var(--topbar) - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); }
.queue .empty { border: 0; }
.queue-head { position: sticky; top: 0; background: var(--surface); padding: 10px 14px; border-bottom: 1px solid var(--rule); z-index: 1; }
.queue-list { list-style: none; margin: 0; padding: 0; }
.q-row { display: grid; grid-template-columns: 22px 1fr; gap: 6px; padding: 10px 12px 10px 14px; border-bottom: 1px solid #edf0ef; }
.q-row input { width: auto; margin-top: 3px; }
.q-row.is-current { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.q-row.is-selected:not(.is-current) { background: #f5f8fc; }
.q-main { display: flex; flex-direction: column; gap: 4px; text-align: left; background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; min-width: 0; }
.q-top { display: flex; gap: 8px; align-items: baseline; }
.q-no { font-weight: 600; font-variant-numeric: tabular-nums; }
.q-reg { font-size: 0.8rem; color: var(--ink-3); }
.q-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.q-flag { font-size: 0.72rem; color: var(--ink-2); border: 1px solid var(--rule-strong); border-radius: var(--r-s); padding: 1px 6px; }
.changed-pill { font-size: 0.72rem; font-weight: 600; background: var(--yellow); border-radius: var(--r-s); padding: 1px 6px; }
.q-preview { font-size: 0.86rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q-meta { font-size: 0.78rem; color: var(--ink-3); }
.panel { min-width: 0; }
.panel-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-open { margin-left: auto; }
.action-bar { position: fixed; left: calc(var(--sidenav) + 36px); right: 36px; bottom: 20px; z-index: 30;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--ink); color: #fff; border-radius: var(--r-l); padding: 10px 14px; box-shadow: 0 12px 32px rgba(23, 32, 43, 0.3); }
.action-bar .btn:not(.btn-primary) { background: transparent; color: #fff; border-color: rgba(255,255,255,0.4); }
.action-bar .link-btn { color: #cfd9e6; margin-left: auto; }
.action-count { font-weight: 600; margin-right: 6px; }
.problem-list { margin: 0 0 14px; padding-left: 18px; max-height: 50vh; overflow: auto; font-size: 0.92rem; }
.problem-list li + li { margin-top: 4px; }
@media (max-width: 1180px) { .split { grid-template-columns: 1fr; } .queue { position: static; max-height: 45vh; } }

/* ---------------------------------------------------------------- design stage / impact order */
.picker { position: relative; }
.picker-backdrop { position: fixed; inset: 0; z-index: 25; }
.picker-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 26; min-width: 280px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--r-m);
  box-shadow: 0 10px 28px rgba(23, 32, 43, 0.15); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.picker-hint { font-size: 0.8rem; color: var(--ink-3); margin: 0 0 4px; }
.picker-opt { display: grid; grid-template-columns: 18px 20px 1fr; gap: 6px; align-items: start; padding: 6px 4px; border-radius: var(--r-s); cursor: pointer; font-size: 0.9rem; }
.picker-opt:hover { background: var(--paper); }
.picker-opt input { width: auto; margin-top: 3px; }
.picker-pos { font-weight: 600; color: var(--blue); text-align: center; font-variant-numeric: tabular-nums; }
.picker-sub { display: block; font-size: 0.78rem; color: var(--ink-3); }
.group-head { background: var(--blue-soft); color: var(--blue-dark); }

/* ---------------------------------------------------------------- version 3: projects and administration */
.head-with-action { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.project-card { grid-template-columns: 1fr 240px; }
.project-card.is-inactive { opacity: 0.7; }
.inactive-tag, .active-tag { font: 600 0.72rem var(--sans); padding: 2px 7px; border-radius: var(--r-s); margin-left: 10px; vertical-align: middle; }
.inactive-tag { background: var(--paper); color: var(--ink-2); border: 1px solid var(--rule-strong); }
.active-tag { background: var(--blue-soft); color: var(--blue-dark); }
.cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 4px 16px; }
.cat-line { display: grid; grid-template-columns: 18px 30px 1fr; gap: 6px; align-items: start; font-size: 0.88rem; cursor: pointer; }
.cat-line input { width: auto; margin-top: 3px; }
.cat-line span { color: var(--ink-2); }
.project-progress p { margin: 6px 0 0; }
.bar-big { height: 10px; border-radius: 5px; }
.project-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-l); overflow: hidden; font-size: 0.9rem; }
.project-table th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 0.8rem; padding: 10px 12px; border-bottom: 1px solid var(--rule-strong); background: #f8faf9; }
.project-table td { padding: 10px 12px; border-bottom: 1px solid #edf0ef; vertical-align: top; }
.project-table .center { text-align: center; }
.project-table tr.is-done td { background: #f4faf6; }
.project-table select { min-width: 230px; padding: 5px 8px; font-size: 0.86rem; }
.project-table td.differs select { border-color: var(--orange); }
.differs-note { display: block; color: var(--orange); margin-top: 3px; }
.pt-link { font-weight: 600; }
.pt-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.big-check { width: 20px; height: 20px; cursor: pointer; accent-color: var(--green); }
.done-tag { display: inline-block; font: 600 0.75rem var(--sans); padding: 2px 8px; border-radius: var(--r-s); background: var(--green); color: #fff; }
.project-history { margin-top: 20px; }
.project-box.is-done { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.project-box h2 a { color: inherit; }
.check-line { display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: start; margin-top: 10px; cursor: pointer; font-size: 0.92rem; }
.check-line input { width: 18px; height: 18px; accent-color: var(--green); margin-top: 1px; }
.check-line small { display: block; color: var(--ink-3); font-size: 0.78rem; }
.done-line { margin: 12px 0 0; }

.invite-help { background: var(--blue-soft); border-radius: var(--r-m); padding: 12px 14px; margin-bottom: 14px; font-size: 0.92rem; }
.invite-help p:last-child { margin-bottom: 0; }
.users-table select { width: auto; padding: 5px 8px; }
.admin-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; align-items: start; }
.setting { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #edf0ef; }
.list-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.list-title { font-size: 0.9rem; margin-bottom: 8px; }
.list-names { font-size: 0.9rem; }
.list-scroll { max-height: 320px; overflow: auto; }
.add-inline { display: flex; gap: 8px; margin-top: 12px; }
@media (max-width: 1180px) { .admin-cols, .list-cols { grid-template-columns: 1fr; } .project-card { grid-template-columns: 1fr; } }
