:root {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #243249;
  background: #edf1f6;
  font-size: 14px;
  --blue: #215be6;
  --border: #dce3ed;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select {
  touch-action: manipulation;
}
button {
  padding: 0.62rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
  color: inherit;
  cursor: pointer;
  font-weight: 550;
}
button:hover:not(:disabled) {
  background: #eaf0ff;
  border-color: #9bb7f7;
}
button:disabled {
  opacity: 0.42;
  cursor: default;
}
.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}
.primary:hover:not(:disabled) {
  background: #1648be;
  color: white;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #7ea5ff;
  outline-offset: 2px;
}
input,
select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 0;
  background: white;
  color: inherit;
}
header {
  height: 70px;
  padding: 0 22px;
  display: flex;
  gap: 20px;
  align-items: center;
  background: white;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: #1d2940;
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -1px;
}
.brand > span:last-child {
  color: var(--blue);
}
.brand-icon {
  background: var(--blue);
  color: white;
  border-radius: 10px;
  padding: 4px 10px;
  margin-right: 10px;
  font-size: 22px;
  letter-spacing: 0;
}
.privacy {
  margin-left: auto;
  background: #eef7f3;
  border: 1px solid #d7eade;
  color: #286345;
  border-radius: 30px;
  padding: 8px 13px;
  font-size: 13px;
}
.toolbar {
  min-height: 57px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 5px;
}
#status {
  margin-left: auto;
  font-size: 13px;
  color: #60718c;
}
.workspace {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr) 188px;
  height: calc(100dvh - 127px);
  min-height: 450px;
}
.pages,
.actions {
  background: #f9fbfe;
  overflow: auto;
}
.pages {
  border-right: 1px solid var(--border);
}
.actions {
  border-left: 1px solid var(--border);
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-title {
  display: flex;
  justify-content: space-between;
  padding: 18px 14px;
}
.actions .panel-title {
  padding-left: 0;
}
.selection {
  display: flex;
  gap: 4px;
  padding: 0 8px 10px;
}
.selection button {
  font-size: 12px;
  padding: 6px;
}
.thumb {
  position: relative;
  margin: 8px 15px 14px;
  padding: 10px;
  border: 2px solid transparent;
  border-radius: 9px;
  cursor: grab;
  background: #eef2f7;
  text-align: center;
}
.thumb.current {
  border-color: #adc2ed;
}
.thumb.selected {
  border-color: var(--blue);
  background: #e8efff;
}
.thumb canvas {
  display: block;
  max-width: 100%;
  margin: auto;
  box-shadow: 0 2px 7px #26344c20;
  background: white;
}
.thumb label {
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
  margin-top: 9px;
  font-size: 13px;
}
.document {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.viewer-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: #f9fbfe;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.viewer-toolbar label {
  white-space: nowrap;
}
#page-number {
  width: 58px;
}
#search-form {
  display: flex;
  gap: 5px;
  margin-left: 12px;
}
#search {
  width: 150px;
}
#viewport {
  flex: 1;
  overflow: auto;
  padding: 26px;
  position: relative;
}
#sheet {
  position: relative;
  margin: 0 auto;
  box-shadow: 0 5px 30px #22334b26;
  background: white;
}
#canvas {
  display: block;
}
#empty {
  text-align: center;
  max-width: 490px;
  margin: clamp(30px, 10vh, 100px) auto 30px;
  background: #f9fbfe;
  border: 1px dashed #aebed4;
  padding: 40px 20px;
  border-radius: 16px;
}
h1 {
  font-size: 26px;
  letter-spacing: -0.6px;
  margin: 18px 0 12px;
}
p {
  line-height: 1.55;
}
.empty-icon {
  display: inline-block;
  border: 2px solid #8ba6e6;
  border-radius: 7px;
  color: var(--blue);
  padding: 17px 12px;
  font-weight: 750;
}
.muted,
.note {
  color: #68778c;
  font-size: 13px;
}
.note {
  margin-top: 12px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  line-height: 1.6;
}
.danger {
  color: #ad3041;
}
.admin-link {
  margin-top: auto;
  padding: 20px 0;
  color: #61718b;
  font-size: 13px;
}
footer {
  padding: 9px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: #69778b;
  background: #f9fbfe;
  border-top: 1px solid var(--border);
}
#filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}
dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 520px;
  width: calc(100% - 30px);
  padding: 25px;
  box-shadow: 0 20px 100px #172a4a40;
}
dialog::backdrop {
  background: #13243f66;
}
dialog h2 {
  margin-top: 0;
  font-size: 20px;
}
dialog input {
  width: 100%;
  margin: 8px 0;
}
dialog label {
  display: block;
}
#modal form,
#modal-body {
  min-width: 0;
  max-width: 100%;
}
#modal-body {
  overflow-x: clip;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}
#toast {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 18px;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(520px, calc(100vw - 36px));
  background: #203451;
  color: white;
  padding: 10px 14px;
  border-radius: 9px;
  box-shadow: 0 6px 22px #172a4a35;
  z-index: 90;
}
@media (max-width: 600px) {
  #toast { left: 10px; right: 10px; bottom: 12px; transform: none; width: auto; max-width: none; }
}
#search-results {
  padding: 8px 16px;
  max-height: 130px;
  overflow: auto;
  background: white;
}
#search-results button {
  margin: 3px;
}
.drag-over {
  outline: 3px dashed var(--blue);
  outline-offset: -5px;
}
.admin {
  max-width: 1080px;
  margin: 30px auto;
  padding: 0 20px;
}
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin: 18px 0;
}
.login {
  max-width: 420px;
  margin: 8vh auto;
}
.login label,
.form-grid label {
  display: block;
  margin: 12px 0;
}
.login input,
.form-grid input {
  width: 100%;
  margin-top: 6px;
}
table {
  border-collapse: collapse;
  width: 100%;
}
td,
th {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.table-wrap {
  overflow: auto;
}
td form {
  display: inline;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 15px;
  align-items: end;
}
.flash {
  padding: 12px;
  background: #eaf1ff;
  border: 1px solid #c6d8fa;
  border-radius: 8px;
}
.switch {
  display: inline-block;
  width: 40px;
  height: 24px;
  padding: 2px;
  border-radius: 20px;
  background: #8895a7;
  border: 0;
  vertical-align: middle;
}
.switch::before {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
}
.switch[aria-checked="true"] {
  background: var(--blue);
}
.switch[aria-checked="true"]::before {
  transform: translateX(16px);
}
.inline {
  display: inline;
}
.admin-nav {
  display: flex;
  gap: 10px;
  align-items: center;
}
.busy .workspace {
  pointer-events: none;
  opacity: 0.7;
}
@media (max-width: 1000px) {
  .workspace {
    grid-template-columns: 160px minmax(0, 1fr);
  }
  .actions {
    grid-column: 1/-1;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px;
    border-top: 1px solid var(--border);
    overflow: visible;
  }
  .actions .panel-title,
  .actions .note,
  .actions .admin-link {
    display: none;
  }
  .workspace {
    height: auto;
    min-height: calc(100dvh - 127px);
  }
  .document,
  .pages {
    height: calc(100dvh - 240px);
    min-height: 360px;
  }
  .actions #selected-count {
    margin: 8px;
  }
  .privacy {
    max-width: 330px;
    font-size: 12px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) {
  header {
    height: auto;
    min-height: 66px;
    padding: 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .brand {
    font-size: 22px;
  }
  .privacy {
    order: 3;
    max-width: none;
    width: 100%;
    text-align: center;
    margin: 0;
    padding: 5px;
  }
  .primary {
    margin-left: auto;
  }
  .toolbar {
    padding: 8px;
    gap: 5px;
  }
  .toolbar button {
    font-size: 13px;
    padding: 8px;
  }
  #status {
    width: 100%;
    margin: 0;
  }
  .workspace {
    grid-template-columns: 100px minmax(0, 1fr);
  }
  .thumb {
    margin: 5px;
    padding: 5px;
  }
  .panel-title {
    padding: 12px 8px;
  }
  .selection {
    flex-wrap: wrap;
    padding: 4px;
  }
  .selection button {
    font-size: 12px;
  }
  .viewer-toolbar {
    justify-content: flex-start;
    padding: 6px;
  }
  .viewer-toolbar button {
    padding: 6px;
  }
  #search-form {
    margin-left: 0;
    width: 100%;
  }
  #search {
    width: 100%;
  }
  .document,
  .pages {
    height: 60dvh;
  }
  .actions {
    gap: 5px;
  }
  .actions button {
    font-size: 13px;
    padding: 8px;
  }
  #viewport {
    padding: 10px;
  }
  #empty {
    padding: 20px 8px;
    margin: 15px 0;
  }
  h1 {
    font-size: 21px;
  }
  footer {
    flex-wrap: wrap;
  }
  footer span {
    max-width: 100% !important;
  }
  #empty p {
    font-size: 13px;
  }
  #zoom {
    max-width: 130px;
  }
}

/* Shared UI contract: forms, actions, help and control states. */
.toggle-input {
  appearance: none;
  width: 36px;
  height: 22px;
  border: 0;
  border-radius: 20px;
  background: #8997ab;
  position: relative;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-input:before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
}
.toggle-input:checked {
  background: var(--blue);
}
.toggle-input:checked:before {
  transform: translateX(14px);
}
.toggle-input:disabled {
  opacity: 0.5;
  cursor: default;
}

[hidden] { display: none !important; }
:root { --surface: #fff; --muted: #61718a; --radius: 12px; --danger: #ad3041; }
.ui-shell { width: min(100%, 780px); margin: 32px auto; padding: 0 20px; }
.ui-heading { margin: 0 0 8px; font-size: 24px; }
.ui-lead { color: var(--muted); margin: 0 0 22px; }
.ui-form { display: grid; gap: 22px; }
.ui-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.ui-fieldset legend { font-weight: 650; padding: 0; margin-bottom: 14px; font-size: 15px; }
.ui-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.ui-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; font-weight: 550; }
.ui-field input, .ui-field select, .ui-field textarea { width: 100%; min-height: 40px; margin: 0; }
.ui-full { grid-column: 1/-1; }
.ui-help { font-size: 12px; color: var(--muted); line-height: 1.5; font-weight: 400; margin: 0; }
.ui-help code { overflow-wrap: anywhere; }
.ui-notice { border: 1px solid #cbdcf9; border-radius: 8px; padding: 12px 14px; background: #f2f6fe; line-height: 1.55; margin: 0 0 20px; }
.ui-notice-error { border-color: #ecc4cb; background: #fff4f5; color: #8a2435; }
.ui-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--border); padding-top: 18px; }
.ui-actions .primary { margin: 0; }
.ui-password { display: flex; position: relative; }
.ui-password input { padding-right: 76px; }
.ui-password button { position: absolute; right: 4px; top: 4px; bottom: 4px; border: 0; padding: 0 9px; font-size: 12px; color: var(--blue); }
.ui-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; padding: .65rem 1rem; border-radius: 7px; font-weight: 550; }
textarea { font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: .5rem; resize: vertical; }
textarea:focus-visible { outline: 3px solid #7ea5ff; outline-offset: 2px; }
@media(max-width:600px) { .ui-shell { margin: 18px auto; padding: 0 12px; } .ui-fields {grid-template-columns:1fr;} .ui-shell .card {padding:20px;} .ui-actions {flex-wrap:wrap;} .ui-actions .primary {width:100%;} }
@media(prefers-reduced-motion:reduce) { *, *::before, *::after {scroll-behavior:auto !important;animation:none !important;transition:none !important;} }

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.dialog-heading h2 {
  margin: 0;
}
.dialog-heading > button {
  border: 0;
}

#toast {pointer-events:none;}
.ui-field input {font-weight:400;}

/* Shared contextual menu primitive. */
.ui-context-menu {
  position: fixed;
  z-index: 80;
  min-width: 210px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 5px;
  border: 1px solid #cfd8e6;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 14px 42px #172a4a33;
}
.ui-context-item {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: transparent;
  text-align: left;
  font-weight: 500;
}
.ui-context-item:hover:not(:disabled),
.ui-context-item:focus-visible {
  background: #edf3ff;
  outline: none;
}
.ui-context-item kbd {
  color: #728096;
  font: inherit;
  font-size: 11px;
  white-space: nowrap;
}
.ui-context-separator {
  height: 1px;
  margin: 4px 5px;
  background: var(--border);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.brio-icon-sprite {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  pointer-events: none;
}
.ui-context-leading {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.ui-context-leading .brio-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: #526985;
}
.ui-context-item.danger .ui-context-leading .brio-icon { color: currentColor; }

/* dev.6.100 — generic workspace dialog: one overflow-safe shell for comments,
   confirmations, download/range forms and password prompts. */
#modal.workspace-modal {
  width: min(560px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
}
#modal.workspace-modal[data-size="compact"] { width: min(440px, calc(100vw - 24px)); }
#modal.workspace-modal[data-size="wide"] { width: min(720px, calc(100vw - 24px)); }
#modal .workspace-modal-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - 24px);
  min-width: 0;
  margin: 0;
  overflow: hidden;
  box-sizing: border-box;
}
#modal .workspace-modal-heading {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  box-sizing: border-box;
}
#modal .workspace-modal-heading h2 {
  min-width: 0;
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
#modal .workspace-modal-heading .icon-only {
  flex: 0 0 auto;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 5px;
}
#modal .workspace-modal-body {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 14px 18px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
}
#modal .workspace-modal-body > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
#modal .workspace-modal-body :is(input, select, textarea) { max-width: 100%; box-sizing: border-box; }
#modal .workspace-modal-body textarea { resize: vertical; }
#modal .workspace-modal-actions {
  flex: 0 0 auto;
  margin: 0;
  padding: 11px 18px 14px;
  border-top: 1px solid var(--border);
  background: #fbfcfe;
  box-sizing: border-box;
}
#modal .workspace-modal-actions #modal-ok.primary.danger {
  border-color: #b83b4b;
  background: #b83b4b;
  color: #fff;
}
#modal .workspace-modal-actions #modal-ok.primary.danger:hover:not(:disabled) {
  border-color: #982c3b;
  background: #982c3b;
  color: #fff;
}
@media (max-width: 480px) {
  #modal.workspace-modal,
  #modal.workspace-modal[data-size="compact"],
  #modal.workspace-modal[data-size="wide"] { width: calc(100vw - 14px); max-width: calc(100vw - 14px); }
  #modal .workspace-modal-form { max-height: calc(100dvh - 14px); }
  #modal .workspace-modal-heading { padding: 14px 14px 10px; }
  #modal .workspace-modal-body { padding: 12px 14px 14px; }
  #modal .workspace-modal-actions { padding: 10px 14px 13px; }
  #modal .workspace-modal-actions button { flex: 1 1 auto; }
  #modal .workspace-modal-actions #modal-ok { flex-basis: 100%; order: -1; }
}
