:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1d2330; --muted: #6b7385; --line: #dde1e8;
  --accent: #2357c6; --accent-soft: #e6edfb; --ok: #1f8a4c; --warn: #b26a00; --err: #c0392b;
  --mark: #fff1a8; --mark-strong: #ffd84d; --a: #2f6fd8; --b: #d9822b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
button, select, input, textarea { font: inherit; }
button {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px;
  cursor: pointer; color: var(--ink);
}
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--err); }
button:disabled { opacity: .5; cursor: not-allowed; }
kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px;
  font-size: 11px; background: #fafafa; font-family: inherit;
}
#topbar {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 16px; align-items: center;
  background: #1d2a44; color: #fff; padding: 8px 16px;
}
#topbar .brand { font-weight: 600; }
#topbar .muted { color: #aab4c8; }
#topbar nav { display: flex; gap: 6px; }
#topbar nav a { color: #dfe6f5; text-decoration: none; padding: 4px 8px; border-radius: 4px; }
#topbar nav a.active, #topbar nav a:hover { background: rgba(255,255,255,.12); }
#whoami { margin-left: auto; display: flex; gap: 10px; align-items: center; }
#whoami button { background: transparent; color: #fff; border-color: #50608a; }
.progress { min-width: 220px; }
.bar { height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: #5fd08a; }
.progress small { color: #c9d3e6; }

#toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: #1d2330; color: #fff; padding: 8px 14px; border-radius: 6px; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: 70vw;
}
#toast.show { opacity: .95; }
#toast.err { background: var(--err); }

dialog { border: 1px solid var(--line); border-radius: 8px; padding: 18px; max-width: 560px; }
dialog::backdrop { background: rgba(20,25,40,.4); }
dialog h3 { margin-top: 0; }
dialog textarea { width: 100%; min-height: 80px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* login */
.login { max-width: 360px; margin: 10vh auto; background: var(--panel); padding: 24px;
  border-radius: 10px; border: 1px solid var(--line); }
.login label { display: block; margin: 10px 0 4px; }
.login input { width: 100%; padding: 7px; }
.login button { margin-top: 16px; width: 100%; }
.error { color: var(--err); }

/* queue */
.queue { max-width: 980px; margin: 16px auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; }
.queue-head { display: flex; gap: 8px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.queue-head .spacer { flex: 1; }
.filters button.on { background: var(--accent-soft); border-color: var(--accent); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--line); }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr:focus { background: var(--accent-soft); outline: none; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px;
  background: #eef0f4; color: var(--muted); }
.badge.draft, .badge.correcting { background: #fff4dc; color: var(--warn); }
.badge.submitted, .badge.final { background: #e3f5ea; color: var(--ok); }
.badge.locked { background: #ece6fb; color: #5b3cc4; }

/* review screen */
.review { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 12px; padding: 12px;
  height: calc(100vh - 48px); }
.doc { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 18px 40vh; }
.side { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.meta { font-size: 12px; color: var(--muted); line-height: 1.6; }
.meta b { color: var(--ink); }
.section { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 14px; }
.section-head { display: flex; gap: 10px; align-items: baseline; position: sticky; top: 0;
  background: var(--panel); padding: 8px 0; z-index: 2; flex-wrap: wrap; }
.section-head h2 { font-size: 15px; margin: 0; }
.section-head label { margin-left: auto; font-size: 13px; white-space: nowrap; }
.section-head .read-ok { color: var(--ok); }
.sec-text { white-space: pre-wrap; line-height: 1.6; font-size: 14.5px; margin: 0;
  font-family: Georgia, "Times New Roman", serif; cursor: text; }
.sec-text::selection, .sec-text *::selection { background: #b6cdf7; }
.absent { color: var(--muted); font-style: italic; }
.warn { color: var(--warn); font-size: 12px; }
mark { background: var(--mark); border-radius: 2px; padding: 0; color: inherit; cursor: pointer; }
mark.multi { background: var(--mark-strong); }
mark.focus { outline: 2px solid var(--accent); }
mark.a { background: rgba(47,111,216,.18); border-bottom: 2px solid var(--a); }
mark.b { background: rgba(217,130,43,.18); border-bottom: 2px solid var(--b); }
mark.ab { background: rgba(120,120,120,.18); border-bottom: 2px solid #555; }

.pending { border: 1px dashed var(--accent); border-radius: 8px; padding: 10px; background: var(--accent-soft); }
.pending q { display: block; margin: 6px 0; font-family: Georgia, serif; max-height: 120px; overflow: auto; }
.kind-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.items h3, .side h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 4px 0; }
.item { border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-bottom: 6px; }
.item.editing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.item.invalid { border-left: 3px solid var(--warn); }
.item-head { display: flex; gap: 6px; align-items: center; }
.item-head .kind { font-weight: 600; }
.item-head .sec { color: var(--muted); font-size: 12px; }
.item-head .tools { margin-left: auto; display: flex; gap: 4px; }
.item-head .tools button { padding: 2px 6px; font-size: 12px; }
.item .span { font-family: Georgia, serif; font-size: 13px; color: #333; margin: 4px 0;
  max-height: 3.2em; overflow: hidden; }
.item .fields { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 150px 1fr; gap: 6px 8px; align-items: center;
  margin-top: 8px; }
.form-grid label { font-size: 12px; }
.form-grid .req::after { content: " *"; color: var(--err); }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 4px; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-bar .spacer { flex: 1; }
.state-line { font-size: 12px; }
.state-line.dirty { color: var(--warn); }
.history { font-size: 12px; }
.history li { margin: 2px 0; }
.banner { padding: 8px 10px; border-radius: 6px; font-size: 13px; }
.banner.info { background: var(--accent-soft); }
.banner.locked { background: #ece6fb; }
.banner.warnb { background: #fff4dc; }
.excl textarea, .note textarea { width: 100%; min-height: 50px; }
.help-grid { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; font-size: 13px; }

/* arbitration */
.row { border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.row.agree { border-left: 4px solid var(--ok); }
.row.fields_differ { border-left: 4px solid var(--warn); }
.row.only_a { border-left: 4px solid var(--a); }
.row.only_b { border-left: 4px solid var(--b); }
.row.decided { opacity: .8; }
.row table td, .row table th { padding: 2px 6px; font-size: 12px; }
.row td.diff { background: #fff4dc; font-weight: 600; }
.choices { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0; font-size: 13px; }
.row textarea { width: 100%; min-height: 34px; font-size: 12px; }
.legend { display: flex; gap: 12px; font-size: 12px; }
.legend span { padding: 0 6px; border-radius: 3px; }
.legend .lg-a { background: rgba(47,111,216,.18); }
.legend .lg-b { background: rgba(217,130,43,.18); }
button.primary kbd { background: transparent; color: #fff; border-color: rgba(255,255,255,.55); }
textarea.ver-reason { width: 100%; min-height: 50px; flex-shrink: 0; }
.side > * { flex-shrink: 0; }

/* Pilot campaign (doc 11 par. 12): unmistakable, never confusable with the official review */
#topbar.pilot { background: #7a4b00; }
#topbar.pilot #draw-id { color: #fff; font-weight: 700; }
