.knowledge-page {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  animation: fadeUp 220ms var(--ease) both;
}

.knowledge-grid {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0;
  gap: 0;
  transition: grid-template-columns 320ms var(--ease), gap 320ms var(--ease);
}

.knowledge-grid.has-preview {
  grid-template-columns: minmax(560px, 1fr) minmax(420px, 0.82fr);
  gap: 16px;
}

.knowledge-main,
.preview-column {
  min-width: 0;
  min-height: 0;
}

.knowledge-main {
  overflow: hidden;
}

.library-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 16px 18px;
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-title h2,
.preview-head h2 {
  color: #0f172a;
  font-size: 16px;
  font-weight: 850;
}

.panel-title p,
.preview-head p {
  margin-top: 6px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.file-search {
  width: min(320px, 100%);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid #d7e0ea;
  border-radius: 10px;
  background: #fff;
  color: #64748b;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.file-search:focus-within {
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.14);
}

.file-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  color: #0f172a;
  font-size: 13px;
  background: transparent;
}

.file-search input:focus {
  outline: none;
}

.library-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.folder-rail {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  border-right: 1px solid #edf2f7;
  padding-right: 12px;
}

.folder-tree {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
}

.folder-tree button {
  min-height: 34px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #334155;
  font-size: 13px;
  text-align: left;
}

.folder-tree button.active {
  background: #dcfce7;
  color: #059669;
  font-weight: 850;
}

.folder-tree b {
  min-width: 24px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
}

.new-folder-btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(16, 185, 129, .28);
  border-radius: 8px;
  background: #f0fdf4;
  color: #059669;
  font-size: 13px;
  font-weight: 850;
}

.new-folder-btn.fixed {
  border-color: rgba(148, 163, 184, 0.3);
  background: #f8fafc;
  color: #64748b;
}

.document-area {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.upload-input {
  display: none;
}

.upload-zone {
  min-height: 112px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1px dashed #93c5fd;
  border-radius: 10px;
  background: #f8fbff;
  color: #334155;
  text-align: center;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, opacity 180ms ease;
}

.upload-zone:hover {
  border-color: #60a5fa;
  background: #f3f8ff;
}

.upload-zone.disabled {
  cursor: default;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.upload-zone.busy {
  opacity: 0.72;
}

.upload-zone i {
  color: #2563eb;
  font-size: 31px;
}

.upload-zone strong {
  font-size: 13px;
  font-weight: 850;
}

.upload-zone span {
  color: #64748b;
  font-size: 12px;
}

.doc-table-wrap {
  min-height: 0;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 690px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #edf2f7;
  color: #24324a;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f7fafc;
  color: #64748b;
  font-weight: 800;
  white-space: nowrap;
}

.doc-row {
  cursor: pointer;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.doc-row:hover {
  background: #f8fbff;
}

.doc-row.selected {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08), rgba(59, 130, 246, 0.04));
  box-shadow: inset 3px 0 0 #10b981;
}

.file-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 750;
  white-space: nowrap;
}

.file-name .pdf,
.viewer-filetype.pdf { color: #ef4444; }
.file-name .word,
.viewer-filetype.word { color: #2563eb; }
.file-name .excel,
.viewer-filetype.excel { color: #10b981; }

.doc-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-weight: 750;
}

.state-tag {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.state-tag.success {
  background: #dcfce7;
  color: #059669;
}

.state-tag.warning {
  background: #ffedd5;
  color: #f97316;
}

.more-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #2563eb;
}

.more-btn.danger {
  color: #dc2626;
}

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

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.empty-row {
  color: #64748b;
  text-align: center;
}

.list-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.pager {
  display: inline-flex;
  justify-content: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.pager button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.pager button:hover:not(.active) {
  background: #fff;
  color: #059669;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
}

.pager button.active {
  background: #059669;
  color: #fff;
  box-shadow: 0 8px 16px rgba(5, 150, 105, .20);
}

.list-foot .page-summary {
  color: #64748b;
  font-size: 14px;
  font-weight: 650;
}

.page-nav {
  color: #64748b;
}

.page-size-wrap {
  position: relative;
  justify-self: end;
}

.page-size {
  justify-self: end;
  min-width: 112px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid #d7e0ea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  color: #334155;
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  transition: border-color 160ms ease, color 160ms ease;
}

.page-size:hover {
  border-color: rgba(16, 185, 129, .32);
  color: #0f9f78;
}

.page-size-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  z-index: 40;
  display: grid;
  border: 1px solid #d7e0ea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .14);
  overflow: hidden;
}

.page-size-dropdown button {
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #334155;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
  padding: 0 20px;
  transition: background 120ms ease, color 120ms ease;
}

.page-size-dropdown button:hover {
  background: #f0fdf4;
  color: #059669;
}

.page-size-dropdown button.active {
  background: #059669;
  color: #fff;
}

.preview-column {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.preview-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 20px 22px;
  overflow: hidden;
}

.preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edf2f7;
}

.preview-copy {
  min-width: 0;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-action,
.icon-action,
.viewer-toolbar-actions button {
  border: 1px solid #d7e0ea;
  border-radius: 8px;
  background: #fff;
  color: #334155;
}

.mini-action {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.icon-action {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
}

.preview-summary-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
}

.preview-secondary-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.5;
}

.preview-viewer {
  min-height: 0;
  margin-top: 18px;
}

.preview-status {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.preview-status.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #dc2626;
}

.preview-embed-wrap,
.preview-image-wrap {
  min-height: 0;
  overflow: hidden;
  border: 1px solid #edf2f7;
  border-radius: 12px;
  background: #fff;
}

.preview-embed {
  width: 100%;
  height: 100%;
  min-height: 560px;
  border: 0;
}

.preview-image-wrap {
  display: grid;
  place-items: center;
  padding: 20px;
}

.preview-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.onlyoffice-preview-wrap {
  min-height: 0;
  overflow: hidden;
  border: 1px solid #dbe4ee;
  border-radius: 12px;
  background: #fff;
}

.onlyoffice-preview-host {
  width: 100%;
  min-height: 720px;
}

.excel-preview-wrap {
  min-height: 0;
  overflow: hidden;
  border: 1px solid #dbe4ee;
  border-radius: 12px;
  background: #fff;
}

.excel-sheet-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  overflow-x: auto;
}

.excel-sheet-tab {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #d7e0ea;
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.excel-sheet-tab.active {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.excel-preview-scroll {
  min-height: 0;
  overflow: auto;
}

.excel-preview-table {
  width: 100%;
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
}

.excel-preview-table th,
.excel-preview-table td {
  padding: 10px 12px;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.5;
}

.excel-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e8f0fe;
  color: #0f172a;
  font-weight: 800;
}

.excel-preview-table td {
  color: #334155;
  background: #fff;
}

.excel-preview-table tbody tr:nth-child(even) td {
  background: #f8fafc;
}

.excel-preview-table tr > *:last-child {
  border-right: 0;
}

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

.page-stage {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 20px;
  padding-right: 6px;
}

.page-sheet {
  display: grid;
  gap: 18px;
  padding: 0 0 20px;
  border-bottom: 1px solid #edf2f7;
  background: transparent;
  box-shadow: none;
  animation: previewSheetIn 360ms var(--ease) both;
  animation-delay: var(--page-delay, 0ms);
}

.page-sheet:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.page-title {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
}

.page-title strong {
  color: #0f172a;
  font-size: 16px;
  font-weight: 850;
}

.page-title span {
  display: block;
  margin-top: 6px;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-item {
  display: grid;
  gap: 4px;
  padding: 0 0 10px;
  border-bottom: 1px solid #f1f5f9;
  background: transparent;
}

.summary-item span {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
}

.summary-item strong {
  color: #0f172a;
  font-size: 14px;
  font-weight: 800;
}

.page-content {
  display: grid;
  gap: 16px;
}

.content-block {
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
}

.content-block h3 {
  margin: 0 0 10px;
  color: #0f172a;
  font-size: 14px;
  font-weight: 850;
}

.content-block ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: #475569;
  font-size: 13px;
  line-height: 1.75;
}

.preview-panel-enter-active,
.preview-panel-leave-active {
  transition: opacity 240ms ease, transform 320ms var(--ease);
}

.preview-panel-enter-from,
.preview-panel-leave-to {
  opacity: 0;
  transform: translateX(24px) scale(0.98);
}

@keyframes previewSheetIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1320px) {
  .knowledge-grid.has-preview {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.78fr);
  }
}

@media (max-width: 1080px) {
  .knowledge-grid,
  .knowledge-grid.has-preview {
    grid-template-columns: 1fr;
    gap: 16px;
    overflow-y: auto;
  }

  .library-body {
    grid-template-columns: 1fr;
  }

  .folder-rail {
    border-right: 0;
    border-bottom: 1px solid #edf2f7;
    padding: 0 0 12px;
  }
}

@media (max-width: 760px) {
  .panel-title,
  .preview-head,
  .viewer-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-grid,
  .list-foot {
    grid-template-columns: 1fr;
  }

  .list-foot {
    gap: 12px;
    justify-items: stretch;
  }

  .pager,
  .page-size-wrap,
  .page-size {
    justify-self: stretch;
  }
}
