/* Ve365 Excel 扩展样式 */
.theme-excel { --selection-border: #217346; --selection-bg: rgba(33,115,70,0.1); }

.formula-bar {
  display: flex; align-items: center; background: #fff;
  border-bottom: 1px solid #c0c0c0; height: 28px; flex-shrink: 0;
}
.formula-bar .name-box {
  width: 80px; text-align: center; font-size: 12px; font-weight: 500;
  border-right: 1px solid #c0c0c0; height: 100%; display: flex; align-items: center; justify-content: center;
  background: #f0f0f0; flex-shrink: 0;
}
.formula-bar .fx-btn {
  padding: 0 8px; font-style: italic; font-weight: 700; color: #5f6368;
  font-size: 13px; flex-shrink: 0; cursor: pointer; border: none; background: none;
}
.formula-bar .fx-btn:hover { color: var(--accent); }
.formula-bar input {
  flex: 1; border: none; outline: none; padding: 0 8px;
  font-size: 13px; font-family: Consolas, 'Courier New', monospace; height: 100%;
}

.grid-container {
  flex: 1; overflow: auto; position: relative; background: #fff;
}
.grid-container.hide-gridlines .grid-table td,
.grid-container.hide-gridlines .grid-table th { border-color: transparent; }

.grid-table { border-collapse: collapse; table-layout: fixed; }
.grid-table th, .grid-table td {
  border: 1px solid #d4d4d4; text-align: left; vertical-align: middle; position: relative;
}

.grid-table .corner {
  background: #f0f0f0; width: 46px; min-width: 46px; height: 22px;
  position: sticky; top: 0; left: 0; z-index: 20; border: 1px solid #c0c0c0;
}
.grid-table .col-header {
  background: #f0f0f0; text-align: center; font-size: 11px; font-weight: 500;
  color: #5f6368; height: 22px; min-width: 88px; width: 88px;
  position: sticky; top: 0; z-index: 10; cursor: pointer; user-select: none;
  border-bottom: 1px solid #c0c0c0;
}
.grid-table .col-header:hover { background: #e8eaed; }
.grid-table .col-header.selected { background: #d4e8dc; color: var(--accent); }
.grid-table .row-header {
  background: #f0f0f0; text-align: center; font-size: 11px; font-weight: 500;
  color: #5f6368; width: 46px; min-width: 46px; height: 22px;
  position: sticky; left: 0; z-index: 5; cursor: pointer; user-select: none;
  border-right: 1px solid #c0c0c0;
}
.grid-table .row-header:hover { background: #e8eaed; }
.grid-table .row-header.selected { background: #d4e8dc; color: var(--accent); }

.grid-table .cell {
  padding: 1px 4px; height: 22px; min-width: 88px; max-width: 88px;
  overflow: hidden; white-space: nowrap; cursor: cell; outline: none; font-size: 12px;
}
.grid-table .cell.selected {
  outline: 2px solid var(--selection-border); outline-offset: -2px; z-index: 2;
  background: var(--selection-bg);
}
.grid-table .cell.in-range { background: rgba(33,115,70,0.06); }
.grid-table .cell.range-edge {
  outline: 2px solid var(--selection-border); outline-offset: -2px; z-index: 1;
}
.grid-table .cell.editing {
  outline: 2px solid var(--selection-border); z-index: 3;
  background: #fff; overflow: visible; white-space: pre;
}
.grid-table .cell.has-comment::after {
  content: ''; position: absolute; top: 0; right: 0;
  border: 4px solid #217346 transparent transparent transparent;
}
.grid-table .cell.hidden-row, .grid-table .row-header.hidden-row { display: none; }

.grid-table .freeze-row { position: sticky; z-index: 4; background: #fff; }
.grid-table .freeze-col { position: sticky; z-index: 4; background: #fff; }

.sheet-bar {
  background: #f0f0f0; border-top: 1px solid #c0c0c0;
  display: flex; align-items: center; padding: 0 6px; height: 32px; flex-shrink: 0;
}
.sheet-bar .sheet-nav { display: flex; gap: 2px; margin-right: 4px; }
.sheet-bar .sheet-nav button {
  width: 24px; height: 24px; border: none; background: transparent; cursor: pointer;
  border-radius: 2px; font-size: 14px; color: #5f6368;
}
.sheet-bar .sheet-nav button:hover { background: #e0e0e0; }
.sheet-bar .add-sheet-btn {
  background: transparent; border: none; color: #5f6368; font-size: 18px;
  width: 28px; height: 26px; cursor: pointer; border-radius: 2px; margin-right: 2px;
}
.sheet-bar .add-sheet-btn:hover { background: #e0e0e0; }
.sheet-tabs { display: flex; overflow-x: auto; flex: 1; }
.sheet-tab {
  padding: 5px 14px; font-size: 12px; color: #5f6368; cursor: pointer;
  border: 1px solid transparent; border-bottom: none; border-radius: 4px 4px 0 0;
  white-space: nowrap; min-width: 56px; text-align: center; background: transparent;
}
.sheet-tab:hover { background: #e8eaed; }
.sheet-tab.active {
  background: #fff; color: var(--accent); border-color: #c0c0c0; font-weight: 600;
}
.sheet-tab .tab-close {
  display: none; margin-left: 4px; font-size: 13px; cursor: pointer;
}
.sheet-tab:hover .tab-close { display: inline; }

.excel-statusbar .status-item { display: flex; align-items: center; gap: 4px; }
.excel-statusbar .status-value { font-weight: 600; }

.context-menu {
  position: fixed; background: #fff; border: 1px solid #dadce0;
  border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 1000; min-width: 200px; padding: 4px 0; display: none;
}
.context-menu .menu-item {
  padding: 8px 16px; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.context-menu .menu-item:hover { background: #e8f5ee; color: var(--accent); }
.context-menu .menu-item .shortcut { margin-left: auto; color: #9aa0a6; font-size: 11px; }
.context-menu .menu-divider { height: 1px; background: #edebe9; margin: 4px 0; }

.border-submenu, .func-submenu {
  position: fixed; background: #fff; border: 1px solid #dadce0;
  border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 1100; min-width: 160px; padding: 4px 0; display: none;
}
.border-submenu .menu-item, .func-submenu .menu-item {
  padding: 8px 16px; font-size: 12px; cursor: pointer;
}
.border-submenu .menu-item:hover, .func-submenu .menu-item:hover { background: #e8f5ee; }

.excel-modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 8500; align-items: center; justify-content: center;
}
.excel-modal-backdrop.show { display: flex; }
.excel-modal {
  background: #fff; border-radius: 4px; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  min-width: 400px; max-width: 90vw; max-height: 85vh; overflow: auto;
}
.excel-modal-header {
  padding: 12px 16px; border-bottom: 1px solid #edebe9;
  font-size: 14px; font-weight: 600; display: flex; justify-content: space-between;
}
.excel-modal-body { padding: 16px; }
.excel-modal-footer {
  padding: 12px 16px; border-top: 1px solid #edebe9;
  display: flex; justify-content: flex-end; gap: 8px;
}
.excel-field { margin-bottom: 12px; }
.excel-field label { display: block; font-size: 12px; margin-bottom: 4px; color: #605e5c; }
.excel-field input, .excel-field select, .excel-field textarea {
  width: 100%; padding: 6px 8px; border: 1px solid #d2d0ce; border-radius: 2px; font-size: 12px;
}
.excel-btn {
  padding: 6px 16px; border: 1px solid #d2d0ce; border-radius: 2px;
  cursor: pointer; font-size: 12px; background: #fff;
}
.excel-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.chart-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 9000; align-items: center; justify-content: center;
}
.chart-overlay.show { display: flex; }
.chart-panel {
  background: #fff; border-radius: 8px; padding: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25); max-width: 90vw;
}
.chart-panel canvas { max-width: 100%; }

.col-resize-handle {
  position: absolute; right: 0; top: 0; bottom: 0; width: 4px;
  cursor: col-resize; z-index: 12;
}

@media print {
  .office-titlebar, .qat-bar, .office-ribbon, .formula-bar, .sheet-bar,
  .office-statusbar, .context-menu, .file-backdrop, .file-panel { display: none !important; }
  .grid-container { overflow: visible; }
}
