/*
 * Shared admin components
 *
 * This file is the single visual contract for modern admin pages. Page styles
 * should describe layout exceptions only and should not redefine these rules.
 */

/* Anchor destinations keep focus without a section-wide browser outline. */
:target:not(:is(a, button, input, select, textarea, summary, [role="button"], [role="link"], [contenteditable])) {
  outline: none;
}

/* Native summaries receive a real Font Awesome icon from admin-disclosures.js. */
:where(summary[data-admin-disclosure]) {
  list-style: none;
}

:where(summary[data-admin-disclosure])::-webkit-details-marker {
  display: none;
}

.admin-disclosure-icon {
  display: inline-block;
  flex: 0 0 auto;
  margin-right: 0.42rem;
  color: var(--accent, var(--brand-primary, #596270));
  font-size: 0.7em;
  transform-origin: center;
  transition: transform 0.16s ease;
}

details[open] > summary[data-admin-disclosure] .admin-disclosure-icon {
  transform: rotate(90deg);
}

.page-stack {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  min-width: 0;
}

.topbar > :first-child {
  flex: 1 1 24rem;
}

.topbar > :not(:first-child) {
  flex: 0 1 auto;
}

.topbar > .hero-actions,
.topbar > .panel-actions,
.topbar > .inline-actions {
  align-self: center;
}

.topbar > *,
.panel,
.panel-header > *,
.section-header > * {
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.page-copy,
.wf-page-intro {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.hero-actions,
.panel-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}

.hero-button,
.admin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  min-height: 2.45rem;
  padding: 0.55rem 0.78rem;
  border: 1px solid transparent;
  border-radius: 0.72rem;
  color: #fff;
  background: var(--accent);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.16s ease, background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.hero-button.secondary,
.admin-button.secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.hero-button.danger,
.admin-button.danger {
  color: var(--danger-ink);
  background: var(--danger-soft);
  border-color: rgba(150, 51, 67, 0.2);
}

.hero-button:hover,
.hero-button:focus-visible,
.admin-button:hover,
.admin-button:focus-visible,
.panel-link:hover,
.panel-link:focus-visible {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(89, 98, 112, 0.1);
}

.hero-button:disabled,
.admin-button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  box-shadow: none;
}

.panel,
.section-card {
  min-width: 0;
  margin: 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header,
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-title,
.section-title {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.3;
}

.panel-copy,
.section-copy {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.panel-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.35rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 0.95fr);
  gap: 1rem;
}

.dashboard-grid.single-panel {
  grid-template-columns: 1fr;
}

.focus-list {
  display: grid;
  gap: 0.7rem;
}

.focus-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.75rem;
  padding: 0.82rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  text-decoration: none;
}

.focus-item:hover,
.focus-item:focus-within {
  border-color: var(--accent);
}

.focus-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
}

.focus-title {
  margin: 0;
  font-size: 0.96rem;
}

.focus-copy {
  margin: 0.16rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.focus-count {
  min-width: 2.5rem;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  color: var(--warning-ink);
  background: var(--warning-soft);
  font-weight: 700;
  text-align: center;
}

.notice {
  padding: 0.82rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
}

.notice p:last-child {
  margin-bottom: 0;
}

.notice.info {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: rgba(40, 56, 145, 0.16);
}

.notice.success {
  color: var(--success-ink);
  background: var(--success-soft);
  border-color: rgba(33, 99, 66, 0.14);
}

.notice.warning {
  color: var(--warning-ink);
  background: var(--warning-soft);
  border-color: rgba(138, 90, 25, 0.14);
}

.notice.error {
  color: var(--danger-ink);
  background: var(--danger-soft);
  border-color: rgba(150, 51, 67, 0.16);
}

.type-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  width: fit-content;
  min-height: 1.75rem;
  padding: 0.25rem 0.58rem;
  border-radius: 999px;
  color: var(--muted);
  background: #edf0f3;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
}

.type-badge.paye,
.status-badge.paye {
  color: var(--paye-ink);
  background: var(--paye-soft);
}

.type-badge.cis,
.status-badge.cis {
  color: var(--cis-ink);
  background: var(--cis-soft);
}

.type-badge.completed,
.status-badge.success {
  color: var(--success-ink);
  background: var(--success-soft);
}

.type-badge.in-progress,
.status-badge.warning {
  color: var(--warning-ink);
  background: var(--warning-soft);
}

.status-badge.danger {
  color: var(--danger-ink);
  background: var(--danger-soft);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-soft {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
}

.table-soft thead th {
  padding: 0.62rem 0.68rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: rgba(247, 249, 252, 0.82);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table-soft tbody td {
  padding: 0.72rem 0.68rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table-soft tbody tr:last-child td {
  border-bottom: 0;
}

.table-soft tbody tr:hover {
  background: rgba(89, 98, 112, 0.035);
}

.table-note {
  display: block;
  margin-top: 0.16rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.form-control,
.form-select {
  min-height: 2.55rem;
  border-color: var(--line);
  border-radius: 0.68rem;
  color: var(--ink);
  background-color: var(--surface);
}

textarea.form-control {
  min-height: 6rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(89, 98, 112, 0.12);
}

.form-label {
  margin-bottom: 0.36rem;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 650;
}

.form-text {
  color: var(--muted);
  font-size: 0.8rem;
}

/* Keep clickable checkbox and radio labels aligned when spacing utilities add padding. */
label.form-check:not(.form-switch) {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  min-width: 0;
  padding-left: 0;
}

label.form-check:not(.form-switch) > .form-check-input {
  float: none;
  flex: 0 0 auto;
  margin: 0.2rem 0 0;
}

label.form-check:not(.form-switch) > .form-check-label {
  min-width: 0;
  line-height: 1.45;
}

.nav-tabs {
  gap: 0.25rem;
  padding: 0.32rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.nav-tabs .nav-link {
  border: 0;
  border-radius: 0.7rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.nav-tabs .nav-link:hover,
.nav-tabs .nav-link:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-tabs .nav-link.active {
  color: #fff;
  background: var(--accent);
}

.empty-state,
.queue-empty,
.invite-empty {
  padding: 1.5rem 0;
  color: var(--muted);
}

.modal-backdrop.show {
  opacity: 0.42;
}

.modal-content,
.admin-confirm-fallback-dialog {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(20, 30, 56, 0.18);
}

.modal-header,
.modal-footer {
  padding: 0.9rem 1.1rem;
  border-color: var(--line);
}

.modal-body {
  padding: 1.1rem;
}

.modal-title {
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.modal-footer .btn {
  min-height: 2.45rem;
  padding-inline: 0.85rem;
  border-radius: 0.72rem;
  font-weight: 650;
}

.modal-footer .btn-light {
  border-color: var(--line);
  color: var(--ink);
  background: var(--surface);
}

.admin-confirm-fallback-dialog {
  /* Native dialogs do not inherit Bootstrap's modal section variables. */
  --bs-modal-header-border-width: 1px;
  --bs-modal-header-border-color: var(--line);
  --bs-modal-footer-border-width: 1px;
  --bs-modal-footer-border-color: var(--line);
  --bs-modal-title-line-height: 1.5;
  --bs-modal-footer-gap: 0.5rem;
  width: min(500px, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: 0;
}

.admin-confirm-fallback-dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.admin-confirm-fallback-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem - 2px);
  max-height: calc(100dvh - 2rem - 2px);
}

.admin-confirm-fallback-dialog .modal-body {
  overflow-y: auto;
}

.admin-confirm-fallback-dialog .modal-title {
  overflow-wrap: anywhere;
}

.admin-confirm-fallback-message {
  margin: 0;
  color: var(--muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.document-editor-sticky-toolbar {
  position: sticky;
  top: 0.75rem;
  z-index: 30;
  box-shadow: 0 0.55rem 1.1rem rgba(20, 30, 56, 0.12);
}

.document-table-quick-tools[hidden],
.document-table-tools[hidden],
.document-table-dialog [hidden] {
  display: none !important;
}

.document-table-dialog.document-editor-dialog {
  width: min(1040px, calc(100vw - 2rem));
  max-width: none;
  padding: 0;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 1rem;
  background: var(--surface, #fff);
  color: var(--ink, #252b33);
  box-shadow: 0 1.5rem 5rem rgba(20, 30, 56, 0.25);
}

.document-table-dialog::backdrop {
  background: rgba(19, 28, 36, 0.48);
}

.document-table-dialog.document-editor-dialog > form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 3rem);
  max-height: calc(100dvh - 3rem);
  padding: 0;
  overflow: hidden;
}

.document-table-dialog-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--line, #d8dee4);
}

.document-table-dialog-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 750;
}

.document-table-close {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.65rem;
  background: var(--surface, #fff);
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
}

.document-table-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.document-table-controls {
  min-width: 0;
  padding: 1.2rem 1.4rem;
}

.document-table-section {
  min-width: 0;
  margin: 0 0 1.35rem;
  padding: 0;
  border: 0;
}

.document-table-section:last-child {
  margin-bottom: 0;
}

.document-table-section legend {
  float: none;
  width: auto;
  margin: 0 0 0.75rem;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 750;
}

.document-table-section .form-label {
  display: block;
  min-width: 0;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.document-table-section .form-label > input,
.document-table-section .form-label > select,
.document-table-colour {
  margin-top: 0.3rem;
}

.document-table-section .form-check {
  margin-top: 0.75rem;
  font-size: 0.87rem;
}

.document-table-dialog .document-editor-dialog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 0.8rem;
}

.document-table-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.document-table-presets button {
  min-height: 2.75rem;
  padding: 0.5rem;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.6rem;
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
}

.document-table-presets button[aria-pressed="true"] {
  border-color: var(--brand-primary, #596270);
  background: color-mix(in srgb, var(--brand-primary, #596270) 10%, #fff);
  font-weight: 700;
}

.document-table-size-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.3rem;
  width: min(100%, 17rem);
}

.document-table-size-grid button {
  aspect-ratio: 1.5;
  min-height: 1.75rem;
  padding: 0;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.25rem;
  background: var(--surface-soft, #f7f9fb);
}

.document-table-size-grid button[aria-pressed="true"] {
  border-color: var(--brand-primary, #596270);
  background: color-mix(in srgb, var(--brand-primary, #596270) 26%, #fff);
}

.document-table-dialog button:focus-visible {
  outline: 3px solid var(--brand-primary, #596270);
  outline-offset: 2px;
}

.document-table-colour {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.document-table-colour input[type="color"] {
  flex: 0 0 2.3rem;
  width: 2.3rem;
  height: 2.3rem;
  padding: 0.15rem;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.45rem;
  background: #fff;
  cursor: pointer;
}

.document-table-colour input[type="text"] {
  min-width: 0;
  padding: 0.5rem 0.4rem;
  font-size: 0.78rem;
}

.document-table-clear {
  padding: 0.25rem;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--muted, #68727d);
  font: inherit;
  font-size: 0.7rem;
}

.document-table-preview-card {
  position: sticky;
  top: 0;
  align-self: start;
  min-width: 0;
  padding: 1.4rem;
  background: linear-gradient(145deg, #f5f7f9, #edf1f5);
}

.document-table-preview-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 700;
}

.document-table-preview-card > p {
  font-size: 0.83rem;
  line-height: 1.5;
}

.document-table-preview {
  box-sizing: border-box;
  min-height: 10rem;
  max-height: min(65vh, 38rem);
  padding: 1rem;
  overflow: auto;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.6rem;
  background: #fff;
  box-shadow: 0 0.35rem 1rem rgba(20, 30, 56, 0.06);
  font-size: 0.85rem;
}

.document-table-preview table {
  width: 100%;
  border-collapse: collapse;
}

.document-table-preview th,
.document-table-preview td {
  padding: 0.5rem;
  border: 1px solid #cad1d8;
  overflow-wrap: anywhere;
}

.document-table-preview table.doc-table-equal { table-layout: fixed; }
.document-table-preview table.doc-table-key-value tr > :first-child { width: 38%; }
.document-table-preview table.doc-table-width-full { width: 100% !important; }
.document-table-preview table.doc-table-width-three-quarter { width: 75% !important; }
.document-table-preview table.doc-table-width-half { width: 50% !important; }
.document-table-preview table.doc-table-width-quarter { width: 25% !important; }
table.doc-table-width-content { width: auto !important; max-width: 100% !important; table-layout: auto !important; }
table.doc-table-width-content tr > :first-child { width: auto !important; }
table.doc-table-width-content th,
table.doc-table-width-content td { overflow-wrap: anywhere; }

@media screen {
  hr.doc-page-break {
    display: block;
    position: relative;
    height: 1.5rem;
    margin: 1.5rem 0 0.75rem;
    padding: 0;
    border: 0;
    border-top: 1px dashed #8b98a5;
    background: none;
    opacity: 1;
    overflow: visible;
    clear: both;
    cursor: pointer;
  }
  hr.doc-page-break::after {
    content: "Page break";
    position: absolute;
    top: -0.75em;
    left: 50%;
    transform: translateX(-50%);
    padding: 0 0.75rem;
    background: #fff;
    color: #596773;
    font: 600 0.8rem/1.5 system-ui, sans-serif;
    white-space: nowrap;
  }
  hr.doc-page-break[aria-selected="true"] { outline: 2px solid var(--brand-primary, #596270); outline-offset: 4px; }
}
.document-page-break-status { margin: 0.4rem 0; color: var(--muted, #596773); font-size: 0.85rem; }
.document-page-break-status:empty { display: none; }
@media print {
  hr.doc-page-break { display: block; height: 0; margin: 0; padding: 0; border: 0; page-break-after: always; break-after: page; }
  hr.doc-page-break::before, hr.doc-page-break::after { content: none; }
  .document-page-break-status { display: none; }
}
.document-table-preview table.doc-table-align-left { margin-left: 0 !important; margin-right: auto !important; }
.document-table-preview table.doc-table-align-center { margin-left: auto !important; margin-right: auto !important; }
.document-table-preview table.doc-table-align-right { margin-left: auto !important; margin-right: 0 !important; }

.document-table-preview [data-table-preview-cell] {
  cursor: pointer;
  user-select: none;
}

.document-table-preview [data-table-preview-cell="active"] {
  outline: 2px solid var(--brand-primary, #596270);
  outline-offset: -2px;
}

.document-table-preview [data-table-preview-cell="scope"] {
  outline: 2px dashed var(--brand-primary, #596270);
  outline-offset: -2px;
}

.document-table-history {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.document-table-padding > .form-label {
  display: block;
  max-width: 12rem;
}

.document-inline-dialog.document-editor-dialog {
  box-sizing: border-box;
  width: min(620px, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 1rem;
  color: var(--ink, #252b33);
  background: var(--surface, #fff);
  box-shadow: 0 1.5rem 5rem rgba(20, 30, 56, 0.25);
}

.document-inline-dialog::backdrop { background: rgba(19, 28, 36, 0.48); }
.document-inline-dialog [hidden] { display: none !important; }
.document-inline-dialog > form { display: flex; flex-direction: column; max-height: calc(100dvh - 2rem - 2px); padding: 0; margin: 0; }
.document-inline-body { display: grid; grid-auto-rows: max-content; gap: 0.85rem; min-height: 0; padding: 1.4rem; overflow-y: auto; }
.document-inline-dialog h2 { margin: 0 0 0.3rem; font-size: 1.2rem; }
.document-inline-dialog .form-label { display: block; min-width: 0; margin: 0; font-size: 0.9rem; font-weight: 600; }
.document-inline-dialog .form-label > input { margin-top: 0.35rem; }
.document-inline-dialog .form-text { margin: -0.25rem 0 0; font-size: 0.8rem; line-height: 1.45; color: var(--muted, #5d6873); }
.document-inline-colour { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; }
.document-inline-colour input[type="color"] { width: 2.6rem; height: 2.6rem; padding: 0.25rem; border: 1px solid var(--line, #d8dee4); border-radius: 0.4rem; background: #fff; }
.document-inline-colour input[type="text"] { min-width: 0; max-width: 12rem; }
.document-inline-style { display: flex; flex-wrap: wrap; gap: 0.7rem 1.3rem; margin: 0; padding: 0; border: 0; font-size: 0.9rem; }
.document-inline-style legend { float: none; width: 100%; margin-bottom: 0.35rem !important; }
.document-inline-icon-settings { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.document-icon-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; max-height: 16rem; overflow-y: auto; padding: 0.2rem; }
.document-icon-choice { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.45rem; min-height: 5rem; min-width: 0; padding: 0.65rem 0.25rem; border: 1px solid var(--line, #d8dee4); border-radius: 0.6rem; color: var(--ink, #252b33); background: var(--surface, #fff); font-size: 0.8rem; line-height: 1.3; }
.document-icon-choice:hover { background: var(--surface-soft, #f0f4f8); }
.document-icon-choice[aria-pressed="true"] { outline: 2px solid var(--brand-primary, #596270); outline-offset: -2px; background: var(--surface-soft, #f0f4f8); }
.document-inline-preview { display: flex; flex-direction: column; gap: 0.75rem; align-items: center; justify-content: center; min-height: 4rem; padding: 0.75rem; border: 1px solid var(--line, #d8dee4); border-radius: 0.6rem; background: #fff; }
.document-font-size-preview { min-height: 5rem; max-height: 16rem; overflow: auto; padding: 1rem; border: 1px solid var(--line, #d8dee4); border-radius: 0.6rem; background: #fff; color: #334155; line-height: 1.45; overflow-wrap: anywhere; }
.document-icon-preview-line { display: block; line-height: 1.5; color: #334155; font-size: 1rem; }
.document-icon-row-preview { width: auto; border-collapse: collapse; color: #334155; font-size: 1rem; }
.document-icon-row-preview td { padding: 0.5rem; border: 1px dashed #cbd3da; }
.document-inline-message { margin: 0; padding: 0.65rem; border-left: 3px solid #a83535; color: #8d2020; background: #fff3f3; font-size: 0.85rem; }
.document-inline-dialog .document-editor-dialog-actions { display: flex; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; margin: 0; padding: 0.85rem 1.4rem; border-top: 1px solid var(--line, #d8dee4); }
.document-inline-dialog [data-inline-remove] { margin-right: auto; }
[contenteditable="true"] img[data-document-icon] { cursor: pointer; }

@media (max-width: 480px) {
  .document-inline-body { padding: 1rem; }
  .document-inline-dialog .document-editor-dialog-actions { padding: 0.85rem 1rem; }
  .document-icon-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.document-table-dialog .document-table-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.document-table-dialog .document-editor-dialog-actions {
  display: flex;
  flex-shrink: 0;
  justify-content: flex-end;
  gap: 0.65rem;
  margin: 0;
  padding: 0.9rem 1.4rem;
  border-top: 1px solid var(--line, #d8dee4);
  background: var(--surface, #fff);
}

@media (max-width: 720px) {
  .document-table-workspace { grid-template-columns: 1fr; }
  .document-table-preview-card { position: static; }
  .document-table-dialog.document-editor-dialog { width: calc(100vw - 1rem); }
  .document-table-controls, .document-table-preview-card { padding: 1rem; }
  .document-table-preview { max-height: 18rem; }
}

@media (max-width: 380px) {
  .document-table-dialog .document-editor-dialog-grid { grid-template-columns: 1fr; }
}

.document-placeholder-panel {
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.8rem;
  background: var(--surface-soft, #f7f9fb);
  padding: 0.8rem 0.9rem;
}

.document-placeholder-panel > summary {
  cursor: pointer;
  font-weight: 700;
}

.document-placeholder-panel-toolbar {
  position: relative;
  align-self: center;
  margin: 0 0 0 0.25rem;
  padding: 0;
  border: 0;
  background: transparent;
}

.document-placeholder-panel-toolbar > summary {
  list-style: none;
  border: 1px solid #ccd3da;
  border-radius: 6px;
  background: #fff;
  padding: 0.35rem 0.55rem;
  white-space: nowrap;
}

.document-placeholder-panel-toolbar > summary::-webkit-details-marker {
  display: none;
}

.document-placeholder-panel-toolbar > summary::after {
  content: "\25be";
  margin-left: 0.4rem;
  font-size: 0.78em;
}

.document-placeholder-panel-toolbar[open] > summary::after {
  content: "\25b4";
}

.document-placeholder-popover {
  display: none;
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 55;
  box-sizing: border-box;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(65vh, 34rem);
  overflow: auto;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.8rem;
  background: var(--surface, #fff);
  padding: 0.9rem;
  box-shadow: 0 1rem 2.5rem rgba(20, 30, 56, 0.2);
}

.document-placeholder-panel-toolbar[open] > .document-placeholder-popover {
  display: block;
}

.document-placeholder-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.document-placeholder-button {
  border: 1px solid color-mix(in srgb, var(--brand-primary, #596270) 32%, #d8dee4);
  border-radius: 999px;
  background: #fff;
  color: var(--ink, #252b33);
  padding: 0.38rem 0.65rem;
  line-height: 1.2;
}

.document-placeholder-button:hover,
.document-placeholder-button:focus-visible {
  border-color: var(--brand-primary, #596270);
  background: color-mix(in srgb, var(--brand-primary, #596270) 8%, #fff);
}

.document-placeholder-button code {
  color: inherit;
  font-size: 0.82rem;
}

.document-placeholder-floating [hidden] {
  display: none !important;
}

.document-placeholder-floating-toggle {
  position: fixed;
  z-index: 100;
  top: 50%;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 2.75rem;
  padding: 0.95rem 0.7rem;
  border: 1px solid var(--brand-primary, #596270);
  border-right: 0;
  border-radius: 0.85rem 0 0 0.85rem;
  background: var(--brand-primary, #596270);
  color: #fff;
  box-shadow: -0.25rem 0.35rem 1.2rem rgba(20, 30, 56, 0.18);
  font: inherit;
  font-weight: 700;
  writing-mode: vertical-rl;
  transform: translateY(-50%);
  cursor: pointer;
}

.document-placeholder-floating-toggle[aria-expanded="true"] {
  background: var(--surface, #fff);
  color: var(--brand-primary, #596270);
}

.document-placeholder-floating-toggle:focus-visible,
.document-placeholder-floating-close:focus-visible,
.document-placeholder-floating-search input:focus-visible {
  outline: 3px solid var(--brand-primary, #596270);
  outline-offset: 3px;
}

.document-placeholder-floating-panel {
  position: fixed;
  z-index: 100;
  top: 50%;
  right: 3.5rem;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(24rem, calc(100vw - 4.5rem));
  max-height: min(42rem, calc(100vh - 8rem));
  max-height: min(42rem, calc(100dvh - 8rem));
  border: 1px solid var(--line, #d8dee4);
  border-radius: 1rem;
  background: var(--surface, #fff);
  color: var(--ink, #252b33);
  box-shadow: 0 1rem 3rem rgba(20, 30, 56, 0.22);
  transform: translateY(-50%);
  overflow: hidden;
  animation: document-placeholder-reveal 140ms ease-out;
}

.document-placeholder-floating-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 0.9rem 0 1.1rem;
}

.document-placeholder-floating-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 750;
}

.document-placeholder-floating-close {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.65rem;
  background: var(--surface, #fff);
  color: inherit;
  cursor: pointer;
}

.document-placeholder-floating-help {
  margin: 0;
  padding: 0.55rem 1.1rem 0.85rem;
  color: var(--muted, #68727d);
  font-size: 0.85rem;
  line-height: 1.5;
}

.document-placeholder-floating-search {
  display: grid;
  gap: 0.35rem;
  margin: 0 1.1rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.document-placeholder-floating-search input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line, #d8dee4);
  border-radius: 0.65rem;
  background: var(--surface-soft, #f7f9fb);
  color: inherit;
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
}

.document-placeholder-floating-results {
  min-height: 0;
  padding: 0 1.1rem 0.8rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.document-placeholder-floating-group + .document-placeholder-floating-group {
  margin-top: 1rem;
}

.document-placeholder-floating-group h3 {
  margin: 0 0 0.45rem;
  color: var(--muted, #68727d);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.document-placeholder-floating-group .document-placeholder-button {
  display: grid;
  gap: 0.3rem;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.65rem;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}

.document-placeholder-floating-label {
  font-size: 0.87rem;
  font-weight: 650;
}

.document-placeholder-floating-group code {
  color: var(--muted, #68727d);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.document-placeholder-floating-empty {
  margin: 0;
  padding: 1rem 1.1rem 1.5rem;
  color: var(--muted, #68727d);
  font-size: 0.9rem;
}

.document-placeholder-floating-status {
  margin: 0;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--line, #d8dee4);
  background: var(--surface-soft, #f7f9fb);
  font-size: 0.8rem;
}

.document-placeholder-floating-header,
.document-placeholder-floating-help,
.document-placeholder-floating-search,
.document-placeholder-floating-status {
  flex-shrink: 0;
}

@keyframes document-placeholder-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 640px), (max-height: 650px) {
  .document-placeholder-floating-panel {
    top: max(5rem, env(safe-area-inset-top));
    bottom: max(1rem, env(safe-area-inset-bottom));
    max-height: calc(100vh - 6rem);
    max-height: calc(100dvh - 6rem);
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .document-placeholder-floating-panel {
    animation: none;
  }
}

@media print {
  .document-placeholder-floating {
    display: none !important;
  }
}

.document-placeholder-token {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 0.35rem;
  margin: 0 0.08rem;
  padding: 0.18rem 0.3rem 0.18rem 0.48rem;
  border: 1px solid color-mix(in srgb, var(--brand-primary, #596270) 42%, #cfd6dd);
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-primary, #596270) 10%, #fff);
  color: var(--ink, #252b33);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.82em;
  font-style: inherit;
  font-weight: inherit;
  line-height: 1.35;
  vertical-align: baseline;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.document-placeholder-token:focus,
.document-placeholder-token-selected {
  outline: 2px solid color-mix(in srgb, var(--brand-primary, #596270) 42%, transparent);
  outline-offset: 1px;
  border-color: var(--brand-primary, #596270);
}

.document-placeholder-token-remove {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  color: #7d2630;
  font: 800 1rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.document-placeholder-token-remove:hover {
  background: #f7dfe2;
}

@media (max-width: 991.98px) {
  .document-editor-sticky-toolbar {
    top: calc(4.25rem + 0.5rem);
  }
}

@media (max-width: 767.98px) {
  .document-placeholder-popover {
    position: fixed;
    top: calc(4.25rem + 4.75rem);
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    width: auto;
    max-height: none;
  }
}

@media print {
  .document-editor-sticky-toolbar {
    position: static;
    box-shadow: none;
  }

  .document-placeholder-panel-toolbar {
    display: none;
  }
}

@media (max-width: 767.98px) {
  .topbar,
  .panel-header,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar > *,
  .topbar > :first-child {
    width: 100%;
    flex: 0 1 auto;
  }

  .hero-actions,
  .panel-actions,
  .inline-actions {
    justify-content: flex-start;
  }

  .page-title {
    font-size: 1.7rem;
  }

  .panel,
  .section-card {
    padding: 0.95rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .focus-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .focus-count {
    grid-column: 2;
    justify-self: start;
  }

  .table-soft {
    min-width: 38rem;
  }
}
