.doc-viewer {
  box-sizing: border-box;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-50% + 8px));
  margin: 0;
  width: 90vw;
  height: min(90vh, 960px);
  max-width: 90vw;
  max-height: none;
  padding: 0;
  border: 1px solid #35600A;
  border-radius: 4px;
  background: #fff;
  color: #222;
  box-shadow: 0 12px 40px rgba(10, 25, 0, 0.35);
}

.doc-viewer[open] {
  display: block;
}

.doc-viewer::backdrop {
  background: rgba(10, 25, 0, 0.55);
}

.doc-viewer-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.doc-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem 1.2rem;
  flex-shrink: 0;
  padding: 0.7rem 1rem;
  background: #fff;
  color: #222;
  border-bottom: 3px solid #4F8B0D;
}

.doc-viewer-heading {
  min-width: 0;
  flex: 1;
}

.doc-viewer-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: #003399;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.doc-viewer-filename {
  margin: 1px 0 0;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.2;
  color: #444;
  word-break: break-all;
}

.doc-viewer-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.5rem;
}

.doc-viewer-download,
.doc-viewer-close {
  display: inline-block;
  padding: 0.45rem 1rem;
  border: 1px solid transparent;
  border-radius: 3px;
  font: inherit;
  font-size: 16px;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.doc-viewer-download {
  background: #4F8B0D;
  border-color: #3F6F0A;
  color: #fff;
}

.doc-viewer-download:hover,
.doc-viewer-download:focus {
  background: #63A812;
  color: #fff;
  text-decoration: none;
}

.doc-viewer-close {
  background: #003399;
  border-color: #003399;
  color: #fff;
}

.doc-viewer-close:focus {
  background: #003399;
  border-color: #003399;
  color: #fff;
}

.doc-viewer-close:hover {
  background: #0044CC;
  border-color: #0044CC;
  color: #fff;
}

.doc-viewer-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #5c5c5c;
}

.doc-viewer-body.is-xlsx {
  overflow: hidden;
  background: #fff;
}

.doc-viewer.is-image {
  width: 90vw;
  max-width: 90vw;
  height: auto;
  max-height: 90vh;
}

.doc-viewer.is-image .doc-viewer-filename,
.doc-viewer.is-image .doc-viewer-download {
  display: none;
}

.doc-viewer-body.is-image {
  overflow: auto;
  display: block;
}

.doc-viewer-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.doc-viewer-xlsx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #fff;
}

#doc-viewer-luckysheet {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.doc-viewer-body.is-xlsx #luckysheet-wa-calculate,
.doc-viewer-body.is-xlsx #luckysheet-functionbox-container,
.doc-viewer-body.is-xlsx .luckysheet-wa-calculate,
.doc-viewer-body.is-xlsx .luckysheet-wa-editor {
  display: none !important;
}

body:has(.doc-viewer[open]) .luckysheet-modal-dialog,
body:has(.doc-viewer[open]) .luckysheet-modal-dialog-slider,
body:has(.doc-viewer[open]) #luckysheet-search-replace,
body:has(.doc-viewer[open]) .luckysheet-cols-menu {
  display: none !important;
}

.doc-viewer-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #525659;
}

.doc-viewer-loading,
.doc-viewer-message {
  max-width: 36rem;
  margin: 3rem auto;
  padding: 1.25rem 1.5rem;
  background: #fff;
  color: #222;
  border-radius: 4px;
  text-align: center;
}

.doc-viewer-loading {
  font-weight: 700;
}

.doc-viewer-message p {
  margin: 0 0 0.75rem;
}

.doc-viewer-message p:last-child {
  margin-bottom: 0;
}

.doc-viewer-error {
  border-left: 4px solid #a94442;
}

.doc-viewer-pdfjs {
  box-sizing: border-box;
  width: 100%;
  padding: 0.75rem;
}

.doc-viewer-pdf-page {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto 0.75rem;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

.doc-viewer-docx {
  box-sizing: border-box;
  width: 100%;
  padding: 1rem 0.75rem 2rem;
}

.doc-viewer-docx .docx-wrapper,
.doc-viewer-docx .docx-preview-wrapper {
  background: transparent !important;
  padding: 0 !important;
}

.doc-viewer-docx section.docx,
.doc-viewer-docx section.docx-preview,
.doc-viewer-docx .docx-wrapper > section {
  margin: 0 auto 1rem !important;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

@media (max-width: 640px) {
  .doc-viewer {
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100vw - 12px);
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
  }

  .doc-viewer-header {
    flex-direction: column;
    align-items: stretch;
  }

  .doc-viewer-actions {
    justify-content: flex-end;
  }

  .doc-viewer-title {
    font-size: 18px;
  }

  .doc-viewer-filename {
    font-size: 14px;
  }

  .doc-viewer.is-image {
    max-width: calc(100vw - 12px);
  }
}

body.blackyellow .doc-viewer {
  background: #000;
  color: #ff0;
  border-color: #ff0;
}

body.blackyellow .doc-viewer::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

body.blackyellow .doc-viewer-header {
  background: #000;
  border-bottom: 3px solid #ff0;
}

body.blackyellow .doc-viewer-title {
  color: #ff0;
}

body.blackyellow .doc-viewer-filename {
  color: #cccc00;
}

body.blackyellow .doc-viewer-download,
body.blackyellow .doc-viewer-close {
  background: #000;
  border-color: #ff0;
  color: #ff0;
}

body.blackyellow .doc-viewer-download:hover,
body.blackyellow .doc-viewer-download:focus,
body.blackyellow .doc-viewer-close:hover,
body.blackyellow .doc-viewer-close:focus {
  background: #ff0;
  color: #000;
}

body.blackyellow .doc-viewer-body {
  background: #111;
}

body.blackyellow .doc-viewer-loading,
body.blackyellow .doc-viewer-message {
  background: #000;
  color: #ff0;
  border: 1px solid #ff0;
}
