:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6ec;
  --border-strong: #cfd4dd;
  --text: #1c2130;
  --muted: #667085;
  --accent: #2f5bea;
  --accent-hover: #2449c4;
  --accent-soft: #eaf0ff;
  --green: #16834a;
  --green-soft: #e6f6ed;
  --amber: #a35c00;
  --amber-soft: #fff4e0;
  --red: #c4322d;
  --red-soft: #fdecec;
  --violet: #6b3fd4;
  --violet-soft: #f1ebff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 560; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { filter: brightness(.95); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; flex: none; }

label.field { display: block; }
label.field > span { display: block; font-weight: 560; font-size: 13px; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  font: inherit; color: var(--text); background: var(--surface);
}
textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill.assigned, .pill.unassigned { background: var(--surface-2); color: var(--muted); }
.pill.in_progress { background: var(--accent-soft); color: var(--accent); border-color: #cfdcff; }
.pill.returned { background: var(--amber-soft); color: var(--amber); border-color: #f7ddb0; }
.pill.submitted { background: var(--violet-soft); color: var(--violet); border-color: #dccfff; }
.pill.final { background: var(--green-soft); color: var(--green); border-color: #bfe6cf; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }

/* ---------- app shell ---------- */
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 18px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 680; font-size: 15px; color: var(--text); }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.brand-mark svg { width: 15px; height: 15px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 11px; border-radius: 7px; color: var(--muted); font-weight: 560; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 650; font-size: 12.5px; }

.page { max-width: 1120px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { margin-bottom: 22px; justify-content: center; font-size: 17px; }
.error-text { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- dashboard ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 12px; font: inherit; font-weight: 560; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 5px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; }
.tabs button.active .count { background: var(--accent); border-color: var(--accent); color: #fff; }

.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .12s, box-shadow .12s; color: inherit; }
.doc-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.doc-icon { width: 40px; height: 48px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .03em; }
.doc-title { font-weight: 600; font-size: 14.5px; }
.doc-meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.doc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.overdue { color: var(--red); font-weight: 600; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; }
.modal.wide { max-width: 640px; }
.modal-head { padding: 18px 20px 6px; display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 10px 20px 4px; }
.modal-foot { padding: 16px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.dropzone { border: 2px dashed var(--border-strong); border-radius: 10px; padding: 26px 16px; text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color .12s, background .12s; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .file-name { font-weight: 600; color: var(--text); margin-top: 4px; word-break: break-all; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 12px; }
.summary-grid div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.summary-grid b { display: block; font-size: 20px; }
.summary-grid span { color: var(--muted); font-size: 12px; }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.notice.warn { background: var(--amber-soft); color: #7a4500; }
.notice.info { background: var(--accent-soft); color: #23439f; }
.notice.ok { background: var(--green-soft); color: #11603a; }
.page-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.page-links button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 6px; padding: 2px 8px; cursor: pointer; font: inherit; font-size: 12.5px; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.people-table { width: 100%; border-collapse: collapse; }
.people-table td, .people-table th { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.people-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 99px; background: var(--accent-soft); color: #23439f; font-size: 13px; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; width: 20px; height: 20px; border-radius: 50%; }
.chip button:hover { background: rgba(0,0,0,.08); }

/* ---------- toasts ---------- */
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1c2130; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-weight: 520; animation: fade .15s; max-width: 90vw; }
.toast.error { background: var(--red); }

/* ---------- editor ---------- */
.editor { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: #e9ebf0; }
.ed-top, .toolbar, .page-bar, .page-surface { -webkit-user-select: none; user-select: none; }.ed-top { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 8px 14px; min-height: 56px; flex-wrap: wrap; }
.ed-title { min-width: 0; }
.ed-title h1 { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
.ed-title .small { display: flex; gap: 8px; align-items: center; }
.save-state { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.save-state.dirty { color: var(--amber); }
.progress-chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; font-weight: 560; cursor: pointer; white-space: nowrap; }
.progress-bar { width: 70px; height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .2s; }

.toolbar { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 4px; padding: 6px 10px; flex-wrap: wrap; position: relative; z-index: 5; }
.tool-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-right: 1px solid var(--border); }
.tool-group:last-child { border-right: 0; }
.tool { width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; cursor: pointer; color: #3b4252; position: relative; }
.tool:hover { background: var(--surface-2); }
.tool.active { background: var(--accent-soft); color: var(--accent); border-color: #cfdcff; }
.tool:disabled { opacity: .35; cursor: default; }
.tool svg { width: 19px; height: 19px; }
.tool[data-tip]:hover::after { content: attr(data-tip); position: absolute; top: 40px; left: 50%; transform: translateX(-50%); background: #1c2130; color: #fff; font-size: 11.5px; padding: 4px 8px; border-radius: 5px; white-space: nowrap; pointer-events: none; z-index: 30; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; margin: 0 2px; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.color-custom { width: 26px; height: 26px; border: 0; padding: 0; background: none; cursor: pointer; }
.size-control { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.size-control input { width: 90px; accent-color: var(--accent); }
.size-dot { width: 22px; height: 22px; display: grid; place-items: center; }
.size-dot i { display: block; border-radius: 50%; background: currentColor; }
.zoom-label { width: 46px; text-align: center; font-size: 12.5px; font-weight: 560; }
.sel-info { font-size: 12px; color: var(--muted); padding: 0 8px; white-space: nowrap; }

.ed-body { flex: 1; overflow: auto; position: relative; }
/* one page at a time; change pages with the buttons */
.pages { display: flex; flex-direction: column; align-items: center; padding: 16px; width: max-content; min-width: 100%; }
.page-card[hidden] { display: none !important; }
.page-strip { background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.strip-pages { flex: 1; display: flex; gap: 6px; overflow-x: auto; justify-content: center; padding: 2px; min-width: 0; }
.strip-btn { flex: none; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-weight: 600; font-size: 13px; color: #3b4252; cursor: pointer; position: relative; }
.strip-btn:hover { border-color: var(--accent); }
.strip-btn.marked::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.strip-btn.clean { background: var(--green-soft); border-color: #9fd8b7; color: var(--green); }
.strip-btn.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.flip-icon { display: contents; }
.flip-icon svg { width: 16px; height: 16px; transform: scaleX(-1); }
.page-card { background: transparent; flex: none; }
@media (max-width: 600px) { .page-strip .btn { padding: 0 9px; } .page-strip .btn .label-text { display: none; } }
.page-label { min-width: 92px; text-align: center; font-size: 12.5px; font-weight: 560; white-space: nowrap; }
.tool.flip svg { transform: scaleX(-1); }
.page-bar { display: flex; align-items: center; gap: 10px; padding: 0 2px 8px; font-size: 12.5px; }
.page-bar .pn { font-weight: 650; color: #3b4252; }
.page-bar .marks { color: var(--muted); }
.nochange { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 6px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border-strong); cursor: pointer; user-select: none; font-weight: 560; color: #3b4252; }
.nochange input { position: absolute; opacity: 0; pointer-events: none; }
.nochange .box { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; background: #fff; }
.nochange .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.nochange.on { background: var(--green-soft); border-color: #9fd8b7; color: var(--green); }
.nochange.on .box { background: var(--green); border-color: var(--green); }
.nochange.on .box svg { opacity: 1; }
.nochange.disabled { cursor: default; opacity: .8; }
.page-warn { color: var(--amber); font-weight: 560; }
.page-surface { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 4px 14px rgba(0,0,0,.06); }
.page-card.clean .page-surface { box-shadow: 0 0 0 3px #9fd8b7, 0 4px 14px rgba(0,0,0,.06); }
.page-surface .bg { position: absolute; top: 0; left: 0; }
.page-surface .canvas-container { position: absolute !important; top: 0; left: 0; }
.page-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }

.info-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 360px; max-width: 100vw; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 50; display: flex; flex-direction: column; animation: slide .15s ease-out; }
@keyframes slide { from { transform: translateX(20px); opacity: 0 } to { transform: none; opacity: 1 } }
.info-drawer header { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.info-drawer .content { padding: 16px 18px; overflow: auto; flex: 1; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity li .when { color: var(--muted); font-size: 12px; }
dl.meta { display: grid; grid-template-columns: 100px 1fr; gap: 6px 10px; margin: 0; font-size: 13px; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }

.banner { padding: 9px 16px; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.banner.info { background: var(--accent-soft); color: #23439f; }
.banner.warn { background: var(--amber-soft); color: #7a4500; }
.banner.ok { background: var(--green-soft); color: #11603a; }
.banner.violet { background: var(--violet-soft); color: #4b2a9e; }

@media (max-width: 820px) {
  .settings-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .ed-title h1 { max-width: 60vw; }
  .doc-row { grid-template-columns: 1fr auto; }
  .doc-icon { display: none; }
  .nav a { padding: 7px 8px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .user-chip .name { display: none; }
}

.unfinished-btn.on { background: var(--amber-soft); border-color: #f0c97a; color: var(--amber); }
.strip-note { align-self: center; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.strip-btn[hidden] { display: none; }
@media (max-width: 600px) { .page-strip { flex-wrap: wrap; } .unfinished-btn { flex: 1; } .strip-pages { order: 3; flex-basis: 100%; justify-content: flex-start; } }

.save-stack { display: flex; flex-direction: column; gap: 6px; margin-left: auto; min-width: 170px; }
.save-stack .btn { width: 100%; height: 32px; }

/* ---------- editor layout: page on the left, controls on the right ---------- */
.ed-main { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.ed-main .ed-body { flex: 1; }
.ed-side { display: contents; }
.ed-side .ed-top { order: 1; } .ed-side .toolbar { order: 2; } .ed-side .banner { order: 3; }
.ed-main { order: 4; } .ed-side .page-strip { order: 5; }

@media (min-width: 900px) {
  .editor { flex-direction: row; }
  .ed-main { order: 0; }
  .ed-side { display: flex; flex-direction: column; width: 300px; flex: none; background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; }
  .ed-side > * { order: 0 !important; }
  .ed-side .ed-top { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 10px; padding: 12px 16px 16px; border-bottom: 1px solid var(--border); min-height: 0; }
  .ed-side .ed-top > .btn.ghost { align-self: flex-start; margin-left: -8px; }
  .ed-side .ed-top .spacer { display: none; }
  .ed-side .ed-title h1 { max-width: none; white-space: normal; font-size: 16px; }
  .ed-side .save-state { order: 9; text-align: center; }
  .ed-side .save-stack { margin-left: 0; min-width: 0; }
  .ed-side .save-stack .btn { height: 38px; }
  .ed-side .banner { padding: 12px 16px; display: block; line-height: 1.45; }
  .ed-side .banner > * { display: block; }
  .ed-side .banner > * + * { margin-top: 4px; }
  .ed-side .toolbar { flex-direction: column; align-items: stretch; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .ed-side .tool-group { border-right: 0; padding: 0; flex-wrap: wrap; gap: 4px; }
  .ed-side .tool-group[data-label]::before, .ed-side .page-strip[data-label]::before { content: attr(data-label); flex-basis: 100%; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
  .ed-side .tool-group.page-nav { display: none; }
  .ed-side .tool[data-tip]:hover::after { display: none; }
  .ed-side .tool { width: 40px; height: 40px; }
  .ed-side .size-control input { width: 200px; }
  .ed-side .sel-info { padding: 0; white-space: normal; }
  .ed-side .page-strip { flex-wrap: wrap; border-top: 0; padding: 14px 16px 20px; gap: 8px; }
  .ed-side .page-strip .btn { flex: 1; }
  .ed-side .page-strip .unfinished-btn { order: 1; flex-basis: 100%; }
  .ed-side .strip-pages { order: 2; flex-basis: 100%; flex-wrap: wrap; justify-content: flex-start; overflow: visible; }
  .ed-side .strip-note { flex-basis: 100%; }
  .ed-side .page-strip > .btn:not(.unfinished-btn) { order: 3; }
}
.tool-group.tools { flex-wrap: wrap; }
[hidden] { display: none !important; }
@media (min-width: 900px) { .ed-side > * { flex-shrink: 0; } }
@media (min-width: 900px) {
  .ed-side .toolbar { flex-direction: row; flex-wrap: wrap; gap: 12px 16px; align-items: flex-start; }
  .ed-side .toolbar > .tool-group { flex-basis: 100%; }
  .ed-side .toolbar > .tool-group.edit-group, .ed-side .toolbar > .tool-group.zoom-group { flex-basis: auto; }
  .ed-side .toolbar > .sel-info { flex-basis: 100%; }
  .ed-side .tool { width: 36px; height: 36px; }
  .ed-side .ed-top { gap: 8px; padding: 10px 16px 14px; }
  .ed-side .page-strip { padding: 12px 16px 16px; }
}
@media (min-width: 900px) {
  .ed-side { width: 320px; }
  .ed-side .tool { width: 34px; height: 34px; }
  .ed-side .zoom-label { width: 42px; }
  .ed-side .size-control input { width: 220px; }
}
@media (min-width: 900px) {
  .ed-side .toolbar > .tool-group.edit-group { flex: 0 0 116px; }
  .ed-side .toolbar > .tool-group.zoom-group { flex: 1 1 0; min-width: 0; }
}
@media (min-width: 900px) { .ed-side .toolbar > .tool-group.edit-group { flex-basis: 110px; } .ed-side .tool-group.zoom-group { gap: 0 2px; } }

/* ---------- save/submit at the bottom; previous/next beside the page ---------- */
.ed-actions { order: 6; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--border); flex-wrap: wrap; }
.ed-actions .save-stack { margin-left: auto; }
.side-arrow { display: none; }
@media (min-width: 900px) {
  .ed-main { flex-direction: row; }
  .ed-main .ed-body { min-width: 0; }
  .side-arrow { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; flex: none; width: 84px; border: 0; background: transparent; color: #3b4252; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0 4px; text-align: center; }
  .side-arrow .arrow-circle { width: 48px; height: 48px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); display: grid; place-items: center; transition: background .12s, border-color .12s; }
  .side-arrow .arrow-circle svg { width: 22px; height: 22px; }
  .side-arrow.next .arrow-circle svg { transform: scaleX(-1); }
  .side-arrow:hover:not(:disabled) .arrow-circle { background: var(--accent); border-color: var(--accent); color: #fff; }
  .side-arrow:disabled { opacity: .3; cursor: default; }
  .side-arrow:focus-visible .arrow-circle { outline: 2px solid var(--accent); outline-offset: 2px; }
  .ed-side .page-strip > .btn:not(.unfinished-btn) { display: none; }
  .ed-side .ed-actions { order: 0; margin-top: auto; position: sticky; bottom: 0; flex-direction: column; align-items: stretch; gap: 8px; padding: 14px 16px 16px; border-bottom: 0; border-top: 1px solid var(--border); box-shadow: 0 -6px 14px rgba(16,24,40,.05); }
  .ed-side .ed-actions .save-stack { margin-left: 0; min-width: 0; }
  .ed-side .ed-actions .save-stack .btn { height: 40px; }
  .ed-side .ed-actions .save-state { text-align: center; }
}

.notice.error { background: var(--red-soft); color: #8f1f1b; }

/* ---------- "This page" section (No changes tick, Clear page) ---------- */
.page-bars { order: 3; background: var(--surface); padding: 10px 14px; border-bottom: 1px solid var(--border); }
.page-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 0; }
.page-bar-head { display: flex; align-items: center; gap: 8px; }
.page-bar .nochange { align-self: flex-start; }
.page-bar .clear-page { align-self: flex-start; }
.page-bar .page-warn:empty { display: none; }
@media (max-width: 899px) {
  .page-bar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .page-bar-head { flex-basis: 100%; }
}
@media (min-width: 900px) {
  .ed-side .page-bars { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
  .ed-side .page-bars::before { content: attr(data-label); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .ed-side .page-bar .nochange { align-self: stretch; padding: 8px 10px 8px 8px; border-radius: 8px; }
  .ed-side .page-bar .clear-page { align-self: stretch; }
}

/* ---------- reviewer protections ---------- */
.watermark { position: absolute; inset: 0; z-index: 3; pointer-events: none; background-repeat: repeat; }
.ed-main { position: relative; }
.privacy-shield { position: absolute; inset: 0; z-index: 20; border: 0; background: rgba(233, 235, 240, .97); backdrop-filter: blur(16px); display: grid; place-items: center; cursor: pointer; font: inherit; color: var(--text); text-align: center; padding: 24px; }
.privacy-shield b { display: block; font-size: 18px; margin-bottom: 6px; }
.editor.protected .page-surface { -webkit-touch-callout: none; }
@media print { .editor.protected .ed-main { visibility: hidden !important; } }
.doc-row.locked { cursor: not-allowed; opacity: .75; }
.doc-row.locked:hover { box-shadow: none; border-color: var(--border); }

/* ---------- notes to the admin ---------- */
.notes-panel { order: 3; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; background: #f4f0ff; border-bottom: 1px solid #e0d6fb; }
.notes-panel::before { content: attr(data-label); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: #5b3fb0; }
.note-item { display: flex; gap: 8px; align-items: baseline; text-align: left; border: 1px solid #ddd2fb; background: #fff; border-radius: 8px; padding: 7px 9px; font: inherit; font-size: 13px; color: #2e2160; cursor: pointer; }
.note-item:hover { border-color: #8b6fe0; }
.note-page { flex: none; font-size: 11.5px; font-weight: 650; color: #6b4fd0; }
.note-text { min-width: 0; overflow-wrap: anywhere; font-style: italic; }
@media (min-width: 900px) { .ed-side .notes-panel { padding: 14px 16px; } }
@media (min-width: 900px) { .ed-side .ed-actions { z-index: 6; } }

/* ---------- high priority ---------- */
.priority-flag { display: inline-block; vertical-align: middle; margin-right: 8px; padding: 1px 8px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.ed-title .priority-flag { margin-bottom: 4px; }
.priority-check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer; }
.priority-check:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.priority-check input { width: 18px; height: 18px; accent-color: var(--red); flex: none; margin: 0; }

/* ---------- list row actions (admin) ---------- */
.row-actions { display: flex; align-items: center; gap: 6px; }
.assign-select { height: 28px; width: auto; padding: 0 28px 0 10px; font-size: 12.5px; font-weight: 600; border-radius: 99px; border: 1px solid #f7ddb0; background-color: var(--amber-soft); color: var(--amber); cursor: pointer; }
.assign-select:hover { border-color: var(--amber); }
.icon-btn { width: 30px; padding: 0; color: var(--muted); }
.icon-btn:hover { color: var(--red); background: var(--red-soft); }
.doc-right { flex-direction: row; align-items: center; gap: 8px; }

.nc-status { color: var(--green); font-weight: 600; font-size: 13px; }

/* ---------- narrow screens: page on top, controls in a scrollable area below ---------- */
@media (max-width: 899px) {
  .editor { flex-direction: column; }
  .ed-main { order: 1; flex: 1 1 auto; min-height: 0; }
  .ed-side { display: flex; flex-direction: column; order: 2; flex: none; max-height: 46%; overflow-y: auto; background: var(--surface); border-top: 1px solid var(--border-strong); box-shadow: 0 -4px 12px rgba(16,24,40,.06); }
  .ed-side > * { flex-shrink: 0; }
  .ed-side .ed-actions { position: sticky; bottom: 0; z-index: 6; }
}
.tabs { overflow: visible; flex-wrap: wrap; row-gap: 2px; }
.nav a { white-space: nowrap; }
@media (max-width: 560px) { .topbar .brand-name { display: none; } .topbar { gap: 6px; } .nav a { padding: 7px 6px; } }
@media (max-width: 560px) { .topbar { height: auto; min-height: 56px; flex-wrap: wrap; padding-block: 8px; row-gap: 4px; } .topbar .spacer { display: none; } .user-chip { margin-left: auto; } }

/* ---------- search & filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -4px 0 14px; }
.search-input { flex: 1 1 220px; min-width: 0; height: 36px; }
.filter-select { width: auto; height: 36px; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 560; padding: 0 4px; cursor: pointer; }
.filter-check input { accent-color: var(--red); width: 16px; height: 16px; }

.action-pair { display: flex; gap: 8px; }
.action-pair .btn { flex: 1; padding: 0 8px; }
/* search box: rounded, with a magnifier icon, matching the filter dropdown */
.search-input { -webkit-appearance: none; appearance: none; height: 38px; border: 1px solid var(--border-strong); border-radius: 99px; padding: 0 14px 0 38px; font: inherit; color: var(--text); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E") no-repeat 13px center; }
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.filter-select { height: 38px; border-radius: 99px; padding: 0 32px 0 14px; }
/* all dropdowns: our own arrow, sitting a comfortable distance from the right edge */
select { -webkit-appearance: none; appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.filter-select { padding: 0 36px 0 14px; }
.assign-select { padding: 0 30px 0 12px; background-position: right 11px center; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23a35c00' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }

.saved-note { color: var(--green); font-size: 12.5px; font-weight: 600; opacity: 0; transition: opacity .2s; }
.saved-note.show { opacity: 1; }
input[type=number] { height: 36px; border: 1px solid var(--border-strong); border-radius: 99px; padding: 0 10px 0 14px; font: inherit; color: var(--text); background: var(--surface); text-align: center; }
input[type=number]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* ---------- one corner style everywhere: rounded rectangles ----------
   12px for big surfaces, 8px for controls, 6px for small labels.
   Only avatars, color swatches and status dots stay round. */
:root { --r-lg: 12px; --r: 8px; --r-sm: 6px; }
.card, .doc-row, .empty, .modal, .dropzone, .info-drawer, .side-arrow .arrow-circle { border-radius: var(--r-lg); }
.btn, input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search],
select, textarea, .search-input, .filter-select, .assign-select, .notice, .toast, .tool, .strip-btn, .nochange,
.ed-side .page-bar .nochange, .note-item, .priority-check, .summary-grid div, .progress-chip, .nav a { border-radius: var(--r); }
.pill, .chip, .priority-flag, .tabs .count, .page-links button, .doc-icon, .brand-mark { border-radius: var(--r-sm); }
.nochange .box, .chip button { border-radius: 4px; }
.action-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .action-pair .btn { min-width: 0; padding: 0 6px; font-size: 13px; white-space: normal; line-height: 1.15; height: auto; min-height: 36px; padding-block: 6px; }
@media (max-width: 899px) { .ed-side > * { order: 0; } }
/* "No changes": just the tick box and its label, no outer box */
.nochange, .ed-side .page-bar .nochange { border: 0; background: transparent; padding: 4px 0; box-shadow: none; }
.nochange.on, .ed-side .page-bar .nochange.on { background: transparent; color: var(--green); }

/* ---------- long documents: compact, scrolling page grid + Go to page ---------- */
.goto-page { width: 100%; height: 34px; text-align: left; padding: 0 12px; }
.page-strip.long .strip-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; max-height: 156px; overflow-y: auto; align-content: start; padding: 2px; position: relative; }
.page-strip.long .strip-note { grid-column: 1 / -1; }
.page-strip.long .strip-btn { min-width: 0; height: 30px; padding: 0; font-size: 12px; }
@media (min-width: 900px) { .ed-side .page-strip .goto-page { order: 1; flex-basis: 100%; } }
@media (max-width: 899px) { .page-strip.long .goto-page { flex: 1 1 120px; width: auto; } .page-strip.long .strip-pages { max-height: 72px; } }
@media (max-width: 899px) {
  .editor .ed-side > .ed-top { order: 1; }
  .editor .ed-side > .banner, .editor .ed-side > .notes-panel { order: 2; }
  .editor .ed-side > .page-bars { order: 3; }
  .editor .ed-side > .toolbar { order: 4; }
  .editor .ed-side > .page-strip { order: 5; }
  .editor .ed-side > .ed-actions { order: 6; }
}
/* desktop: keep the Pages section compact so it fits above Save / Submit */
@media (min-width: 900px) {
  .ed-side .page-strip.long .unfinished-btn, .ed-side .page-strip.long .goto-page { flex: 1 1 0; flex-basis: auto; min-width: 0; }
  .ed-side .page-strip.long .goto-page { order: 1; }
  .ed-side .page-strip.long .strip-pages { max-height: 104px; }
}
@media (min-width: 900px) { .ed-side .page-strip.long .goto-page { width: auto; } .ed-side .page-strip.long .unfinished-btn { order: 1; } }

/* ---------- time & activity log ---------- */
.time-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.time-line svg { width: 14px; height: 14px; flex: none; }
.log-row { cursor: default; }
.log-row:hover { box-shadow: none; border-color: var(--border); }
.done-icon { color: var(--green); background: var(--green-soft); border-color: #bfe6cf; }
.done-icon svg { width: 18px; height: 18px; }
