/* GreenDeck spreadsheet (sheet.js), drawn like Excel: name box + formula bar, grey headers,
   gridlines, green selection, sheet tabs at the bottom. Every cell can be typed. */
.sv {
  --xl: #107c41; --xl-2: #0b5c30; --xl-soft: #e2f1e8; --grid: #e1e1e1; --head: #f3f3f3; --head-line: #c8c8c8;
  --hand: #ffedd5; --hand-mark: #ea7a12;
  display: flex; flex-direction: column; height: 100%; min-height: 360px; overflow: hidden; background: #fff;
  border: 1px solid #d6d6d6; border-radius: 10px; font-family: Aptos, Calibri, "Segoe UI", -apple-system, system-ui, sans-serif;
  transition: opacity .2s;
}
.sv.loading { opacity: .55; }

/* name box + fx + formula */
.sv-bar { flex: none; display: flex; align-items: center; gap: 0; height: 40px; border-bottom: 1px solid #d6d6d6; background: #fff; font-size: 14px; }
.sv-ref { flex: none; width: 92px; height: 100%; display: grid; place-items: center; border-right: 1px solid #d6d6d6; font-size: 13px; font-weight: 600; color: #222; }
.sv-fx { flex: none; width: 44px; height: 100%; display: grid; place-items: center; border-right: 1px solid #d6d6d6; font-family: Georgia, serif; font-style: italic; font-weight: 700; color: #777; }
.sv-val { flex: 1 1 auto; min-width: 60px; height: 100%; display: flex; align-items: center; padding: 0 12px; color: #111; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.sv-val:hover { background: #fafafa; }
.sv-kind { flex: none; margin: 0 8px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #f1f1f1; color: #555; }
.sv-kind.k-input { background: var(--xl-soft); color: var(--xl-2); }
.sv-kind.k-linked { background: #e6effa; color: #24539a; }
.sv-kind.k-hand { background: var(--hand); color: #b45309; }
.sv-note { flex: 0 1 auto; max-width: 44%; padding-right: 12px; font-size: 12.5px; color: #6b6b6b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-bar.denied { background: #fdecea; }
.sv-bar.denied .sv-note { color: #b42318; font-weight: 600; }
.sv-bar.shake { animation: svShake .32s ease; }
.sv-go { margin-left: 4px; height: 24px; padding: 0 8px; border: 1px solid #c9d6ea; border-radius: 6px; background: #fff; color: #24539a; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.sv-go:hover { background: #eef4fc; }
.sv-lock { display: none; }

.sv-histw { flex: none; display: flex; height: 100%; border-right: 1px solid #d6d6d6; }
.sv-hist { width: 38px; height: 100%; display: grid; place-items: center; border: 0; background: transparent; color: #333; cursor: pointer; transition: background .12s, color .12s; }
.sv-hist + .sv-hist { border-left: 1px solid #ececec; }
.sv-hist svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sv-hist:hover:not(:disabled) { background: var(--xl-soft); color: var(--xl-2); }
.sv-hist:active:not(:disabled) svg { transform: scale(.88); }
.sv-hist:disabled { color: #c4c4c4; cursor: default; }

/* grid */
.sv-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; outline: none; background: #fff; }
.sv-grid { table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 13.5px; color: #111; }
.sv-grid th { height: 24px; padding: 0 4px; background: var(--head); color: #444; font-size: 12px; font-weight: 400; text-align: center; border-right: 1px solid var(--head-line); border-bottom: 1px solid var(--head-line); user-select: none; transition: background .1s, color .1s; }
.sv-grid thead th { position: sticky; top: 0; z-index: 3; }
.sv-grid tbody th { position: sticky; left: 0; z-index: 2; height: 28px; }
.sv-grid .sv-corner { left: 0; z-index: 4; background: var(--head); }
.sv-grid th.on { background: #d3e3d9; color: var(--xl-2); font-weight: 700; box-shadow: inset 0 -2px 0 var(--xl); }
.sv-grid tbody th.on { box-shadow: inset -2px 0 0 var(--xl); }
.sv-grid td { position: relative; height: 28px; padding: 0 7px; border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); white-space: nowrap; overflow: hidden; cursor: cell; user-select: none; }
.sv-t { display: block; overflow: hidden; text-overflow: ellipsis; }
.sv-grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sv-grid td.bold { font-weight: 700; }
.sv-grid td.on-dark { color: #fff; }
.sv-grid td.spill { overflow: visible; z-index: 1; }
.sv-grid td.spill .sv-t { width: max-content; }
.sv-grid td.no-r { border-right-color: transparent; }

/* kinds: like Excel, a small corner mark, the value stays readable */
.sv-grid td.k-input:not(.on-dark) { background: #fbfefc; font-weight: 600; }
.sv-grid td.k-input.is-blank::after { content: "Type here"; position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-weight: 400; color: #aaa; }
.sv-grid td.k-linked::before, .sv-grid td.k-calculated::before, .sv-grid td.k-hand::before { content: ""; position: absolute; left: 0; top: 0; border-style: solid; border-width: 7px 7px 0 0; border-color: #3a7bd5 transparent transparent transparent; }
.sv-grid td.k-linked { color: #1d3f72; }
.sv-grid td.k-calculated::before { border-top-color: #9a9a9a; }
.sv-grid td.k-calculated { color: #333; }
.sv-grid td.k-hand { background: var(--hand) !important; color: #9a4a06; }
.sv-grid td.k-hand::before { border-top-color: var(--hand-mark); }

/* selection, editing */
.sv-grid td.sv-sel { box-shadow: inset 0 0 0 2px var(--xl); z-index: 1; }
.sv-grid td.sv-sel::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 6px; height: 6px; background: var(--xl); border: 1px solid #fff; }
.sv-grid td.k-input.is-blank.sv-sel::after { content: "Type here"; right: 8px; bottom: auto; width: auto; height: auto; background: none; border: 0; }
.sv-grid td.sv-editing { padding: 0; overflow: visible; background: #fff; box-shadow: 0 0 0 2px var(--xl), 0 4px 14px rgba(16, 124, 65, .2); z-index: 2; }
.sv-grid td.sv-editing .sv-t, .sv-grid td.sv-editing::after { visibility: hidden; }
.sv-in { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0 7px; border: 0; outline: none; background: #fff; font: inherit; color: #111; }
.sv-in.num { text-align: right; font-variant-numeric: tabular-nums; }
.sv-grid td.sv-saving { opacity: .55; }
.sv-grid td.sv-flash { animation: svFlash 1.8s ease; }
.sv-grid td.sv-flash-still { background: #e2f1e8; }
.sv-grid td.sv-target { animation: svTarget 1.8s ease; }
.sv-grid td.sv-copied { animation: svCopied .5s ease; }

/* sheet tabs + legend, like the bottom of Excel */
.sv-foot { flex: none; display: flex; align-items: stretch; gap: 16px; height: 34px; border-top: 1px solid #d6d6d6; background: var(--head); padding: 0 12px 0 6px; }
.sv-tabs { flex: none; display: flex; gap: 0; max-width: 70%; overflow-x: auto; }
.sv-tab { position: relative; height: 100%; padding: 0 16px; border: 0; border-right: 1px solid #d6d6d6; background: transparent; font: inherit; font-size: 13px; color: #444; cursor: pointer; white-space: nowrap; }
.sv-tab:hover { background: #e9e9e9; }
.sv-tab.on { background: #fff; color: var(--xl); font-weight: 700; box-shadow: inset 0 -3px 0 var(--xl); }
.sv-tab.has-change::after { content: ""; position: absolute; top: 6px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--hand-mark); }
.sv-legend { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: 0 1 auto; min-width: 0; overflow: hidden; font-size: 12px; color: #555; }
.sv-lg { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 6px; border-radius: 99px; white-space: nowrap; }
.sv-lg:hover { background: #e8e8e8; }
.sv-lg i { position: relative; flex: none; width: 13px; height: 13px; border-radius: 4px; background: #fff; box-shadow: inset 0 0 0 1px #cfcfcf; overflow: hidden; }
.sv-lg i::before { content: ""; position: absolute; left: 0; top: 0; border-style: solid; border-width: 6px 6px 0 0; border-color: transparent; }
.sv-lg .k-input { background: #fbfefc; box-shadow: inset 0 0 0 1.5px #7fbf98; }
.sv-lg .k-linked::before { border-top-color: #3a7bd5; }
.sv-lg .k-calculated { background: #f4f4f4; }
.sv-lg .k-calculated::before { border-top-color: #9a9a9a; }
.sv-lg .k-hand { background: var(--hand); box-shadow: inset 0 0 0 1px #f5c48f; }
.sv-lg .k-hand::before { border-top-color: var(--hand-mark); }
.sv-fail { display: flex; align-items: center; gap: 14px; padding: 36px 24px; color: #666; }

@keyframes svFlash { 0%, 30% { background: #fff1b8; } 100% { } }
@keyframes svTarget { 0%, 100% { box-shadow: inset 0 0 0 2px #107c41; } 30%, 60% { box-shadow: inset 0 0 0 2px #107c41, 0 0 0 5px rgba(16, 124, 65, .25); } }
@keyframes svCopied { 0% { box-shadow: inset 0 0 0 2px #107c41, 0 0 0 0 rgba(16, 124, 65, .35); } 100% { box-shadow: inset 0 0 0 2px #107c41, 0 0 0 8px rgba(16, 124, 65, 0); } }
@keyframes svShake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (max-width: 760px) {
  .sv-legend, .sv-note, .sv-kind { display: none; }
  .sv-ref { width: 64px; }
  .sv-fx { width: 34px; }
  .sv-hist { width: 34px; }
  .sv-grid td, .sv-grid tbody th { height: 34px; }
  .sv-tab { padding: 0 12px; }
}
