/* Excel Viewer — formula bar, the grid (four sticky panes), sheet tabs, status bar. Cells keep the file's own
   colours; the grid looks like a spreadsheet in light mode, and headers/chrome follow the site theme. */

.xv-fbar {
  flex: none; display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem; background: var(--surface);
  border-bottom: 1px solid var(--border); min-width: 0;
}
.xv-name, .xv-formula {
  height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text);
  font: 500 .9rem var(--font-sans); padding: 0 .55rem; min-width: 0;
}
.xv-name { width: 8.5rem; flex: none; text-transform: uppercase; }
.xv-formula { flex: 1 1 auto; font-family: var(--font-mono, ui-monospace, monospace); font-size: .88rem; background: var(--surface-2); }
.xv-name:focus-visible, .xv-formula:focus-visible { outline: 2px solid var(--focus); outline-offset: -1px; }
.xv-fx { flex: none; color: var(--text-faint); font: italic 600 .85rem Georgia, serif; }
.xv-open-link { flex: none; }

.xv-stage { background: var(--surface); }
.xv-space {
  position: relative; font-family: var(--xv-font, Carlito, Calibri, Arimo, Arial, sans-serif); font-size: var(--xv-size, 11pt);
  color: #111; color-scheme: light;
}
.xv-top { position: sticky; top: 0; z-index: 3; display: flex; }
.xv-body { display: flex; }
.xv-pane { position: relative; flex: none; }
.xv-tl, .xv-bl { position: sticky; left: 0; }
.xv-tl { z-index: 4; }
.xv-bl { z-index: 2; }
.xv-tl, .xv-tr { background: #fff; }
.xv-bl, .xv-br { background: #fff; }
.xv-space .xv-top { box-shadow: 0 1px 0 #d4d4d4; }
.xv-tl { box-shadow: 1px 0 0 #d4d4d4; }
.xv-bl { box-shadow: 1px 0 0 #d4d4d4; }

/* Headers */
.xv-corner, .xv-ch, .xv-rh {
  position: absolute; display: flex; align-items: center; justify-content: center; box-sizing: border-box;
  background: #f3f4f6; color: #4b5563; font: 500 11px/1 var(--font-sans); border-right: 1px solid #d4d4d8; border-bottom: 1px solid #d4d4d8;
  user-select: none; -webkit-user-select: none; overflow: hidden; white-space: nowrap; cursor: default;
}
.xv-corner { left: 0; top: 0; cursor: pointer; }
.xv-corner::after { content: ''; position: absolute; right: 3px; bottom: 3px; border: 5px solid transparent; border-right-color: #9ca3af; border-bottom-color: #9ca3af; }
.xv-ch.is-sel, .xv-rh.is-sel { background: color-mix(in srgb, var(--app-accent, #16a34a) 18%, #f3f4f6); color: color-mix(in srgb, var(--app-accent, #16a34a) 80%, #000); font-weight: 650; }
.xv-ch.is-sel { box-shadow: inset 0 -2px 0 var(--app-accent, #16a34a); }
.xv-rh.is-sel { box-shadow: inset -2px 0 0 var(--app-accent, #16a34a); }

/* Cells */
.xv-c {
  position: absolute; box-sizing: border-box; display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 0 3px 1px; overflow: hidden; white-space: pre; line-height: normal; z-index: 1;
}
/* Text keeps its alignment when it's wider than the cell (right-aligned shows its end, centred its middle);
   wrapped text shrinks to the cell so it wraps; numbers never wrap (they're shortened or shown as ###). */
.xv-c > span { position: relative; flex: none; }
.xv-c.xv-w > span { flex: 0 1 auto; min-width: 0; }
.xv-c.xv-nf > span { flex: none; white-space: pre; }
.xv-c.xv-num { justify-content: flex-end; }
.xv-c.xv-ctr { justify-content: center; }
.xv-c.xv-ov { overflow: visible; z-index: 2; }
/* Spilling text: a box over this cell and the empty cells beside it, clipped at the next filled cell */
.xv-c > span.xv-sp {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: inherit; justify-content: inherit;
  padding: inherit; overflow: hidden; white-space: pre;
}
.xv-sp > span { flex: none; }
.xv-sp > span.xv-cc { position: absolute; top: 0; bottom: 1px; display: flex; align-items: inherit; transform: translateX(-50%); white-space: pre; }
/* Turned text: a box the size of the turned outline (set once measured), the text turned about its middle */
.xv-c > span.xv-rb { position: relative; display: block; flex: none; width: 0; height: 0; }
.xv-rb > span { position: absolute; left: 50%; top: 50%; white-space: pre; transform: translate(-50%, -50%) rotate(var(--xv-rot, 0deg)); }
/* Off-screen copies of cells, used to measure how tall their rows need to be */
.xv-probe { position: absolute; left: 0; top: 0; visibility: hidden; pointer-events: none; z-index: -1; }
.xv-probe > .xv-c { position: absolute; left: 0; top: 0; height: auto; }
.xv-c.xv-nl { border-left: 0 !important; }
.xv-c.xv-nt { border-top: 0 !important; }
.xv-c.xv-link > span { color: #0563c1; text-decoration: underline; }
.xv-c.xv-cm::after { content: ''; position: absolute; right: 0; top: 0; border: 4px solid transparent; border-top-color: #dc2626; border-right-color: #dc2626; }
.xv-bar { position: absolute; left: 2px; top: 3px; bottom: 3px; border-radius: 1px; pointer-events: none; }
.xv-gv, .xv-gh { position: absolute; display: block; background: #e2e2e2; pointer-events: none; z-index: 0; }
.xv-gv { width: 1px; }
.xv-gh { height: 1px; }
.no-grid .xv-gv, .no-grid .xv-gh { display: none; }

/* Selection */
.xv-sel { position: absolute; z-index: 5; pointer-events: none; box-sizing: border-box; border: 2px solid var(--app-accent, #16a34a); background: color-mix(in srgb, var(--app-accent, #16a34a) 12%, transparent); }
.xv-sel.is-single { background: none; }
.xv-sel > i { position: absolute; display: block; background: #fff; mix-blend-mode: normal; opacity: .55; }

/* Pictures and charts */
.xv-draw { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.xv-pic, .xv-chart { position: absolute; pointer-events: auto; box-sizing: border-box; }
.xv-pic { object-fit: fill; }
.xv-chart { background: #fff; border: 1px solid #d9d9d9; font: 12px var(--font-sans); color: #444; display: grid; place-items: center; }

/* Sheet tabs */
.xv-tabs {
  flex: none; display: flex; gap: 2px; overflow-x: auto; padding: 0 .5rem; background: var(--surface-2);
  border-top: 1px solid var(--border); scrollbar-width: thin; min-height: 36px; align-items: stretch;
}
.xv-tabs:empty { display: none; }
.xv-tab {
  flex: none; border: 0; background: none; padding: .45rem .9rem .35rem; font: 500 .85rem var(--font-sans); color: var(--text-soft);
  cursor: pointer; border-bottom: 3px solid var(--tab, transparent); border-radius: 0 0 6px 6px; white-space: nowrap; max-width: 14rem; overflow: hidden; text-overflow: ellipsis;
}
.xv-tab.is-current { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: 0 1px 2px rgb(16 24 40 / .08); }
.xv-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
@media (hover: hover) { .xv-tab:not(.is-current):hover { background: var(--surface); color: var(--text); } }
@media (pointer: coarse) { .xv-tab { min-height: 44px; } }

.xv-status { gap: .9rem; }
.xv-note { display: inline-flex; align-items: center; gap: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xv-note .icon { width: 14px; height: 14px; color: #dc2626; }
.xv-filter-list { max-height: 50vh; overflow: auto; display: grid; gap: .1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .4rem .6rem; }
.xv-filter-row { min-height: 36px; }
.xv-names { display: grid; gap: .3rem; }
.xv-name-item { display: flex; justify-content: space-between; gap: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: .55rem .75rem; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.xv-name-item span { color: var(--text-soft); font-family: var(--font-mono, monospace); font-size: .85rem; }
.xv-details { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.xv-details dt { color: var(--text-soft); }
.xv-details dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .xv-name { width: 5.5rem; }
  .xv-fx { display: none; }
  .xv-hide-phone { display: none; }
}

/* Print: the sheet as a table */
.xv-print { display: none; }
@media print {
  body > *:not(.xv-print) { display: none !important; }
  .xv-print { display: block !important; font-family: var(--xv-font, Carlito, Calibri, Arial, sans-serif); color: #000; }
  .xv-print-title { font: 600 12pt var(--font-sans); margin: 0 0 8px; }
  .xv-print-table { border-collapse: collapse; table-layout: fixed; font-size: 10pt; }
  .xv-print-table td { padding: 1px 4px; white-space: nowrap; overflow: hidden; vertical-align: bottom; }
  .xv-print-table.with-grid td { border: 1px solid #ccc; }
  .xv-print-table td.xv-num { text-align: right; }
  @page { margin: 12mm; }
}
