/* Мастер диаграмм Calc (LibreOffice Calc) + плавающие диаграммы на листе */
.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog {
  position: absolute;
  inset: 0;
  z-index: 21000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  overflow: auto;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog[hidden] {
  display: none !important;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__window {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100% - 32px));
  max-height: min(92%, 680px);
  border: 1px solid #3a3a3a;
  border-radius: 3px;
  background: #1e1e1e;
  color: #f0f0f0;
  font-family: Liberation Sans, Arial, sans-serif;
  font-size: 13px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid #333;
  background: #252525;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__x {
  margin: 0;
  padding: 2px 10px;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: #ccc;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__x:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__body {
  display: flex;
  flex-direction: row;
  min-height: 0;
  flex: 1;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__nav {
  flex: 0 0 30%;
  min-width: 140px;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  border-right: 1px solid #333;
  background: #1a1a1a;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 12px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #ddd;
  font-size: 12px;
  cursor: pointer;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__nav-btn--active {
  border-color: #4a8fd6;
  background: rgba(74, 143, 214, 0.18);
  color: #fff;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr minmax(140px, 38%);
  gap: 12px;
  padding: 14px 16px;
  min-width: 0;
  overflow: auto;
}

@media (max-width: 640px) {
  .libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__main {
    grid-template-columns: 1fr;
  }

  .libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__preview {
    grid-column: 1;
    grid-row: auto;
    min-height: 140px;
  }
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__panel[hidden] {
  display: none !important;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__lead {
  margin: 0 0 10px;
  color: #ccc;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #252525;
  color: #eee;
  cursor: pointer;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-card--active {
  border-color: #4a8fd6;
  box-shadow: inset 0 0 0 1px #4a8fd6;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-icon {
  width: 56px;
  height: 40px;
  border-radius: 3px;
  background: #333 center / contain no-repeat;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-icon--pie {
  background-image: radial-gradient(circle at 50% 50%, #4e79a7 0 38%, transparent 38%),
    conic-gradient(#4e79a7 0 120deg, #f28e2b 120deg 250deg, #e15759 250deg);
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-icon--column {
  background: linear-gradient(to top, #4e79a7 0 70%, transparent 70%) 20% 100% / 18% 100% no-repeat,
    linear-gradient(to top, #f28e2b 0 45%, transparent 45%) 45% 100% / 18% 100% no-repeat,
    linear-gradient(to top, #e15759 0 55%, transparent 55%) 70% 100% / 18% 100% no-repeat;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-icon--bar {
  background: linear-gradient(to right, #4e79a7 0 70%, transparent 70%) 0 20% / 100% 18% no-repeat,
    linear-gradient(to right, #f28e2b 0 45%, transparent 45%) 0 45% / 100% 18% no-repeat,
    linear-gradient(to right, #e15759 0 55%, transparent 55%) 0 70% / 100% 18% no-repeat;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-icon--line {
  background: linear-gradient(135deg, transparent 46%, #4a8fd6 46%, #4a8fd6 54%, transparent 54%);
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__field-label {
  color: #bbb;
  font-size: 12px;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__input {
  padding: 6px 8px;
  border: 1px solid #555;
  border-radius: 2px;
  background: #111;
  color: #f5f5f5;
  font: inherit;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__hint {
  margin: 0;
  color: #999;
  font-size: 12px;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  cursor: pointer;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__preview {
  grid-column: 2;
  grid-row: 1 / span 3;
  border: 1px solid #444;
  border-radius: 4px;
  background: #fff;
  color: #222;
  display: flex;
  flex-direction: column;
  min-height: 180px;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__preview-title {
  padding: 6px 8px;
  border-bottom: 1px solid #ddd;
  font-size: 12px;
  font-weight: 600;
  background: #f3f3f3;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__preview-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__preview-canvas svg {
  width: 100%;
  height: auto;
  max-height: 200px;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #333;
  background: #252525;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__footer-right {
  display: flex;
  gap: 8px;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__btn {
  padding: 6px 14px;
  border: 1px solid #555;
  border-radius: 3px;
  background: #333;
  color: #eee;
  font: inherit;
  cursor: pointer;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__btn:hover:not(:disabled) {
  background: #3d3d3d;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__btn--primary {
  border-color: #2f6fb3;
  background: #3d84cc;
  color: #fff;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__btn--primary:hover:not(:disabled) {
  background: #4a93db;
}

.libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__btn--ghost {
  background: transparent;
}

/* Плавающая диаграмма на листе */
.hf-sheet-chart-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  overflow: visible;
}

.hf-sheet-chart {
  position: absolute;
  pointer-events: auto;
  border: 1px solid #8c8c8c;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.hf-sheet-chart--dragging,
.hf-sheet-chart[data-hf-chart-dragging="1"] {
  cursor: grabbing;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  z-index: 20;
}

.hf-sheet-chart__inner {
  width: 100%;
  height: 100%;
  padding: 6px;
  box-sizing: border-box;
}

.hf-sheet-chart__inner svg {
  width: 100%;
  height: 100%;
  display: block;
}

html[data-theme="light"] .libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__window {
  background: #f0f0f0;
  color: #1a1a1a;
  border-color: #b0b0b0;
}

html[data-theme="light"] .libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__titlebar,
html[data-theme="light"] .libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__footer {
  background: #e8e8e8;
  border-color: #c8c8c8;
}

html[data-theme="light"] .libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__nav {
  background: #e4e4e4;
  border-color: #c8c8c8;
}

html[data-theme="light"] .libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__type-card {
  background: #fff;
  border-color: #bbb;
  color: #222;
}

html[data-theme="light"] .libreoffice-sheet-calc-container .libreoffice-lo-chart-dialog__input {
  background: #fff;
  color: #111;
  border-color: #aaa;
}
