/* LocalSheet — Benmore-branded theme. Blue accent, dark top bar, full dark
   mode via [data-theme="dark"] variable overrides. (--green is a legacy
   alias for the accent — every rule reads variables, never raw colors.) */

/* Benmore brand fonts — self-hosted (no external font CDN: nothing leaves
   the device). Poppins = display/brand, Source Sans 3 = UI + cells. */
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/poppins-500.woff2?v=1') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/poppins-600.woff2?v=1') format('woff2');
}
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 200 900; /* variable font */
  font-display: swap;
  src: url('/static/fonts/source-sans-3.woff2?v=1') format('woff2');
}

:root {
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Poppins', var(--font-sans);
  --accent: #2F5BE7;
  --green: var(--accent);
  --green-soft: rgba(47, 91, 231, 0.10);
  --green-mid: rgba(47, 91, 231, 0.40);
  --bg: #ffffff;
  --card: #ffffff;
  --bg-soft: #fbfcfc;
  --bg-hover: #eef1f2;
  --canvas: #f1f4f5;
  --line: #d8dcdf;
  --hdr-bg: #f6f8f9;
  --hdr-bg-hit: #e3eafc;
  --ink: #1f2937;
  --ink-soft: #6b7280;
  --topbar: #0e1015;
  --row-h: 26px;
  --colhdr-h: 28px;
  --rowhdr-w: 48px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --accent: #5b7ef5;
  --green-soft: rgba(91, 126, 245, 0.16);
  --green-mid: rgba(91, 126, 245, 0.45);
  --bg: #0f1115;
  --card: #16191f;
  --bg-soft: #14161b;
  --bg-hover: #21252e;
  --canvas: #0a0c0f;
  --line: #2a2f38;
  --hdr-bg: #161920;
  --hdr-bg-hit: #1d2638;
  --ink: #e6e8ec;
  --ink-soft: #98a0ac;
  --topbar: #08090c;
}

* { box-sizing: border-box; }

/* LocalSheet never tracks visitors — keep the platform consent banner hidden
   for the instant before app.js auto-declines it. */
#bm-cookie { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---- top bar -------------------------------------------------------------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--topbar);
  color: #fff;
}
#page-tabs a.active { background: var(--accent) !important; }
#brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: .2px; }
#brand img { border-radius: 5px; }
#page-tabs { display: flex; gap: 2px; margin-left: 16px; }
#page-tabs a {
  color: rgba(255, 255, 255, 0.85); text-decoration: none;
  font-family: var(--font-display);
  font-size: 12.5px; font-weight: 500;
  padding: 4px 14px; border-radius: 6px;
}
#page-tabs a:hover { background: rgba(255, 255, 255, 0.12); }
#page-tabs a.active { background: rgba(255, 255, 255, 0.22); color: #fff; font-weight: 600; }
#privacy-note {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.14);
  padding: 4px 10px;
  border-radius: 99px;
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#topbar #btn-help {
  background: rgba(255,255,255,.16); color: #fff; border: none;
  width: 26px; height: 26px; border-radius: 50%; font-weight: 700;
}
#topbar #btn-help:hover { background: rgba(255,255,255,.3); }

/* ---- toolbar -------------------------------------------------------------- */
#toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  flex-wrap: wrap;
}
.tb-btn {
  min-width: 30px; height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
}
.tb-btn:hover { background: var(--bg-hover); border-color: var(--line); }
.tb-btn .ic { width: 14px; height: 14px; display: block; margin: 0 auto; }
.tb-btn svg path { fill: none; }
.tb-btn.on { background: var(--green-soft); border-color: var(--green-mid); color: var(--green); }
.tb-btn.wide { font-size: 12px; }
.tb-btn.danger:hover { background: #fdeaea; border-color: #e6b3b3; color: #b42318; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.tb-select {
  height: 28px; border: 1px solid var(--line); border-radius: 5px;
  background: var(--card); font-size: 12px; color: var(--ink); padding: 0 4px;
}

/* ---- formula bar ------------------------------------------------------------ */
#fxbar {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  height: 30px;
}
#sel-ref {
  width: 110px;
  border: none; border-right: 1px solid var(--line); outline: none;
  text-align: center;
  font-size: 12px; font-weight: 600; color: var(--ink); font-family: inherit;
}
#sel-ref:focus { background: var(--green-soft); }
#fx-label {
  width: 30px; display: flex; align-items: center; justify-content: center;
  font-style: italic; font-family: Georgia, serif; color: var(--ink-soft);
  border-right: 1px solid var(--line);
}
#fx-input {
  flex: 1; border: none; outline: none; padding: 0 10px;
  font-size: 13px; font-family: inherit; color: var(--ink);
}

/* ---- grid ----------------------------------------------------------------------- */
#grid-wrap { position: relative; flex: 1; overflow: hidden; background: var(--card); }

#corner {
  position: absolute; left: 0; top: 0; z-index: 5;
  width: var(--rowhdr-w); height: var(--colhdr-h);
  background: var(--hdr-bg);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
#colhdr {
  position: absolute; top: 0; left: var(--rowhdr-w); right: 0; height: var(--colhdr-h);
  overflow: hidden; z-index: 4;
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--line);
}
#colhdr-inner { position: relative; height: 100%; will-change: transform; }
.ch {
  position: absolute; top: 0; height: var(--colhdr-h);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--ink-soft);
  border-right: 1px solid var(--line);
  user-select: none; cursor: pointer;
}
.ch.hit { background: var(--hdr-bg-hit); color: var(--green); }
.ch .rz {
  position: absolute; right: -4px; top: 0; width: 8px; height: 100%;
  cursor: col-resize; z-index: 2;
}
#rowhdr {
  position: absolute; top: var(--colhdr-h); left: 0; bottom: 0; width: var(--rowhdr-w);
  overflow: hidden; z-index: 4;
  background: var(--hdr-bg);
  border-right: 1px solid var(--line);
}
#rowhdr-inner { position: relative; will-change: transform; }
.rh {
  position: absolute; left: 0; width: var(--rowhdr-w); height: var(--row-h);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  user-select: none; cursor: pointer;
}
.rh.hit { background: var(--hdr-bg-hit); color: var(--green); font-weight: 600; }

#scroller {
  position: absolute; top: var(--colhdr-h); left: var(--rowhdr-w); right: 0; bottom: 0;
  overflow: auto;
}
#sizer {
  position: relative;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 25px, var(--line) 25px, var(--line) 26px);
}
#gridlines-v { position: absolute; inset: 0; pointer-events: none; }
.vline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }

#cells { position: absolute; left: 0; top: 0; }
.cell {
  position: absolute;
  padding: 0 5px;
  display: flex; align-items: center;
  white-space: nowrap; overflow: hidden;
  background: var(--bg);
  font-size: 13px;
  pointer-events: none;
}
.cell.al-r { justify-content: flex-end; }
.cell.al-c { justify-content: center; }
.cell.al-l { justify-content: flex-start; }
.cell.fb { font-weight: 700; }
.cell.fi { font-style: italic; }
.cell.fu { text-decoration: underline; }
.cell.err { color: #b42318; font-weight: 600; font-size: 12px; }

#sel-range {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--green-soft);
  border: 1px solid var(--green-mid);
}
#sel-focus {
  position: absolute; pointer-events: none; z-index: 3;
  border: 2px solid var(--green);
  background: transparent;
}
#fill-handle {
  position: absolute; z-index: 4;
  width: 7px; height: 7px;
  background: var(--green);
  border: 1px solid #fff;
  cursor: crosshair;
}
#fill-preview {
  position: absolute; pointer-events: none; z-index: 2; display: none;
  border: 1.5px dashed var(--green);
}
#cell-editor {
  position: absolute; z-index: 6; display: none;
  border: 2px solid var(--green); outline: none;
  padding: 0 4px; font-size: 13px; font-family: inherit;
  background: var(--card); color: var(--ink);
}

/* ---- bottom bar -------------------------------------------------------------------- */
#bottombar {
  display: flex; align-items: center;
  border-top: 1px solid var(--line);
  background: var(--hdr-bg);
  height: 32px;
  padding: 0 8px;
  gap: 12px;
}
#tabs { display: flex; align-items: flex-end; gap: 2px; overflow-x: auto; }
.tab {
  padding: 5px 14px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: var(--bg-hover);
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tab.active { background: var(--card); color: var(--green); font-weight: 600; border-color: var(--green-mid); }
.tab.add { font-weight: 700; padding: 5px 10px; }
.tab.add:hover { color: var(--green); }
.tab-rename { width: 90px; font-size: 12px; border: 1px solid var(--green); outline: none; }
#status-stats { margin-left: auto; font-size: 12px; color: var(--ink-soft); white-space: pre; }
#status-save { font-size: 12px; color: var(--green); white-space: nowrap; }

/* ---- hidden clipboard proxy ------------------------------------------------------------ */
#clip-proxy {
  position: fixed; left: -9999px; top: 0;
  width: 10px; height: 10px;
  opacity: 0;
}

/* ---- formula smarts ------------------------------------------------------------------------ */
#ref-overlays { position: absolute; inset: 0; pointer-events: none; }
.ref-box { position: absolute; border: 1.5px solid; pointer-events: none; z-index: 2; }

#fn-ac {
  position: fixed; z-index: 60; display: none;
  min-width: 300px; max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 3px;
  font-size: 12px;
}
.ac-item { padding: 5px 10px; border-radius: 5px; cursor: pointer; display: flex; gap: 2px; align-items: baseline; white-space: nowrap; overflow: hidden; }
.ac-item b { color: var(--green); font-size: 12.5px; }
.ac-item span { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.ac-item.sel { background: var(--green-soft); }

/* ---- find bar ---------------------------------------------------------------------------------- */
#find-bar {
  position: fixed; top: 112px; right: 16px; z-index: 45;
  display: none; align-items: center; gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  padding: 6px 8px;
}
#find-input {
  width: 180px; height: 26px;
  border: 1px solid var(--line); border-radius: 5px;
  padding: 0 8px; font-size: 12.5px; font-family: inherit;
  outline: none;
}
#find-input:focus { border-color: var(--green); }
#find-count { font-size: 11.5px; color: var(--ink-soft); min-width: 56px; text-align: center; }

/* ---- color pickers ---------------------------------------------------------------------------- */
.tc-icon { position: relative; font-weight: 700; font-size: 13px; display: inline-block; line-height: 1; }
.tc-bar { position: absolute; left: -1px; right: -1px; bottom: -4px; height: 3px; background: #b42318; border-radius: 1px; }
#color-menu {
  position: fixed; z-index: 60; display: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 8px;
}
.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.color-sw {
  width: 24px; height: 24px;
  border: 1px solid var(--line); border-radius: 5px;
  cursor: pointer; padding: 0;
}
.color-sw:hover { outline: 2px solid var(--green); outline-offset: 1px; }
.color-sw.nocolor {
  background: linear-gradient(135deg, #fff 45%, #b42318 45%, #b42318 55%, #fff 55%);
}

/* ---- Benmore badge ----------------------------------------------------------------------------- */
#bm-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--ink-soft);
  text-decoration: none;
  padding: 3px 9px;
  border: 1px solid var(--line); border-radius: 99px;
  background: var(--card);
  white-space: nowrap;
}
#bm-badge b { color: var(--ink); font-weight: 600; }
#bm-badge img { border-radius: 3px; }
#bm-badge:hover { border-color: #2563eb; }
#bm-badge:hover b { color: #2563eb; }
#bm-badge.floating {
  position: fixed; right: 12px; bottom: 12px; z-index: 40;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.10);
}

/* ---- embedded charts (floating over the grid, Excel-style) --------------------------------- */
#embed-layer { position: absolute; left: 0; top: 0; z-index: 5; }
.embed-card {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.embed-card:hover { border-color: var(--green-mid); }
.embed-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 2px;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  cursor: move;
  user-select: none;
}
/* visibility (not display) so the header height never changes on hover —
   otherwise the chart body reflows and the chart shrinks */
.embed-btns { display: flex; gap: 2px; visibility: hidden; }
.embed-card:hover .embed-btns { visibility: visible; }
.embed-btns a.vc-btn { text-decoration: none; font-size: 11px; line-height: 1.6; }
.embed-body { flex: 1; min-height: 0; padding: 2px 10px 8px; position: relative; }
.embed-body canvas { width: 100% !important; height: 100% !important; }
.embed-rz {
  position: absolute; right: 0; bottom: 0;
  width: 14px; height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--green-mid) 50%);
  border-bottom-right-radius: 9px;
}

#chart-menu {
  position: fixed; z-index: 55; display: none;
  min-width: 260px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  font-size: 13px;
}

/* ---- context menu ------------------------------------------------------------------------- */
#ctx-menu {
  position: fixed; z-index: 50; display: none;
  min-width: 190px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
}
.ctx-item { padding: 6px 12px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.ctx-item:hover { background: var(--green-soft); color: var(--green); }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---- help modal ------------------------------------------------------------------------------ */
#help-modal {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.45);
}
#help-card {
  width: min(620px, 92vw); max-height: 84vh; overflow-y: auto;
  background: var(--card); border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
#help-card h2 { margin: 0 0 8px; font-size: 18px; display: flex; justify-content: space-between; align-items: center; }
#help-card h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--green); }
#help-close { border: none; background: var(--bg-hover); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; font-size: 13px; }
.help-priv { font-size: 13px; color: var(--ink); background: var(--green-soft); border-radius: 8px; padding: 10px 12px; margin: 0; }
.help-keys { border-collapse: collapse; width: 100%; font-size: 13px; }
.help-keys td { padding: 3px 8px 3px 0; vertical-align: top; }
.help-keys td:first-child { color: var(--green); font-weight: 600; white-space: nowrap; }
.help-fns { font-size: 12px; color: var(--ink-soft); line-height: 1.7; }
#help-card code { background: var(--bg-hover); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
#help-card p { font-size: 13px; }

/* ---- Visualizer ----------------------------------------------------------------------------- */
#viz-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
#viz-toolbar .tb-btn { border: 1px solid var(--line); background: var(--card); }
#viz-toolbar .tb-btn.accent { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
#viz-toolbar .tb-btn.accent:hover { filter: brightness(1.15); }
#viz-hint { font-size: 12px; color: var(--ink-soft); margin-left: 8px; }
#viz-save { font-size: 12px; color: var(--green); }

#viz-main { flex: 1; display: flex; min-height: 0; }
#viz-canvas {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-content: start;
  background: var(--canvas);
}
#viz-empty { grid-column: span 3; text-align: center; color: var(--ink-soft); padding: 80px 20px; }
#viz-empty h2 { color: var(--ink); margin: 0 0 8px; }
#viz-empty a { color: var(--green); }

.viz-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex; flex-direction: column;
  height: 300px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  overflow: hidden;
}
.viz-card.tall { height: 460px; }
.viz-card.size-1 { grid-column: span 1; }
.viz-card.size-2 { grid-column: span 2; }
.viz-card.size-3 { grid-column: span 3; }
.viz-card.sel { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft), 0 1px 3px rgba(15,23,42,.05); }
.viz-card-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 4px;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.viz-card-btns { display: flex; gap: 2px; visibility: hidden; }
.viz-card:hover .viz-card-btns { visibility: visible; }
.vc-btn { border: none; background: transparent; cursor: pointer; color: var(--ink-soft); border-radius: 4px; font-size: 12px; padding: 2px 6px; }
.vc-btn:hover { background: var(--bg-hover); color: var(--ink); }
.viz-card-body { flex: 1; min-height: 0; padding: 4px 12px 12px; position: relative; }
.viz-card-body canvas { width: 100% !important; height: 100% !important; }
.viz-msg { color: var(--ink-soft); font-size: 12.5px; padding: 12px 4px; }

.viz-kpi { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.viz-kpi-num { font-size: 44px; font-weight: 700; color: var(--green); letter-spacing: -1px; }
.viz-kpi-sub { font-size: 12px; color: var(--ink-soft); }

.viz-tablewrap { height: 100%; overflow: auto; }
.viz-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.viz-table th {
  position: sticky; top: 0;
  background: var(--hdr-bg);
  text-align: left; font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding: 5px 8px; white-space: nowrap;
}
.viz-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.viz-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

#viz-panel {
  width: 300px; flex: none;
  border-left: 1px solid var(--line);
  background: var(--card);
  overflow-y: auto;
  padding: 14px;
}
#viz-panel-empty { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.vp-group { margin-bottom: 14px; }
.vp-group > label {
  display: block;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.vp-input {
  width: 100%;
  height: 28px;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 12.5px; font-family: inherit; color: var(--ink);
  padding: 0 8px; background: var(--card);
}
.vp-input:focus { outline: none; border-color: var(--green); }
.vp-row { display: flex; gap: 6px; align-items: center; }
.vp-row.wrap { flex-wrap: wrap; }
.vp-row .vp-input { flex: 1; min-width: 0; }
.vp-agg { max-width: 100px; }
.vp-sm { max-width: 110px; }
.vp-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.vp-type {
  height: 28px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); font-size: 11.5px; cursor: pointer; color: var(--ink);
}
.vp-type:hover { background: var(--bg-hover); }
.vp-type.on { background: var(--green-soft); border-color: var(--green); color: var(--green); font-weight: 600; }
.vp-check { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.vp-filter { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; background: var(--bg-soft); }
.vp-f-del { border: none; background: transparent; cursor: pointer; color: var(--ink-soft); font-size: 12px; }
.vp-f-del:hover { color: #b42318; }
.vp-f-body { margin-top: 6px; }
.vp-f-links { font-size: 11.5px; margin-bottom: 4px; }
.vp-f-links a { color: var(--green); cursor: pointer; }
.vp-f-vals { max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.vp-addfilter {
  width: 100%; height: 28px;
  border: 1px dashed var(--green-mid); border-radius: 6px;
  background: transparent; color: var(--green);
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.vp-addfilter:hover { background: var(--green-soft); }

@media (max-width: 1100px) {
  #viz-canvas { grid-template-columns: repeat(2, 1fr); }
  .viz-card.size-2, .viz-card.size-3 { grid-column: span 2; }
}

/* ---- dark-mode + theme toggle odds & ends ----------------------------------------------------- */
#btn-theme {
  background: rgba(255,255,255,.16); color: #fff; border: none;
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
#btn-theme:hover { background: rgba(255,255,255,.3); }
#btn-theme svg { width: 13px; height: 13px; }
#btn-theme .ic-sun { display: none; }
[data-theme="dark"] #btn-theme .ic-moon { display: none; }
[data-theme="dark"] #btn-theme .ic-sun { display: block; }

#fx-input, #find-input { background: transparent; }
#sel-ref { background: transparent; }
#fx-input::placeholder, #find-input::placeholder, .vp-input::placeholder { color: var(--ink-soft); }
[data-theme="dark"] .tb-btn.danger:hover { background: rgba(180, 35, 24, 0.2); color: #f1908a; border-color: rgba(180,35,24,.5); }
[data-theme="dark"] #bm-badge { background: var(--card); }
[data-theme="dark"] .viz-kpi-num { color: var(--accent); }

/* ---- brand typography accents ------------------------------------------------------------------ */
.cell, #fx-input, #cell-editor, .viz-table td { font-variant-numeric: tabular-nums; }
.viz-card-hd, .embed-hd, .viz-kpi-num, #help-card h2, #help-card h3, #viz-empty h2 { font-family: var(--font-display); }
.viz-card-hd, .embed-hd { font-weight: 500; }
.vp-group > label, #tabs .tab { font-family: var(--font-display); }
#tabs .tab { font-weight: 500; }
#bm-badge b { font-family: var(--font-display); font-weight: 500; }

[data-theme="dark"] [data-theme="dark"] 


/* ---- workbook switcher --------------------------------------------------------------------- */
#book-select {
  margin-left: 10px;
  height: 26px; max-width: 170px;
  border: 1px solid rgba(255,255,255,.25); border-radius: 6px;
  background: rgba(255,255,255,.1); color: #fff;
  font-size: 12px; font-family: var(--font-display); padding: 0 4px;
  outline: none;
}
#book-select option { color: var(--ink); background: var(--card); }

/* ---- frozen header row ------------------------------------------------------------------------ */
#frozenrow {
  position: absolute; top: var(--colhdr-h); left: var(--rowhdr-w); right: 0;
  height: var(--row-h);
  overflow: hidden; z-index: 4; display: none;
  background: var(--bg);
  border-bottom: 2px solid var(--green-mid);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
#frozenrow-inner { position: relative; height: 100%; will-change: transform; }
#frozenrow .cell { pointer-events: none; }

/* ---- column filter funnel ----------------------------------------------------------------------- */
.ch .flt {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 9px; color: var(--ink-soft);
  width: 14px; height: 14px; line-height: 14px; text-align: center;
  border-radius: 3px; cursor: pointer;
  opacity: 0; transition: opacity .1s;
}
.ch:hover .flt { opacity: 1; }
.ch .flt.on { opacity: 1; background: var(--accent); color: #fff; }
.ch .flt:hover { background: var(--green-soft); color: var(--accent); }
.ch .flt.on:hover { background: var(--accent); color: #fff; }

#filter-menu {
  position: fixed; z-index: 55; display: none;
  min-width: 200px; max-width: 280px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 8px 10px;
  font-size: 12.5px;
}
#filter-menu .vp-f-vals { max-height: 240px; }

#export-menu, #dv-list {
  position: fixed; z-index: 55; display: none;
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 4px;
  font-size: 13px;
}
#dv-list { min-width: 160px; padding: 3px; }

/* ---- find & replace rows ------------------------------------------------------------------------ */
#find-bar { flex-direction: column; gap: 5px; }
.find-row { display: flex; align-items: center; gap: 4px; }
#replace-input {
  width: 180px; height: 26px;
  border: 1px solid var(--line); border-radius: 5px;
  padding: 0 8px; font-size: 12.5px; font-family: inherit;
  outline: none; background: transparent; color: var(--ink);
}
#replace-input:focus { border-color: var(--green); }

/* ---- modals (conditional formatting, validation) ------------------------------------------------- */
.ls-modal {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.45);
}
.ls-card {
  width: min(680px, 94vw); max-height: 80vh; overflow-y: auto;
  background: var(--card); border-radius: 12px;
  padding: 18px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.ls-card h2 { margin: 0 0 10px; font-size: 16px; font-family: var(--font-display); display: flex; justify-content: space-between; align-items: center; }
.ls-card h3 { margin: 14px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--green); font-family: var(--font-display); }
.ls-card input[type="color"] { width: 34px; height: 28px; padding: 1px; border: 1px solid var(--line); border-radius: 5px; background: var(--card); cursor: pointer; }

.cf-rule {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; margin-bottom: 4px;
  border: 1px solid var(--line); border-radius: 7px;
  font-size: 12.5px;
}
.cf-sw {
  width: 44px; height: 20px; flex: none;
  border-radius: 4px; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.cf-desc { flex: 1; }

/* ---- cell notes ------------------------------------------------------------------------------------ */
.cell.has-note { pointer-events: auto; }
.cell.has-note::after {
  content: '';
  position: absolute; right: 0; top: 0;
  border-left: 6px solid transparent;
  border-top: 6px solid #f59e0b;
}

/* ---- pivot table totals ------------------------------------------------------------------------------ */
.viz-table.pivot th { text-align: left; }
.viz-table.pivot th.num { text-align: right; }
.viz-table.pivot .tot, .viz-table.pivot tr.tot td, .viz-table.pivot tr.tot th {
  font-weight: 700;
  border-top: 2px solid var(--line);
  background: var(--bg-soft);
}

/* glyph-free dropdown affordances (the body font lacks U+25BE) */
.tb-btn.menu-btn::after {
  content: '';
  display: inline-block;
  margin-left: 5px; vertical-align: 2px;
  border: 4px solid transparent;
  border-top-color: currentColor;
}
.ch .flt::after {
  content: '';
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -25%);
  border: 4px solid transparent;
  border-top-color: currentColor;
}
