.sheet-editor { min-width: 0; overflow: hidden; display: flex; flex-direction: column; background: #fff; color: #343c3a; border: 1px solid #dde5e1; border-radius: 7px; }
.sheet-editor-surface { min-width: 0; }
.sheet-rich-frame { width: 100%; height: 620px; min-height: 380px; max-height: 68vh; border: 0; background: white; }
.sheet-rich-frame:not([data-ready="true"]) { pointer-events: none; opacity: .65; }
.sheet-workbook-hint { padding: 7px 12px; margin: 0; border-top: 1px solid #edf1ee; font-size: 10px; color: #7c8b82; }
.document-scroll > .workbook-editor .sheet-rich-frame { flex: 1; height: 65vh; }
#dialog:has(.workbook-editor) { width: min(1440px, calc(100vw - 32px)); }
.sheet-editor [hidden] { display: none !important; }
.sheet-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 8px 10px; border-bottom: 1px solid #e6ebe8; background: #fbfcfb; }
.sheet-operations, .sheet-modes { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.sheet-toolbar button { padding: 5px 8px; border: 1px solid transparent; font-size: 11px; background: transparent; color: #5d6964; }
.sheet-toolbar button:hover { background: #eef3ef; }
.sheet-toolbar button:disabled { opacity: .4; cursor: default; }
.sheet-modes { border: 1px solid #dce7df; padding: 2px; border-radius: 5px; background: #f2f6f3; }
.sheet-modes button[aria-pressed=true] { background: #fff; color: #25734c; border-color: #e0e8e3; }
.sheet-save-state { margin-left: auto; font-size: 10px; color: #7c8b82; }
.sheet-save-state.error { color: #a34c3f; flex-basis: 100%; }
.sheet-formula { display: flex; align-items: center; border-bottom: 1px solid #dce5df; min-height: 35px; }
.sheet-formula input, .sheet-formula textarea { height: 34px; min-height: 0; margin: 0; border: 0; border-radius: 0; padding: 5px 9px; box-shadow: none; font: 12px/24px ui-monospace, monospace; background: #fff; color: #3c4842; resize: none; overflow: auto; }
.sheet-formula input:first-child { width: 78px; flex: none; border-right: 1px solid #e1e9e4; text-align: center; }
.sheet-formula textarea:last-child { flex: 1; min-width: 0; }
.sheet-fx { padding: 0 9px; color: #8e9c94; font: italic 14px Georgia, serif; }
.sheet-viewport { overflow: auto; min-height: 250px; max-height: 52vh; overscroll-behavior: contain; scrollbar-width: thin; }
.sheet-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; min-width: 100%; font-size: 12px; }
.sheet-grid th, .sheet-grid td { padding: 0; border: 0; border-right: 1px solid #e4e9e6; border-bottom: 1px solid #e4e9e6; height: 29px; line-height: 1; }
.sheet-grid th { background: #f2f6f3; font: 11px ui-sans-serif, sans-serif; text-transform: none; letter-spacing: 0; color: #7a8b81; text-align: center; }
.sheet-grid thead { position: sticky; top: 0; z-index: 3; }
.sheet-grid tbody th, .sheet-grid .sheet-corner { position: sticky; left: 0; width: 45px; min-width: 45px; max-width: 45px; z-index: 2; background: #f2f6f3; }
.sheet-grid th button { background: transparent; border: 0; border-radius: 0; height: 28px; padding: 0 7px; width: 100%; font: inherit; color: inherit; }
.sheet-grid td { min-width: 138px; width: 138px; }
.sheet-grid td.sheet-selected { background: #eff7f1; box-shadow: inset 0 0 0 1px #b7d7c3; }
.sheet-grid td textarea { display: block; width: 100%; min-width: 0; min-height: 0; height: 28px; border: 0; border-radius: 0; padding: 4px 8px; margin: 0; font: 12px/20px ui-sans-serif, sans-serif; color: #34483d; background: transparent; text-overflow: ellipsis; box-shadow: none; resize: none; overflow: hidden; }
.sheet-grid td textarea:focus { outline: 2px solid #438d62; outline-offset: -2px; box-shadow: none; background: #fff; }
.sheet-grid td textarea.sheet-cell-error { color: #a14c3f; }
.sheet-footer { display: flex; justify-content: space-between; align-items: center; padding: 6px 11px; gap: 8px; border-top: 1px solid #e3eae5; color: #87978d; font-size: 10px; }
.sheet-pager { display: flex; align-items: center; gap: 8px; }
.sheet-pager button { border: 0; padding: 1px 6px; background: transparent; color: #617b68; }
.sheet-pager button:disabled { opacity: .3; }
.sheet-source { width: 100%; min-height: 350px; height: 44vh; border: 0; border-radius: 0; margin: 0; padding: 16px; font: 12px/1.7 ui-monospace, monospace; resize: vertical; white-space: pre; tab-size: 4; box-shadow: none; }
.sheet-help { border-top: 1px solid #edf1ee; padding: 8px 12px; font-size: 10px; color: #8b9990; }
.sheet-help summary { cursor: pointer; }
.sheet-help p { max-width: 820px; line-height: 1.8; margin: 8px 0 2px; }
.document-scroll > .sheet-editor { border: 0; border-radius: 0; min-height: 100%; }
.document-scroll > .sheet-editor .sheet-viewport { flex: 1; max-height: 65vh; }
.document-sheet-icon { color: #418c62; }
#dialog:has(.sheet-editor) { width: min(1100px, calc(100vw - 32px)); }
#dialog:has(.sheet-editor) .sheet-editor { margin-top: 16px; }
#dialog:has(.sheet-editor) .dialog-actions { margin-top: 15px; }
#dialog:has(.workbook-editor) { width: min(1440px, calc(100vw - 32px)); }
#dialog .sheet-grid textarea, #dialog .sheet-formula textarea { min-height: 0; }
.file-content-preview { margin: 18px 0; min-width: 0; }
.file-text-preview { overflow: auto; max-height: 420px; padding: 18px; margin: 0; border: 1px solid #e3e8e5; border-radius: 6px; background: #fafcfb; font: 12px/1.8 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.document-kind-control { margin-bottom: 10px; }
.topbar #top-actions { flex-wrap: wrap; justify-content: flex-end; }
@media(max-width:700px) {
  .sheet-toolbar { padding: 6px; gap: 5px; }
  .sheet-toolbar button { font-size: 10px; padding: 5px 6px; }
  .sheet-save-state { flex-basis: 100%; margin-left: 2px; }
  .sheet-grid td { min-width: 115px; width: 115px; }
  #dialog:has(.sheet-editor) { padding: 15px; }
  .sheet-viewport { max-height: 43vh; }
  .file-detail .sheet-grid { min-width: 100%; }
}
