/* Spreadsheet and text viewer of the preview panel (contract A16-7). Every class starts with sv-.
   Sizes that come from a model are set by sheetview.js through the CSSOM as calc(var(--sv-z) * Npx);
   --sv-z is the zoom. System fonts only, no external asset, no inline style. */

.sv-root {
  --sv-z: 1;
  --sv-accent: var(--navy, #0054a0);
  --sv-accent-ink: var(--navy-700, #00427f);
  --sv-ink: var(--ink, #0f1e33);
  --sv-muted: var(--muted, #52627a);
  --sv-surface: var(--surface, #ffffff);
  --sv-bar: #f6f8fb;
  --sv-well: #eef1f5;
  --sv-tint: var(--tint, #e8f0fa);
  --sv-line: var(--line, #e1e7f0);
  --sv-line-2: var(--line-2, #c9d4e3);
  --sv-grid-line: #dadde2;
  --sv-head-bg: #f3f5f8;
  --sv-head-fg: #566275;
  --sv-head-line: #cdd3db;
  --sv-chg: #d9730d;
  --sv-chg-line: #d97a1c;
  --sv-chg-w: 1.5px;
  --sv-thumb: #c3cad5;
  --sv-ring-quiet: #5b8fc2;
  --sv-ui-font: var(--font, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif);
  --sv-cell-font: Calibri, Carlito, "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;

  container: sv / inline-size;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--sv-surface);
  color: var(--sv-ink);
  font-family: var(--sv-ui-font);
  font-size: 0.875rem;
  line-height: 1.4;
  text-align: left;
  overflow-wrap: normal;
}
.sv-root *, .sv-root *::before, .sv-root *::after { box-sizing: border-box; }
.sv-root [hidden] { display: none; }
.sv-root :focus-visible { outline: 2px solid var(--sv-accent); outline-offset: 2px; border-radius: 6px; }
/* the frame itself takes focus only from a click or from the page; it shows no ring of its own */
.sv-root:focus, .sv-root:focus-visible { outline: none; }

.sv-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.sv-icon { width: 1.125rem; height: 1.125rem; flex: none; }

/* ---------- header ---------- */

.sv-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem;
  flex: none; padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--sv-line); background: var(--sv-surface);
}
.sv-title {
  display: flex; align-items: center; gap: 0.5rem; flex: 1 1 8rem; min-width: 0;
  color: var(--sv-ink); font-weight: 600; font-size: 0.9375rem;
}
.sv-title .sv-icon { color: var(--sv-accent); }
.sv-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-tools, .sv-actions { display: flex; align-items: center; gap: 0.375rem; flex: none; }

.sv-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  height: 2rem; padding: 0 0.625rem; margin: 0;
  border: 1px solid var(--sv-line-2); border-radius: 8px;
  background: var(--sv-surface); color: var(--sv-ink);
  font: inherit; font-size: 0.8125rem; font-weight: 600; line-height: 1; white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.sv-btn:hover { border-color: var(--sv-accent); color: var(--sv-accent-ink); }
.sv-btn:active { background: var(--sv-tint); }
.sv-btn-icon { width: 2rem; padding: 0; }
.sv-close { border-color: transparent; color: var(--sv-muted); }
.sv-close:hover { background: var(--sv-tint); border-color: transparent; color: var(--sv-accent-ink); }

.sv-zoom {
  display: inline-flex; align-items: stretch; height: 2rem;
  border: 1px solid var(--sv-line-2); border-radius: 8px; background: var(--sv-surface); overflow: hidden;
}
.sv-zoom-btn, .sv-zoom-val {
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0; padding: 0; border: 0; background: none; color: var(--sv-ink);
  font: inherit; font-size: 0.8125rem; font-weight: 600; line-height: 1; cursor: pointer;
}
.sv-zoom-btn { width: 1.875rem; color: var(--sv-muted); }
.sv-zoom-val { min-width: 3rem; padding: 0 0.125rem; font-variant-numeric: tabular-nums; }
.sv-zoom-btn:hover, .sv-zoom-val:hover { background: var(--sv-tint); color: var(--sv-accent-ink); }
.sv-zoom-btn[aria-disabled="true"] { opacity: 0.4; cursor: default; background: none; }
.sv-zoom :focus-visible { outline-offset: -2px; }

.sv-toggle { font-weight: 600; color: var(--sv-muted); }
.sv-toggle[aria-pressed="true"] { background: var(--sv-tint); border-color: var(--sv-accent); color: var(--sv-accent-ink); }
.sv-chg-mark {
  width: 0.75rem; height: 0.75rem; flex: none; border-radius: 2px;
  background: var(--sv-surface); box-shadow: inset 0 0 0 2px var(--sv-line-2);
}
.sv-toggle[aria-pressed="true"] .sv-chg-mark { box-shadow: inset 0 0 0 2px var(--sv-chg); }
.sv-count { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--sv-muted); }
.sv-count:empty { display: none; }
.sv-toggle[aria-pressed="true"] .sv-count { color: var(--sv-accent-ink); }

/* ---------- the other files of the version ---------- */

.sv-files {
  display: flex; gap: 0.25rem; flex: none; padding: 0 0.5rem;
  border-bottom: 1px solid var(--sv-line); background: var(--sv-surface);
  overflow-x: auto; scrollbar-width: none;
}
.sv-file {
  flex: 0 1 auto; min-width: 3rem; max-width: 16rem; margin: 0; padding: 0.5rem 0.5rem 0.4375rem;
  border: 0; border-bottom: 2px solid transparent; background: none; color: var(--sv-muted);
  font: inherit; font-size: 0.8125rem; line-height: 1.3; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sv-file:hover { color: var(--sv-accent-ink); }
.sv-file-on { border-bottom-color: var(--sv-accent); color: var(--sv-accent-ink); font-weight: 600; cursor: default; }
.sv-file:focus-visible { outline-offset: -2px; }

/* ---------- body ---------- */

.sv-body { position: relative; display: flex; flex: 1 1 auto; min-width: 0; min-height: 0; background: var(--sv-well); }
.sv-scroll {
  flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--sv-thumb) transparent;
}
.sv-scroll:focus-visible { outline: 2px solid var(--sv-ring-quiet); outline-offset: -2px; border-radius: 0; }
.sv-empty { margin: 0; padding: 2.5rem 1rem; color: var(--sv-muted); text-align: center; }

/* ---------- the grid ---------- */

.sv-grid {
  border-collapse: separate; border-spacing: 0; table-layout: fixed; margin: 0;
  background: #ffffff; color: #000000;
  font-family: var(--sv-cell-font); font-size: calc(var(--sv-z) * 14.667px); line-height: 1.2;
  font-variant-numeric: lining-nums;
}
.sv-col-rn { width: calc(var(--sv-z) * 40px); }
.sv-grid td {
  padding: 0 calc(var(--sv-z) * 3px);
  border: 0 solid var(--sv-grid-line); border-right-width: 1px; border-bottom-width: 1px;
  font-weight: 400; text-align: left; vertical-align: bottom;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
}
.sv-grid th {
  position: sticky; padding: 0;
  border: 0 solid var(--sv-head-line); border-right-width: 1px; border-bottom-width: 1px;
  background: var(--sv-head-bg); color: var(--sv-head-fg);
  font-family: var(--sv-ui-font); font-size: calc(var(--sv-z) * 11.5px); font-weight: 400; line-height: 1;
  text-align: center; vertical-align: middle; white-space: nowrap;
  -webkit-user-select: none; user-select: none;
}
.sv-ch { top: 0; z-index: 2; height: calc(var(--sv-z) * 22px); }
.sv-rh { left: 0; z-index: 1; }
.sv-grid .sv-corner { top: 0; left: 0; z-index: 3; }

.sv-b { font-weight: 700; }
.sv-grid td.sv-b { font-weight: 700; }
.sv-i { font-style: italic; }
.sv-u { text-decoration: underline; }
.sv-s { text-decoration: line-through; }
.sv-u.sv-s { text-decoration: underline line-through; }
.sv-grid td.sv-hc { text-align: center; }
.sv-grid td.sv-hr { text-align: right; }
.sv-grid td.sv-hj { text-align: justify; }
.sv-grid td.sv-vt { vertical-align: top; }
.sv-grid td.sv-vm { vertical-align: middle; }
.sv-grid td.sv-open { border-right-color: transparent; }

.sv-spill { text-decoration: inherit; }
.sv-rot {
  display: inline-block; writing-mode: vertical-rl; white-space: pre;
  text-align: left; text-decoration: inherit; line-height: 1.2;
  padding: calc(var(--sv-z) * 2px) 0;
}
.sv-rot-up { transform: rotate(180deg); }
.sv-rot-wrap { white-space: pre-wrap; }

/* A changed cell keeps its fill; the mark is a thin line just inside the cell's edge. Every changed cell draws
   its top and left line. It draws its right or bottom line only where the neighbour is unchanged (sheetview.js
   sets sv-chg-jr and sv-chg-jb where it is changed), so two changed neighbours share one line. */
.sv-show-chg .sv-chg {
  --sv-chg-r: calc(-1 * var(--sv-chg-w));
  --sv-chg-b: calc(-1 * var(--sv-chg-w));
  box-shadow:
    inset var(--sv-chg-w) 0 0 0 var(--sv-chg-line),
    inset 0 var(--sv-chg-w) 0 0 var(--sv-chg-line),
    inset var(--sv-chg-r) 0 0 0 var(--sv-chg-line),
    inset 0 var(--sv-chg-b) 0 0 var(--sv-chg-line);
}
.sv-show-chg .sv-chg-jr { --sv-chg-r: 0px; }
.sv-show-chg .sv-chg-jb { --sv-chg-b: 0px; }

/* ---------- sheet tabs ---------- */

.sv-foot {
  display: flex; align-items: stretch; flex: none; min-height: 1.875rem;
  border-top: 1px solid var(--sv-line-2); background: var(--sv-bar);
}
.sv-sheets {
  display: flex; flex: 1 1 0; min-width: 0;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
}
.sv-sheets::-webkit-scrollbar, .sv-files::-webkit-scrollbar { display: none; }
.sv-sheet {
  display: inline-flex; align-items: center; gap: 0.3125rem; flex: none;
  max-width: 15rem; min-height: 1.875rem; margin: 0; padding: 0 0.5625rem;
  border: 0; border-right: 1px solid var(--sv-line); background: none; color: var(--sv-muted);
  font: inherit; font-size: 0.75rem; line-height: 1.2; white-space: nowrap; cursor: pointer;
}
.sv-sheet-name { overflow: hidden; text-overflow: ellipsis; }
.sv-sheet:hover { background: var(--sv-surface); color: var(--sv-accent-ink); }
.sv-sheet-on {
  background: var(--sv-surface); color: var(--sv-accent-ink); font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--sv-accent); cursor: default;
}
.sv-sheet:focus-visible { outline-offset: -2px; }
.sv-sheet-dot { display: none; width: 0.375rem; height: 0.375rem; flex: none; border-radius: 50%; background: var(--sv-chg); }
.sv-show-chg .sv-sheet-dot { display: block; }
.sv-nav { display: flex; flex: none; border-left: 1px solid var(--sv-line-2); }
.sv-nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; margin: 0; padding: 0; border: 0; background: none; color: var(--sv-muted); cursor: pointer;
}
.sv-nav-btn .sv-icon { width: 0.875rem; height: 0.875rem; }
.sv-nav-btn:hover { background: var(--sv-surface); color: var(--sv-accent-ink); }
.sv-nav-btn[aria-disabled="true"] { background: none; color: var(--sv-muted); opacity: 0.35; cursor: default; }
.sv-nav-btn:focus-visible { outline-offset: -2px; }
.sv-note {
  flex: none; align-self: center; margin: 0; padding: 0 0.75rem;
  color: var(--sv-muted); font-size: 0.75rem; white-space: nowrap;
}

/* ---------- text view ---------- */

.sv-scroll-text { background: var(--sv-surface); }
.sv-text {
  margin: 0; padding: 1rem 1.25rem 2rem; max-width: 60rem;
  color: var(--sv-ink); font-family: var(--sv-ui-font); font-size: calc(var(--sv-z) * 0.9375rem); line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4;
}

/* ---------- narrow panel (the overlay) ---------- */

@container sv (max-width: 520px) {
  .sv-head { padding: 0.5rem 0.625rem; }
  .sv-title { flex-basis: 6rem; }
  .sv-tools { order: 3; flex: 1 0 100%; justify-content: space-between; }
  .sv-foot { flex-wrap: wrap; }
  .sv-note { flex: 1 0 100%; padding: 0.25rem 0.75rem; border-top: 1px solid var(--sv-line); white-space: normal; }
}
@media (pointer: coarse) {
  .sv-btn, .sv-zoom { height: 2.5rem; }
  .sv-btn-icon { width: 2.5rem; }
  .sv-zoom-btn { width: 2.5rem; }
  .sv-foot { min-height: 2.75rem; }
  .sv-sheet { min-height: 2.75rem; }
  .sv-nav-btn { width: 2.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sv-btn { transition: none; }
}
@media (forced-colors: active) {
  .sv-show-chg .sv-chg { outline: 2px solid Highlight; outline-offset: -2px; }
  .sv-sheet-on, .sv-file-on { outline: 1px solid Highlight; outline-offset: -1px; }
}
