/* DOC-EDITOR — A4 fullscreen stage (не меняет Desk preview) */

.doc-ed-overlay {
  position: fixed;
  inset: 0;
  z-index: 13000;
  background: rgba(20, 28, 36, 0.55);
  display: flex;
  flex-direction: column;
}

.doc-ed-overlay[hidden] {
  display: none !important;
}

.doc-ed,
.doc-ed-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
  background: #c5ccd4;
  color: #111;
  font-family: "Segoe UI", "Liberation Sans", Arial, sans-serif;
}

.doc-ed-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #f4f6f8;
  border-bottom: 1px solid #c8d0d8;
  position: sticky;
  top: 0;
  z-index: 2;
}

.doc-ed-toolbar__group {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
  padding-right: 0.5rem;
  border-right: 1px solid #d5dde5;
}

.doc-ed-toolbar__group--end {
  margin-left: auto;
  border-right: 0;
}

.doc-ed-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  border: 1px solid #b8c2cc;
  border-radius: 4px;
  background: #fff;
  color: #1a2430;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
}

.doc-ed-btn:hover {
  background: #eef2f6;
}

.doc-ed-btn.is-active {
  background: #d9e6f5;
  border-color: #6a8fb8;
}

.doc-ed-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.doc-ed-color {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.doc-ed-color input[type="color"] {
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid #b8c2cc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.doc-ed-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: #e8edf2;
  border-bottom: 1px solid #c8d0d8;
}

.doc-ed-title {
  flex: 1;
  min-width: 0;
  border: 1px solid #b8c2cc;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  background: #fff;
}

.doc-ed-status {
  font-size: 0.8rem;
  color: #3a4a5a;
  white-space: nowrap;
}

.doc-ed-status.is-dirty {
  color: #8a5a12;
}

.doc-ed-stage {
  flex: 1;
  overflow: auto;
  padding: 1.5rem 1rem 3rem;
}

.doc-ed-a4 {
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  padding: 18mm 16mm;
  box-sizing: border-box;
}

.doc-ed-a4 .ProseMirror,
.doc-ed-a4__page {
  outline: none;
  min-height: 250mm;
  font-size: 12pt;
  line-height: 1.35;
  color: #111;
}

.doc-ed-a4 .ProseMirror table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  word-wrap: break-word;
  margin: 0.6em 0;
}

.doc-ed-a4 .ProseMirror td,
.doc-ed-a4 .ProseMirror th {
  border: 1px solid #333;
  padding: 6px 8px;
  vertical-align: top;
  min-width: 1.5em;
}

.doc-ed-a4 .ProseMirror th {
  background: #f0f2f4;
  font-weight: 700;
}

.doc-ed-a4 .ProseMirror p {
  margin: 0 0 0.55em;
}

.doc-ed-loading {
  padding: 2rem;
  text-align: center;
}

.doc-ed-launch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.doc-ed-btn--accent {
  background: #1f4b7a;
  color: #fff;
  border-color: #1f4b7a;
}

.doc-ed-btn--accent:hover {
  background: #16375a;
}

.doc-ed-btn--danger {
  background: #c62828;
  color: #fff;
  border-color: #b71c1c;
  font-weight: 700;
  min-width: 4.2rem;
}

.doc-ed-btn--danger:hover {
  background: #b71c1c;
}

.doc-ed-a4__page[contenteditable="true"] {
  outline: none;
  min-height: 250mm;
  font-size: 12pt;
  line-height: 1.35;
}

.doc-ed-a4__page[contenteditable="true"] table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  word-wrap: break-word;
}

.doc-ed-a4__page[contenteditable="true"] td,
.doc-ed-a4__page[contenteditable="true"] th {
  border: 1px solid #333;
  padding: 6px 8px;
  vertical-align: top;
}

.doc-ed-profile-picker {
  position: absolute;
  top: 3.5rem;
  right: 1rem;
  z-index: 5;
  width: min(360px, 92vw);
  max-height: 70vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #b8c2cc;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  padding: 0.5rem;
}

.doc-ed-profile-picker__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0.35rem;
}

.doc-ed-profile-picker__block {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid #6a8fb8;
  border-radius: 6px;
  background: #eef5fc;
  cursor: pointer;
  font-weight: 600;
}

.doc-ed-profile-picker__group {
  font-size: 0.75rem;
  color: #5a6a7a;
  margin: 0.5rem 0.35rem 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-ed-profile-picker__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #e5eaf0;
  background: transparent;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
}

.doc-ed-profile-picker__item:hover {
  background: #f3f7fb;
}

.doc-ed-profile-picker__item em {
  font-style: normal;
  color: #334;
  font-size: 0.85rem;
  word-break: break-word;
}

.doc-ed-profile-picker__empty {
  font-size: 0.85rem;
  color: #667;
  padding: 0.5rem;
  margin: 0;
}

.doc-ed {
  position: relative;
}

.doc-ed-mode-badge {
  display: inline-block;
  padding: 0.35rem 0.55rem;
  border-radius: 4px;
  background: #1f4b7a;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.doc-ed-form-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.doc-ed-form-fields {
  overflow: auto;
  background: #f4f6f8;
  border-right: 1px solid #c8d0d8;
  padding: 0.75rem;
}

.doc-ed-form-fields__title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.doc-ed-form-field {
  display: block;
  margin-bottom: 0.65rem;
}

.doc-ed-form-field__label {
  display: block;
  font-size: 0.75rem;
  color: #4a5a6a;
  margin-bottom: 0.2rem;
}

.doc-ed-form-field__input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #b8c2cc;
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  font: inherit;
  background: #fff;
}

.doc-ed-form-preview {
  overflow: auto;
  background: #c5ccd4;
  padding: 1rem;
}

.doc-ed-form-preview--oo {
  padding: 0;
  background: #e5e5e5;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.doc-ed-onlyoffice,
#docEdOnlyOffice {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.doc-ed-preview-page {
  max-width: 210mm;
  margin: 0 auto 1rem;
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}

.doc-ed-preview-page__img {
  display: block;
  width: 100%;
  height: auto;
}

.doc-ed-preview-empty,
.doc-ed-preview-page__loading {
  padding: 1.5rem;
  text-align: center;
  color: #445;
}

@media (max-width: 900px) {
  .doc-ed-form-layout {
    grid-template-columns: 1fr;
  }
  .doc-ed-form-fields {
    max-height: 40vh;
    border-right: 0;
    border-bottom: 1px solid #c8d0d8;
  }
}

@media print {
  .doc-ed-form-fields,
  .doc-ed-toolbar,
  .doc-ed-meta {
    display: none !important;
  }
  .doc-ed-form-preview,
  .doc-ed-preview-page,
  .doc-ed-preview-page * {
    visibility: visible !important;
  }
  .doc-ed-preview-page {
    box-shadow: none !important;
    margin: 0;
    page-break-after: always;
  }
}

@media print {
  body * {
    visibility: hidden !important;
  }
  .doc-ed-a4,
  .doc-ed-a4 * {
    visibility: visible !important;
  }
  .doc-ed-toolbar,
  .doc-ed-meta,
  .doc-ed-btn {
    display: none !important;
  }
  .doc-ed-overlay,
  .doc-ed,
  .doc-ed-stage {
    position: static !important;
    background: #fff !important;
    overflow: visible !important;
    height: auto !important;
    padding: 0 !important;
  }
  .doc-ed-a4 {
    box-shadow: none !important;
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
  }
  @page {
    size: A4;
    margin: 18mm 16mm;
  }
}
