/* ProSync Excel online */
body.sheet-page { overflow: hidden; display: flex; flex-direction: column; height: 100vh; height: 100dvh; margin: 0; }
body.sheet-page > header { flex-shrink: 0; }
body.sheet-page footer { display: none; }
body.sheet-page main { padding: 0; margin: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }

#sheet-app {
  --sx-grid: #e1e5ea;
  --sx-head: #f3f5f8;
  --sx-head-on: #d7e6fb;
  --sx-head-ink: #475467;
  --sx-sel: #1a73e8;
  --sx-bar: var(--bg, #fff);
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 300px;
  background: var(--bg, #fff);
  color: var(--ink, #111);
  font-family: var(--font, system-ui, sans-serif);
  font-size: 13px;
  user-select: none;
  -webkit-user-select: none;
}
#sheet-app input, #sheet-app textarea, #sheet-app select, #sheet-app button { font: inherit; color: inherit; }

/* title row */
.sx-top { display: flex; align-items: center; gap: 8px; padding: 6px 12px 2px; flex-wrap: wrap; min-width: 0; }
.sx-name {
  font-size: 16px !important; font-weight: 600; border: 1px solid transparent; border-radius: 6px;
  padding: 3px 8px; background: transparent; min-width: 80px; max-width: 360px; width: 26ch; flex: 0 1 auto;
}
.sx-name:hover { border-color: var(--line, #ddd); }
.sx-name:focus { outline: none; border-color: var(--sx-sel); background: var(--bg, #fff); }
.sx-saved { color: var(--muted, #667); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 0; }
.sx-top-end { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }
.sx-topbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; min-width: 32px; padding: 0 8px;
  border: 1px solid var(--line, #ddd); border-radius: 8px; background: var(--bg, #fff); color: var(--ink, #111); cursor: pointer; flex: none;
}
.sx-topbtn:hover { background: var(--bg-soft, #f4f7fb); }
.sx-topbtn.theme-toggle { padding: 0; width: 32px; }
.sx-topbtn .sx-ic { width: 18px; height: 18px; }
.sx-langbtn { font-size: 13px; font-weight: 500; }
.sx-lang-short { display: none; }
.sx-menus { display: flex; gap: 2px; flex-wrap: wrap; order: 3; width: 100%; }
.sx-menus button {
  border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.sx-menus button:hover, .sx-menus button[aria-expanded="true"] { background: var(--bg-soft, #f2f4f7); }

/* icons */
.sx-ic { display: block; flex: none; width: 18px; height: 18px; pointer-events: none; }
.sx-chev { display: block; flex: none; width: 10px; height: 10px; margin-left: 1px; opacity: .7; pointer-events: none; }

/* toolbar */
.sx-toolbar {
  display: flex; align-items: center; gap: 1px; padding: 3px 8px; margin: 0 8px;
  background: var(--bg-soft, #f4f7fb); border-radius: 22px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
  flex-shrink: 0; min-width: 0; touch-action: pan-x; overscroll-behavior-x: contain;
}
.sx-toolbar::-webkit-scrollbar { height: 4px; }
.sx-tool {
  flex: none; min-width: 30px; height: 30px; border: 0; background: transparent; border-radius: 6px; color: var(--ink, #111);
  cursor: pointer; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.sx-tool.sx-dd { padding: 0 3px 0 5px; }
.sx-tool:hover { background: rgba(127, 127, 127, 0.16); }
.sx-tool:focus-visible { outline: 2px solid var(--accent, #1f6feb); outline-offset: -2px; }
.sx-tool.on { background: var(--accent-soft, #e8f0fe); color: var(--accent, #1f6feb); }
.sx-sep { flex: none; width: 1px; height: 20px; background: var(--line, #ddd); margin: 0 5px; }
.sx-toolbar select, .sx-ctxbar select {
  flex: none; height: 28px; border: 1px solid var(--line, #ddd); border-radius: 6px; background: var(--bg, #fff);
  padding: 0 4px; cursor: pointer; font-size: 12.5px; color: var(--ink, #111);
}
.sx-font { width: 140px; }
.sx-size { width: 56px; }
.sx-fmt { width: 118px; }

/* the formatting bar over the right-click menu */
.sx-ctxbar {
  position: absolute; z-index: 41; display: flex; align-items: center; flex-wrap: wrap; gap: 1px; padding: 4px 6px;
  max-width: calc(100% - 8px); box-sizing: border-box; background: var(--bg, #fff); color: var(--ink, #111);
  border: 1px solid var(--line, #ddd); border-radius: 10px; box-shadow: 0 8px 26px rgba(16, 24, 40, 0.18);
  animation: sx-fade 0.12s ease-out;
}
.sx-ctxbar[hidden] { display: none; }
.sx-ctxbar .sx-font { width: 104px; }
.sx-ctxbar .sx-size { width: 52px; }
.sx-ctxbar .sx-sep { margin: 0 3px; }

/* formula bar */
.sx-bar {
  display: flex; align-items: stretch; gap: 0; margin: 6px 8px 4px; border: 1px solid var(--line, #ddd);
  border-radius: 8px; overflow: hidden; background: var(--bg, #fff); flex-shrink: 0; height: 30px;
}
.sx-namebox {
  width: 96px; border: 0; border-right: 1px solid var(--line, #ddd); padding: 0 8px; background: transparent;
  font-variant-numeric: tabular-nums;
}
.sx-fx {
  border: 0; border-right: 1px solid var(--line, #ddd); background: transparent; padding: 0 9px; cursor: pointer;
  color: var(--muted, #667); display: inline-flex; align-items: center;
}
.sx-fx .sx-ic { width: 16px; height: 16px; }
.sx-fx:hover { background: var(--bg-soft, #f4f7fb); }
.sx-input { flex: 1; min-width: 0; border: 0; padding: 0 8px; background: transparent; }
.sx-namebox:focus, .sx-input:focus { outline: none; background: var(--accent-soft, #eef4ff); }

/* the grid */
.sx-main {
  position: relative; flex: 1; min-height: 0; overflow: hidden; border-top: 1px solid var(--line, #ddd);
  background: #fff; color: #111;
}
.sx-corner {
  position: absolute; left: 0; top: 0; width: 48px; height: 26px; background: var(--sx-head);
  border-right: 1px solid #c8ced6; border-bottom: 1px solid #c8ced6; z-index: 6; cursor: pointer;
}
.sx-corner::after {
  content: ""; position: absolute; right: 3px; bottom: 3px; border: 5px solid transparent;
  border-right-color: #b3bac4; border-bottom-color: #b3bac4;
}
.sx-colhead, .sx-rowhead { position: absolute; overflow: hidden; background: var(--sx-head); z-index: 5; }
.sx-colhead { left: 48px; right: 0; top: 0; height: 26px; border-bottom: 1px solid #c8ced6; }
.sx-rowhead { left: 0; top: 26px; bottom: 0; width: 48px; border-right: 1px solid #c8ced6; }
.sx-inner { position: absolute; left: 0; top: 0; will-change: transform; }
.sx-h {
  position: absolute; box-sizing: border-box; color: var(--sx-head-ink); font-size: 12px; text-align: center;
  cursor: default; font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.sx-colhead .sx-h { top: 0; height: 26px; line-height: 26px; border-right: 1px solid #d5dae1; }
.sx-rowhead .sx-h { left: 0; width: 48px; border-bottom: 1px solid #d5dae1; overflow: hidden; }
.sx-h.on { background: var(--sx-head-on); color: #0b57d0; font-weight: 600; }
.sx-h.frozen { background: #eaeef3; }
.sx-grip { position: absolute; z-index: 2; }
.sx-colhead .sx-grip { right: -4px; top: 0; width: 8px; height: 100%; cursor: col-resize; }
.sx-rowhead .sx-grip { left: 0; bottom: -4px; width: 100%; height: 8px; cursor: row-resize; }
.sx-grip:hover { background: rgba(26, 115, 232, 0.35); }

.sx-scroll {
  position: absolute; left: 48px; top: 26px; right: 0; bottom: 0; overflow: auto; outline: none;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.sx-content { position: relative; }
.sx-cells, .sx-marks, .sx-charts { position: absolute; left: 0; top: 0; }
.sx-marks { pointer-events: none; z-index: 2; }
.sx-charts { z-index: 3; }

.sx-cell {
  position: absolute; box-sizing: border-box; display: flex; overflow: hidden; padding: 0 4px 1px;
  border-right: 1px solid var(--sx-grid); border-bottom: 1px solid var(--sx-grid); white-space: pre;
  line-height: 1.25; font-family: "Sarabun", "Tahoma", "Leelawadee UI", "Noto Sans Thai", sans-serif;
  background-clip: padding-box;
}
.sx-cell.nogrid { border-color: transparent; }
.sx-cell > span { min-width: 0; }
.sx-cell.clip > span { overflow: hidden; }
.sx-cell.spill { overflow: visible; z-index: 1; border-right-color: transparent; background-color: transparent; }
.sx-cell.spill > span { position: relative; z-index: 1; }
.sx-cell a { color: #1155cc; text-decoration: underline; }

.sx-range {
  position: absolute; box-sizing: border-box; background: rgba(26, 115, 232, 0.1); border: 1px solid var(--sx-sel);
}
.sx-active { position: absolute; box-sizing: border-box; border: 2px solid var(--sx-sel); }
.sx-handle {
  position: absolute; width: 8px; height: 8px; background: var(--sx-sel); border: 1px solid #fff;
  box-sizing: border-box; pointer-events: auto; cursor: crosshair; z-index: 3;
}
.sx-copy {
  position: absolute; box-sizing: border-box; border: 2px dashed var(--sx-sel);
  animation: sx-march 0.6s linear infinite;
}
@keyframes sx-march { 50% { border-color: rgba(26, 115, 232, 0.35); } }
.sx-point { position: absolute; box-sizing: border-box; border: 2px dashed #e8710a; background: rgba(232, 113, 10, 0.08); }
.sx-fill { position: absolute; box-sizing: border-box; border: 1px dashed #5f6368; }
.sx-filter {
  position: absolute; width: 16px; height: 16px; padding: 0; border: 1px solid #b8c0cb; border-radius: 3px;
  background: #fff; pointer-events: auto; cursor: pointer; color: #333; display: grid; place-items: center;
}
.sx-filter .sx-ic { width: 11px; height: 11px; }
.sx-filter .sx-chev { width: 10px; height: 10px; margin: 0; opacity: 1; }
.sx-filter.on { background: #d7e6fb; border-color: var(--sx-sel); color: #0b57d0; }

.sx-pane { position: absolute; overflow: hidden; background: #fff; z-index: 4; pointer-events: none; }
.sx-pane .sx-inner > * { pointer-events: auto; }
.sx-pane-top { box-shadow: 0 2px 0 #b8c0cb; }
.sx-pane-left { box-shadow: 2px 0 0 #b8c0cb; }
.sx-pane-corner { z-index: 5; box-shadow: 2px 2px 0 #b8c0cb; }
.sx-pane[hidden] { display: none; }

.sx-editor {
  position: absolute; z-index: 8; box-sizing: border-box; margin: 0; padding: 2px 4px; resize: none;
  border: 2px solid var(--sx-sel); outline: none; background: #fff; color: #111; overflow: hidden;
  font-family: "Sarabun", "Tahoma", "Leelawadee UI", "Noto Sans Thai", sans-serif; font-size: 11pt;
  line-height: 1.25; white-space: pre; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); user-select: text;
}

/* charts */
.sx-chart {
  position: absolute; background: #fff; border: 1px solid #d0d5dd; border-radius: 4px; cursor: move;
  box-sizing: border-box; overflow: hidden;
}
.sx-chart svg { width: 100%; height: 100%; display: block; }
.sx-chart.on { border: 2px solid var(--sx-sel); overflow: visible; }
.sx-chart-x, .sx-chart-edit {
  position: absolute; top: 4px; width: 24px; height: 24px; border: 1px solid #d0d5dd; border-radius: 6px;
  background: #fff; cursor: pointer; display: none; padding: 0; color: #333; place-items: center;
}
.sx-chart-x .sx-ic, .sx-chart-edit .sx-ic { width: 15px; height: 15px; }
.sx-chart-x { right: 4px; }
.sx-chart-edit { right: 32px; }
.sx-chart:hover .sx-chart-x, .sx-chart:hover .sx-chart-edit, .sx-chart.on .sx-chart-x, .sx-chart.on .sx-chart-edit { display: grid; }
.sx-chart-size {
  position: absolute; right: -5px; bottom: -5px; width: 10px; height: 10px; background: var(--sx-sel);
  border: 1px solid #fff; cursor: nwse-resize; display: none;
}
.sx-chart.on .sx-chart-size { display: block; }

/* bottom: sheet tabs, status, zoom */
.sx-bottom {
  display: flex; align-items: center; gap: 8px; height: 34px; flex-shrink: 0; border-top: 1px solid var(--line, #ddd);
  background: var(--bg-soft, #f4f7fb); padding: 0 8px;
}
.sx-tabs { display: flex; align-items: center; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.sx-tabs::-webkit-scrollbar { display: none; }
.sx-tab, .sx-tab-add {
  flex: none; border: 0; background: transparent; height: 28px; padding: 0 14px; border-radius: 6px 6px 0 0;
  cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap;
}
.sx-tab-add { padding: 0 10px; font-size: 18px; border-radius: 6px; }
.sx-tab:hover, .sx-tab-add:hover { background: rgba(127, 127, 127, 0.14); }
.sx-tab.on { background: var(--bg, #fff); color: var(--accent, #1f6feb); font-weight: 600; box-shadow: 0 -1px 0 var(--line, #ddd) inset; }
.sx-tab.on:not([style]) { border-bottom-color: var(--accent, #1f6feb); }
.sx-status { color: var(--muted, #667); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.sx-zoom { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.sx-zoom button {
  width: 24px; height: 24px; border: 1px solid var(--line, #ddd); background: var(--bg, #fff); border-radius: 50%;
  cursor: pointer; line-height: 1; padding: 0; display: inline-grid; place-items: center; color: var(--ink, #111);
}
.sx-zoom .sx-ic { width: 14px; height: 14px; }
#sx-zoom-val { min-width: 38px; text-align: center; }

/* pop-ups and menus */
.sx-pop {
  position: absolute; z-index: 40; min-width: 180px; max-width: min(420px, calc(100vw - 16px));
  max-height: min(70vh, 560px); overflow: auto; background: var(--bg, #fff); color: var(--ink, #111);
  border: 1px solid var(--line, #ddd); border-radius: 10px; box-shadow: 0 10px 32px rgba(16, 24, 40, 0.2);
  padding: 6px; user-select: none;
}
.sx-pop[hidden] { display: none; }
.sx-pop hr { border: 0; border-top: 1px solid var(--line, #ddd); margin: 5px 4px; }
.sx-list > button, .sx-suggest > button, .sx-fn-list > button {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 18px; border: 0;
  background: transparent; text-align: left; padding: 6px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.sx-list > button:hover, .sx-suggest > button:hover, .sx-suggest > button.on, .sx-fn-list > button:hover {
  background: var(--accent-soft, #e8f0fe);
}
.sx-list kbd { font: 11px system-ui, sans-serif; color: var(--muted, #667); margin-left: auto; padding-left: 12px; }
.sx-list > button > .sx-ml { flex: 1; min-width: 0; }
.sx-list-ic > button { justify-content: flex-start; gap: 10px; padding: 6px 10px 6px 8px; }
.sx-mi { flex: none; width: 18px; height: 18px; display: grid; place-items: center; color: var(--muted, #667); font-style: normal; }
.sx-list > button:hover .sx-mi, .sx-list > button.on .sx-mi { color: var(--accent, #1f6feb); }
.sx-list > button.on { font-weight: 600; }
.sx-mi.fileXlsx { color: #107c41; }
.sx-mi.fileOds { color: #0f9d58; }
.sx-mi.filePdf { color: #d93025; }
.sx-mi.fileHtml { color: #e8710a; }
.sx-mi.fileJson { color: #7c3aed; }
.sx-mi.fileCsv, .sx-mi.fileTsv { color: #0b8043; }
.sx-saveas { min-width: 290px; }
.sx-saveas kbd { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.sx-fmt-pop { max-height: min(60vh, 460px); }
.sx-chart-pop > button { display: flex; }
.sx-suggest { padding: 4px; min-width: 260px; }
.sx-suggest > button, .sx-fn-list > button { flex-direction: column; align-items: flex-start; gap: 1px; white-space: normal; }
.sx-suggest span, .sx-fn-list span { font-size: 11.5px; color: var(--muted, #667); }
.sx-fn-pop { width: 380px; }
.sx-fn-list { max-height: 360px; overflow: auto; margin-top: 6px; }
.sx-menu-title { font-weight: 600; padding: 4px 6px 8px; }
.sx-field {
  display: block; width: 100%; box-sizing: border-box; margin: 0 0 6px; padding: 6px 8px;
  border: 1px solid var(--line, #ddd); border-radius: 6px; background: var(--bg, #fff); user-select: text;
}
.sx-field:focus { outline: 2px solid var(--accent-soft, #cfe0fc); border-color: var(--accent, #1f6feb); }
.sx-pop select.sx-field { padding: 5px 6px; }
.sx-check { display: flex; align-items: center; gap: 8px; padding: 4px 6px; cursor: pointer; }
.sx-pop-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 8px 4px 2px; }
.sx-pop-actions button {
  border: 1px solid var(--line, #ddd); background: var(--bg, #fff); border-radius: 8px; padding: 5px 12px; cursor: pointer;
}
.sx-pop-actions button.primary { background: var(--accent, #1f6feb); color: var(--accent-ink, #fff); border-color: transparent; }
.sx-pop-actions label { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.sx-hint { color: var(--muted, #667); font-size: 12px; padding: 6px; }
.sx-filter-pop { width: 260px; }
.sx-filter-search { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--line, #ddd); border-radius: 6px; margin-bottom: 4px; user-select: text; }
.sx-filter-list { max-height: 240px; overflow: auto; border: 1px solid var(--line, #ddd); border-radius: 6px; padding: 2px; }
.sx-find-pop, .sx-print-pop { width: 330px; }
.sx-find-said { color: var(--muted, #667); font-size: 12px; padding: 2px 6px; }
.sx-swatches { display: grid; grid-template-columns: repeat(6, 26px); gap: 5px; padding: 4px; }
.sx-swatches button { width: 26px; height: 26px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, 0.15); cursor: pointer; padding: 0; }
.sx-swatches button:hover { transform: scale(1.12); }

.sx-toast {
  position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); z-index: 50;
  background: #1f2937; color: #fff; padding: 9px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: calc(100% - 32px); animation: sx-in 0.2s ease-out;
}
@keyframes sx-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 720px) {
  .sx-top { padding: 4px 8px 0; gap: 6px; }
  .sx-name { width: 18ch; font-size: 15px !important; }
  .sx-menus { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .sx-menus button { flex: none; padding: 4px 8px; }
  .sx-toolbar { margin: 0 4px; border-radius: 10px; }
  .sx-bar { margin: 4px 4px; }
  .sx-namebox { width: 70px; }
  .sx-status { display: none; }
}

@media (max-width: 560px) {
  .sx-top { padding: 4px 6px 0; gap: 6px; }
  .sx-name { width: 14ch; }
  .sx-lang-word { display: none; }
  .sx-lang-short { display: inline; }
  .sx-langbtn { padding: 0 7px; gap: 4px; }
  .sx-font { width: 112px; }
  .sx-fmt { width: 100px; }
  .sx-bottom { gap: 4px; padding: 0 4px; }
  .sx-zoom #sx-zoom-val { min-width: 34px; }
}
@media (max-width: 360px) {
  .sx-saved { display: none; }
  .sx-name { width: 11ch; }
}
/* fingers get bigger targets */
@media (pointer: coarse) {
  .sx-tool { min-width: 36px; height: 36px; }
  .sx-toolbar select, .sx-ctxbar select { height: 32px; }
  .sx-menus button { padding: 7px 10px; }
  .sx-list > button { padding-top: 9px; padding-bottom: 9px; }
  .sx-handle { touch-action: none; }
  .sx-handle::after { content: ""; position: absolute; inset: -10px; }
  .sx-zoom button { width: 30px; height: 30px; }
  .sx-cell { -webkit-touch-callout: none; }
}
.sx-scroll, .sx-colhead, .sx-rowhead, .sx-tabs { -webkit-touch-callout: none; }

@media print {
  body.sheet-page header, #sheet-app { display: none !important; }
}
.sx-sink {
  position: absolute; left: 48px; top: 26px; width: 2px; height: 2px; padding: 0; border: 0; margin: 0;
  opacity: 0; resize: none; overflow: hidden; z-index: 0; pointer-events: none; font-size: 16px;
}

/* back to the start page */
.sx-home-btn {
  width: 32px; height: 32px; border: 1px solid var(--line, #ddd); border-radius: 8px; background: var(--bg, #fff);
  cursor: pointer; line-height: 1; color: #107c41; flex: none; display: inline-grid; place-items: center; padding: 0;
}
.sx-home-btn:hover { background: var(--bg-soft, #f4f7fb); }

/* the start page, in the same style as the PDF editor's */
.sx-start {
  position: absolute; inset: 0; z-index: 60; overflow: auto; background: var(--bg, #fff); color: var(--ink, #111);
  user-select: none;
}
.sx-start[hidden] { display: none; }
.sx-start-in { max-width: 980px; margin: 0 auto; padding: 18px 20px 56px; }
.sx-start-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.sx-start-top .brand { display: inline-flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 600; color: inherit; text-decoration: none; }
.sx-start-top .brand svg { width: 34px; height: 34px; }
.sx-start-top .controls { display: flex; gap: 8px; align-items: center; }
.sx-hero {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 20px; overflow: hidden;
  padding: 34px 30px; border-radius: 16px; margin-bottom: 24px;
  background: linear-gradient(110deg, #e7f6ec 0%, #eef6f1 55%, #e9f0fb 100%); border: 1px solid #d5eadd;
}
:root[data-theme="dark"] .sx-hero { background: linear-gradient(110deg, #0f2a1d 0%, #13261f 55%, #1d1b33 100%); border-color: #1f3a2b; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sx-hero { background: linear-gradient(110deg, #0f2a1d 0%, #13261f 55%, #1d1b33 100%); border-color: #1f3a2b; }
}
.sx-hero h1 { margin: 0 0 8px; font-size: 26px; font-weight: 500; }
.sx-hero p { margin: 0; color: var(--muted, #667); font-size: 14.5px; }
.sx-hero svg { flex: none; width: 230px; height: 120px; }
.sx-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.sx-action {
  display: flex; align-items: center; gap: 18px; padding: 22px 20px; border-radius: 14px; border: 1px solid var(--line, #ddd);
  background: var(--bg-soft, #f4f7fb); color: inherit; cursor: pointer; text-align: left; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.sx-action:hover { border-color: #16a34a; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(16, 124, 65, .12); }
.sx-action .ic {
  flex: none; width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center;
  background: var(--bg, #fff); border: 1px solid var(--line, #ddd); color: #16a34a;
}
.sx-action .ic svg { width: 28px; height: 28px; }
.sx-action b { display: block; font-size: 18px; font-weight: 500; margin-bottom: 3px; }
.sx-action small { color: var(--muted, #667); font-size: 13.5px; }
.sx-action .go { margin-left: auto; color: var(--muted, #667); font-size: 20px; }
.sx-drop {
  margin: 20px 0 8px; padding: 22px; border: 2px dashed var(--line, #cfd6de); border-radius: 12px; text-align: center;
  color: var(--muted, #667); cursor: pointer; font-size: 14px;
}
.sx-drop:hover, .sx-drop.on { border-color: #16a34a; color: #16a34a; }
.sx-start h2 { font-size: 14px; font-weight: 500; color: var(--muted, #667); margin: 26px 0 10px; }
.sx-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.sx-card {
  display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line, #ddd); border-radius: 12px;
  background: var(--bg-soft, #f4f7fb); color: inherit; cursor: pointer; text-align: left; transition: border-color .15s;
}
.sx-card:hover { border-color: #16a34a; }
.sx-card > span { font-size: 14px; }
.sx-mini { flex: none; width: 104px; display: grid; background: #fff; border: 1px solid #e3e7ec; border-radius: 6px; overflow: hidden; }
.sx-mini i { display: grid; grid-template-columns: repeat(4, 1fr); font-style: normal; }
.sx-mini b {
  font-weight: 400; font-size: 7.5px; color: #333; padding: 2px 3px; border-right: 1px solid #edf0f3; border-bottom: 1px solid #edf0f3;
  white-space: nowrap; overflow: hidden; text-overflow: clip; min-height: 14px; box-sizing: border-box;
}
.sx-mini b.h { background: #dbe8fb; font-weight: 700; }
.sx-recent { border: 1px solid var(--line, #ddd); border-radius: 12px; overflow: hidden; background: var(--bg-soft, #f4f7fb); }
.sx-recent-row {
  display: grid; grid-template-columns: 30px 1fr auto auto 30px; align-items: center; gap: 12px; padding: 11px 14px;
  border-bottom: 1px solid var(--line, #e5e7eb); cursor: pointer;
}
.sx-recent-row:last-child { border-bottom: 0; }
.sx-recent-row:hover, .sx-recent-row:focus { background: rgba(22, 163, 74, .09); outline: none; }
.sx-xl { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: #107c41; color: #fff; font-weight: 700; font-size: 13px; }
.sx-recent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-recent-meta, .sx-recent-when { color: var(--muted, #667); font-size: 12.5px; white-space: nowrap; }
.sx-recent-x { width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; color: var(--muted, #667); font-size: 16px; }
.sx-recent-x:hover { background: rgba(220, 38, 38, .14); color: #ef4444; }
.sx-empty { color: var(--muted, #667); margin: 0; font-size: 14px; }
@media (max-width: 720px) {
  .sx-start-in { padding: 12px 14px 40px; }
  .sx-hero { padding: 22px 18px; }
  .sx-hero h1 { font-size: 20px; }
  .sx-hero svg { display: none; }
  .sx-actions, .sx-cards { grid-template-columns: 1fr; gap: 12px; }
  .sx-recent-row { grid-template-columns: 30px 1fr auto 30px; }
  .sx-recent-meta { display: none; }
}

/* loading, as the PDF editor shows it */
.sx-loading {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg, #fff);
  color: var(--muted, #667); font-size: 15px; text-align: center; transition: opacity .3s ease;
}
.sx-loading.done { opacity: 0; pointer-events: none; }
.sx-spin {
  width: 30px; height: 30px; margin: 0 auto 14px; border-radius: 50%;
  border: 3px solid var(--line, #d0d5dd); border-top-color: #16a34a; animation: sx-spin .9s linear infinite;
}
@keyframes sx-spin { to { transform: rotate(360deg); } }

/* formula help: the function's arguments, with the one being typed picked out */
.sx-sig {
  position: absolute; z-index: 41; max-width: min(460px, calc(100% - 16px)); pointer-events: none;
  background: var(--bg, #fff); color: var(--ink, #111); border: 1px solid var(--line, #ddd); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.18); padding: 8px 11px; font-size: 12.5px; line-height: 1.5;
  animation: sx-fade 0.12s ease-out;
}
.sx-sig[hidden] { display: none; }
.sx-sig-line { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; color: var(--muted, #667); word-break: break-word; }
.sx-sig-line b { color: #107c41; font-weight: 700; }
.sx-sig-line span.on { color: var(--ink, #111); font-weight: 700; background: color-mix(in srgb, #107c41 16%, transparent); border-radius: 4px; padding: 0 3px; }
.sx-sig-arg { margin-top: 4px; }
.sx-sig-arg b { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; }
.sx-sig-arg i { color: var(--muted, #667); font-style: normal; font-size: 11px; border: 1px solid var(--line, #ddd); border-radius: 999px; padding: 0 6px; }
.sx-sig-over { color: #b42318; }
.sx-sig-fn { margin-top: 2px; color: var(--muted, #667); font-size: 11.5px; }
@keyframes sx-fade { from { opacity: 0; transform: translateY(-3px); } }

/* "did you mean …?" beside a cell */
.sx-fix-pop { width: 330px; padding: 12px 12px 8px; user-select: text; animation: sx-fade 0.16s ease-out; border-color: color-mix(in srgb, #f59e0b 45%, var(--line, #ddd)); }
.sx-fix-head { display: flex; gap: 10px; align-items: flex-start; }
.sx-fix-ic {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: color-mix(in srgb, #f59e0b 18%, transparent); color: #b45309; font-size: 15px;
}
.sx-fix-q { margin-top: 2px; }
.sx-fix-pop code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; padding: 1px 6px; border-radius: 5px;
  background: color-mix(in srgb, #107c41 12%, transparent); color: var(--ink, #111); word-break: break-all;
}
.sx-fix-was code { background: color-mix(in srgb, #b42318 9%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, #b42318 60%, transparent); }
.sx-fix-notes { margin: 8px 0 0 38px; padding: 0; list-style: none; font-size: 12px; color: var(--muted, #667); display: grid; gap: 2px; }
.sx-fix-notes li::before { content: "✓ "; color: #107c41; font-weight: 700; }
.sx-fix-was { margin: 6px 0 0 38px; font-size: 12px; color: var(--muted, #667); }
.sx-fix-pop .sx-pop-actions button.primary { background: #107c41; color: #fff; }
.sx-fix-pop .sx-pop-actions button:focus-visible { outline: 2px solid color-mix(in srgb, #107c41 55%, transparent); outline-offset: 2px; }
:root[data-theme="dark"] .sx-fix-ic { color: #fbbf24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sx-fix-ic { color: #fbbf24; } }

/* renaming a sheet right on its tab */
.sx-tab-input {
  flex: none; height: 26px; box-sizing: border-box; padding: 0 10px; margin: 0 2px; font: inherit; font-weight: 600;
  color: var(--ink, #111); background: var(--bg, #fff); border: 1.5px solid var(--accent, #1f6feb); border-radius: 6px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #1f6feb) 18%, transparent); outline: none;
}
.sx-tab-input.bad { border-color: #d92d20; box-shadow: 0 0 0 3px color-mix(in srgb, #d92d20 18%, transparent); }
.sx-tab-note {
  position: absolute; z-index: 45; max-width: 280px; padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4;
  background: #b42318; color: #fff; box-shadow: 0 8px 20px rgba(16, 24, 40, 0.25); animation: sx-fade 0.12s ease-out;
}
.sx-tab-note::after { content: ""; position: absolute; left: 16px; bottom: -5px; width: 10px; height: 10px; background: inherit; transform: rotate(45deg); }
.sx-tab-note[hidden] { display: none; }
.shake { animation: sx-shake 0.3s ease; }
@keyframes sx-shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

/* the app's own dialog, in place of the browser's prompt and confirm */
.sx-dialog-back {
  position: absolute; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(15, 20, 27, 0.38); backdrop-filter: blur(2px); animation: sx-back 0.15s ease-out;
}
.sx-dialog-back.closing { opacity: 0; transition: opacity 0.12s; }
@keyframes sx-back { from { opacity: 0; } }
.sx-dialog {
  width: min(400px, 100%); box-sizing: border-box; background: var(--bg, #fff); color: var(--ink, #111);
  border: 1px solid var(--line, #ddd); border-radius: 14px; padding: 18px 18px 14px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.3); animation: sx-pop-in 0.18s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes sx-pop-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
.sx-dialog h3 { margin: 0 0 6px; font-size: 17px; }
.sx-dialog-text { margin: 0 0 10px; color: var(--muted, #667); font-size: 14px; }
.sx-dialog-label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.sx-dialog .sx-field { margin: 0; padding: 8px 10px; font-size: 14px; color: var(--ink, #111); }
.sx-dialog-hint { font-size: 12px; color: var(--muted, #667); margin-top: 4px; }
.sx-dialog-msg { margin-top: 10px; font-size: 13px; color: #b42318; background: color-mix(in srgb, #b42318 9%, transparent); padding: 6px 10px; border-radius: 8px; }
.sx-dialog-msg[hidden] { display: none; }
.sx-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.sx-dialog-actions button {
  min-height: 36px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line, #ddd);
  background: var(--bg, #fff); color: var(--ink, #111); font: inherit; font-weight: 600; cursor: pointer;
}
.sx-dialog-actions button:hover { background: var(--bg-soft, #f4f7fb); }
.sx-dialog-actions button.primary { background: #107c41; border-color: #107c41; color: #fff; }
.sx-dialog-actions button.primary:hover { filter: brightness(1.08); background: #107c41; }
.sx-dialog.danger .sx-dialog-actions button.primary { background: #d92d20; border-color: #d92d20; }
.sx-dialog-actions button:focus-visible { outline: 2px solid var(--accent, #1f6feb); outline-offset: 2px; }
:root[data-theme="dark"] .sx-sig-over, :root[data-theme="dark"] .sx-dialog-msg { color: #ff8a80; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sx-sig-over, :root:not([data-theme="light"]) .sx-dialog-msg { color: #ff8a80; } }

/* quick save and print on the top bar */
.sx-savegroup { display: inline-flex; flex: none; }
.sx-savebtn { background: #107c41; border-color: #107c41; color: #fff; font-weight: 600; font-size: 13px !important; }
.sx-savebtn:hover { background: #0b6435; border-color: #0b6435; }
.sx-savegroup .sx-savebtn:first-child { border-radius: 8px 0 0 8px; }
.sx-savegroup .sx-savecaret { border-radius: 0 8px 8px 0; min-width: 24px; padding: 0 5px; border-left-color: rgba(255, 255, 255, .35); }
.sx-printbtn { font-size: 13px !important; }
@media (max-width: 720px) { .sx-tb-lbl { display: none; } }
