* {
  box-sizing: border-box;
}

:root {
  --compact-header-screen-font: 13.5px;
  --brand-header-height: calc(56px + env(safe-area-inset-top));
  --mobile-bottom-height: calc(42px + env(safe-area-inset-bottom));
}

html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #050713;
  color: #111111;
  font-family: Arial, Helvetica, sans-serif;
}

.workbook-shell {
  position: fixed;
  inset: 0;
  width: min(100vw, 480px);
  height: 100%;
  margin: auto;
  overflow: hidden;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.55);
}

body.capture-mode .workbook-shell {
  width: 100vw;
  max-width: none;
  border: 0;
  box-shadow: none;
}

body.capture-mode .sheet-viewport {
  top: 0;
  bottom: 0;
}

body.capture-mode .brand-header,
body.capture-mode .mobile-tab-bar {
  display: none;
}

.brand-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 90;
  height: var(--brand-header-height);
  display: grid;
  grid-template-columns: minmax(64px, 1fr) minmax(0, 144px) minmax(64px, 1fr);
  align-items: center;
  gap: 8px;
  padding: env(safe-area-inset-top) 12px 0;
  color: #ffffff;
  background: #000000;
  border-radius: 0;
}

.header-button {
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #ffffff;
  font: 700 13.5px/1 Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
}

.header-button:first-child {
  justify-self: start;
  min-width: 64px;
}

.header-button:last-child {
  justify-self: end;
  min-width: 64px;
}

.header-button:hover,
.header-button:active {
  background: #151515;
}

.header-button:focus-visible {
  outline: 2px solid #d9ba7a;
  outline-offset: 1px;
}

.header-logo {
  position: relative;
  width: 100%;
  height: 48px;
  padding: 0;
  overflow: hidden;
}

.header-logo img {
  display: block;
  flex-shrink: 0;
  width: 112.5%;
  max-width: none;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

.login-notice {
  padding: 12px 0;
}

.mobile-header-icon,
.mobile-header-logo,
.mobile-header-view {
  display: none;
}

.login-notice h3 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.3;
}

.login-notice p {
  margin: 0;
  color: #c4cec7;
  font-size: 16px;
  line-height: 1.5;
}

.sheet-viewport {
  position: absolute;
  top: var(--brand-header-height);
  right: 0;
  bottom: var(--mobile-bottom-height);
  left: 0;
  height: auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
  scroll-behavior: auto;
  overflow-anchor: none;
  isolation: isolate;
  clip-path: inset(0);
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sheet-viewport::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.mobile-tab-bar {
  position: absolute;
  inset: auto 0 0;
  z-index: 90;
  height: var(--mobile-bottom-height);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  color: #ffffff;
  background: #000000;
  border-top: 0;
  border-radius: 0;
  box-shadow: none;
}

.mobile-tab {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 5px;
  color: #ffffff;
  background: #000000;
  cursor: pointer;
}

.mobile-tab > .nav-icon {
  position: relative;
  display: block;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  color: #ffffff;
}

.nav-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon-products .cart-grid {
  stroke-width: 4.5;
}

.nav-icon-products .cart-wheel,
.nav-icon-period .calendar-dots {
  fill: currentColor;
  stroke: none;
}

.nav-icon-settings svg {
  stroke-width: 1.2;
}

.nav-icon-view .view-rays {
  opacity: 0;
}

.nav-icon-view.expanded .view-rays {
  opacity: 1;
}

.mobile-tab small {
  color: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: var(--compact-header-screen-font);
  font-style: normal;
  font-weight: 700;
  font-synthesis: none;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mobile-tab.active {
  color: #ffffff;
  background: #000000;
  box-shadow: none;
}

.mobile-tab:active {
  background: #111111;
}

.sheet-viewport.mobile-view {
  overscroll-behavior-inline: none;
  overscroll-behavior-block: none;
  scroll-snap-type: none;
  cursor: grab;
  scrollbar-width: none;
}

.sheet-viewport.mobile-view:active {
  cursor: grabbing;
}

.sheet-grid {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-auto-flow: row;
  width: max-content;
  min-width: 100%;
  background: white;
}

.sheet-row {
  display: contents;
}

.sheet-cell {
  position: relative;
  display: flex;
  min-width: 0;
  padding: calc(1px * var(--sheet-scale)) calc(2px * var(--sheet-scale));
  line-height: 1.08;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  font-variant-numeric: tabular-nums;
}

.sheet-cell.frozen-cell {
  position: sticky;
  left: 0;
  z-index: 3;
}

.sheet-cell.name-column {
  box-shadow: none;
}

.sheet-cell.name-column.frozen-cell {
  left: calc(var(--image-column-width) * var(--sheet-scale));
}

.sheet-cell.name-column .cell-value {
  text-overflow: ellipsis;
}

.sheet-cell.image-column {
  padding-left: 0;
  padding-right: 0;
}

.sheet-cell.image-column.has-product-image {
  padding: calc(2px * var(--sheet-scale)) !important;
  align-items: center !important;
  justify-content: center !important;
  background: #000000 !important;
}

.sheet-cell.positive-data-cell,
.sheet-cell.negative-data-cell {
  border: calc(1.5px * var(--sheet-scale)) solid #ffffff;
  /* Preserve the same space for text as the original thinner frame. */
  padding: calc(0.5px * var(--sheet-scale)) calc(1.5px * var(--sheet-scale));
  border-radius: calc(3px * var(--sheet-scale));
  background-clip: padding-box;
}

.sheet-cell.header-cell {
  position: sticky;
  top: 0;
  z-index: 6;
  border: 0;
  background: #000000 !important;
  box-shadow: none;
}

.sheet-cell.header-cell.frozen-cell {
  z-index: 8;
}

.sheet-cell.total-cell {
  position: sticky;
  top: calc(var(--header-height) * var(--sheet-scale));
  z-index: 5;
  border: 0;
  background: #000000;
  box-shadow: none;
}

.sheet-cell.total-cell.frozen-cell {
  z-index: 7;
}

/* Black cells join into one opaque surface. Only the outer shell is rounded. */
.sheet-grid .sheet-cell.black-sheet-cell {
  background: #000000 !important;
  border: 0;
  border-radius: 0;
}

.cell-value {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
}

.dated-header-value {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(1px * var(--sheet-scale));
  overflow: hidden;
  color: inherit;
  text-align: center;
  white-space: nowrap;
}

.live-header-value {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(2px * var(--sheet-scale));
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
}

.live-header-period,
.live-header-metric {
  max-width: 100%;
  overflow: hidden;
  font-size: calc(7px * var(--sheet-scale));
  font-weight: 800;
  line-height: 1;
}

.live-header-date {
  max-width: 100%;
  overflow: hidden;
  font-size: calc(5.8px * var(--sheet-scale));
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.025em;
}

.dated-header-period,
.dated-header-metric {
  max-width: 100%;
  overflow: hidden;
  font-size: calc(7px * var(--sheet-scale));
  font-weight: 800;
  line-height: 1;
  text-overflow: clip;
}

.dated-header-date {
  max-width: 100%;
  overflow: hidden;
  font-size: calc(5.8px * var(--sheet-scale));
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.025em;
  text-overflow: clip;
}

.sheet-grid.compact-headers .live-header-period,
.sheet-grid.compact-headers .live-header-date,
.sheet-grid.compact-headers .dated-header-period,
.sheet-grid.compact-headers .dated-header-date {
  display: none;
}

.sheet-grid.compact-headers .live-header-value,
.sheet-grid.compact-headers .dated-header-value {
  gap: 0;
}

/* Compact sheet typography is deliberately uniform across every visible cell. */
.sheet-grid.compact-headers .sheet-cell,
.sheet-grid.compact-headers .sheet-cell span {
  font-family: Arial, Helvetica, sans-serif !important;
  font-size: calc(9px * var(--sheet-scale)) !important;
  font-style: normal !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
  line-height: 1 !important;
}

.product-image {
  display: block;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
  width: 100%;
  height: 100%;
  border: calc(1px * var(--sheet-scale)) solid #000000;
  border-radius: calc(2.5px * var(--sheet-scale));
  object-fit: contain;
  object-position: center;
  background: #ffffff;
}

.menu-trigger {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: calc(34px * var(--sheet-scale));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(6px * var(--sheet-scale));
  padding: 0 calc(8px * var(--sheet-scale));
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: calc(10px * var(--sheet-scale));
  overflow: hidden;
  color: #ffffff;
  background: linear-gradient(135deg, #1477ff 0%, #6957ff 52%, #d544f2 100%);
  box-shadow: 0 5px 15px rgba(57, 78, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-family: Arial, Helvetica, sans-serif;
  font-size: calc(11px * var(--sheet-scale));
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.menu-trigger::before {
  content: "";
  position: absolute;
  inset: -140% 40% -140% -80%;
  z-index: -1;
  transform: rotate(20deg) translateX(-110%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  animation: menu-shine 3.8s ease-in-out infinite;
}

.menu-trigger:hover {
  transform: translateY(-1px) scale(1.025);
  filter: saturate(1.15);
  box-shadow: 0 8px 20px rgba(57, 78, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.menu-trigger:active {
  transform: translateY(1px) scale(0.98);
}

.menu-trigger:focus-visible,
.mobile-tab:focus-visible,
.menu-back:focus-visible,
.menu-close:focus-visible,
.category-option:focus-visible,
.period-option:focus-visible,
.layout-option:focus-visible,
.zoom-step-button:focus-visible,
.zoom-preset:focus-visible,
.view-mode-button:focus-visible,
.apply-view-button:focus-visible {
  outline: 3px solid #ffd84d;
  outline-offset: 2px;
}

.menu-trigger-icon {
  font-size: calc(13px * var(--sheet-scale));
  line-height: 1;
}

.menu-backdrop {
  position: absolute;
  inset: 0;
  top: var(--brand-header-height);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  background: rgba(4, 8, 20, 0.58);
  backdrop-filter: blur(6px);
  animation: backdrop-in 180ms ease-out both;
}

.menu-backdrop[hidden] {
  display: none !important;
}

.period-menu {
  width: calc(100% - 16px);
  height: auto;
  max-height: min(80dvh, 680px);
  margin: 8px 8px 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  color: #f8faff;
  background: #111814;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
  animation: menu-slide-in 260ms cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.view-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 16px;
}

.view-mode-button {
  min-height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  color: #dce4ff;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.view-mode-button:hover {
  transform: translateY(-1px);
  border-color: rgba(132, 164, 255, 0.55);
  background: rgba(91, 118, 255, 0.14);
}

.view-mode-button.selected {
  border-color: #7fa4ff;
  color: #ffffff;
  background: linear-gradient(135deg, rgba(30, 114, 255, 0.42), rgba(132, 72, 238, 0.38));
  box-shadow: 0 9px 24px rgba(28, 72, 210, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.view-mode-button span {
  font: 900 12px/1 Arial, Helvetica, sans-serif;
  letter-spacing: 0.08em;
}

.view-mode-button small {
  color: #aeb9d8;
  font: 700 7px/1.25 Arial, Helvetica, sans-serif;
  letter-spacing: 0.025em;
  text-align: center;
}

.view-mode-button.selected small {
  color: #e8edff;
}

.period-menu-header {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  min-height: 58px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #101713;
  backdrop-filter: blur(18px);
}

.menu-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-menu-body {
  min-height: 0;
  flex: 0 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 12px 14px 14px;
}

.period-menu h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.menu-brand {
  display: block;
  margin-bottom: 4px;
  color: #d9ba7a;
  font: 800 8px/1 Arial, Helvetica, sans-serif;
  letter-spacing: 0.16em;
}

.menu-section {
  display: contents;
}

.menu-section[hidden],
[data-menu-section][hidden] {
  display: none !important;
}

.settings-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.settings-shortcuts button {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(92, 145, 112, 0.38);
  border-radius: 12px;
  color: #f7f9ff;
  background: #18231d;
  text-align: left;
  cursor: pointer;
}

.settings-shortcuts span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-shortcuts small {
  display: block;
  margin-bottom: 2px;
  color: #8793ad;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.settings-shortcuts b {
  color: #70c18f;
  font-size: 8px;
  text-transform: uppercase;
}

.menu-back,
.menu-close {
  position: relative;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.menu-back {
  display: block;
  font-size: 0;
}

.menu-back::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transform: translate(-42%, -50%);
}

.menu-back::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 41%;
  width: 7px;
  height: 7px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.menu-back[hidden] {
  display: none !important;
}

.menu-close::before,
.menu-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
}

.menu-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.menu-close::after { transform: translate(-50%, -50%) rotate(-45deg); }

.menu-close:hover {
  transform: rotate(6deg) scale(1.05);
  background: rgba(255, 255, 255, 0.15);
}

.menu-back:focus-visible,
.menu-close:focus-visible {
  outline: 2px solid #70c18f;
  outline-offset: 2px;
}

.period-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.category-option {
  position: relative;
  min-height: 58px;
  display: grid;
  grid-template-columns: 12px 1fr;
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 10px;
  row-gap: 4px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #f7f8ff;
  text-align: left;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.category-option:hover {
  transform: translateY(-2px);
  border-color: rgba(121, 156, 255, 0.75);
  background: rgba(76, 103, 255, 0.17);
}

.category-option.selected {
  border-color: #5db581;
  background: #1b3828;
  box-shadow: 0 8px 20px rgba(6, 39, 20, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.category-option i {
  width: 10px;
  height: 10px;
  align-self: center;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.07), 0 0 14px currentColor;
}

.category-option span {
  align-self: center;
  font-size: 12px;
  font-weight: 800;
}

.category-option small {
  grid-column: 2;
  color: #aeb7cc;
  font-size: 8px;
  line-height: 1.25;
}

.period-option {
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #f7f8ff;
  text-align: left;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.period-option:hover {
  transform: translateY(-2px);
  border-color: rgba(121, 156, 255, 0.75);
  background: rgba(76, 103, 255, 0.17);
}

.period-option.selected {
  border-color: #5db581;
  background: #1b3828;
  box-shadow: 0 8px 20px rgba(6, 39, 20, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.period-option span {
  font-size: 12px;
  font-weight: 800;
}

.period-option small {
  color: #aeb7cc;
  font-size: 8px;
  line-height: 1.25;
}

.all-periods-option {
  width: 100%;
  min-height: 82px;
  margin-bottom: 16px;
  color: #151006;
  border-color: rgba(255, 228, 106, 0.9);
  background: linear-gradient(135deg, #ffe66c 0%, #ffbd3c 55%, #ff8f3d 100%);
  box-shadow: 0 12px 28px rgba(255, 169, 43, 0.22);
}

.all-periods-option small {
  color: rgba(38, 27, 7, 0.68);
}

.all-periods-option:hover,
.all-periods-option.selected {
  border-color: #fff0a7;
  background: linear-gradient(135deg, #fff07c 0%, #ffc747 55%, #ff9849 100%);
  box-shadow: 0 14px 30px rgba(255, 169, 43, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.menu-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 3px 0 8px;
  color: #77829b;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.menu-divider::before,
.menu-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
}

.layout-divider {
  margin-top: 12px;
}

.column-order-settings[hidden] {
  display: none !important;
}

.zoom-divider {
  margin-top: 8px;
}

.zoom-panel {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(68, 128, 255, 0.18), transparent 65%),
    rgba(255, 255, 255, 0.045);
}

.zoom-stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
}

.zoom-step-button {
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(143, 180, 255, 0.48);
  border-radius: 14px;
  color: #ffffff;
  background: linear-gradient(145deg, rgba(48, 113, 255, 0.45), rgba(111, 76, 224, 0.32));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  font: 400 24px/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.zoom-step-button:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.025);
  border-color: #a9c7ff;
  background: linear-gradient(145deg, rgba(62, 128, 255, 0.62), rgba(128, 84, 240, 0.44));
}

.zoom-step-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.zoom-step-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.zoom-value {
  min-width: 0;
  color: #ffffff;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -0.04em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.zoom-presets {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.zoom-preset {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #b9c5dd;
  background: rgba(255, 255, 255, 0.055);
  font: 800 10px/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
}

.zoom-preset:hover {
  transform: translateY(-1px);
  color: #ffffff;
  border-color: rgba(141, 179, 255, 0.7);
}

.zoom-preset.selected {
  color: #ffffff;
  border-color: #4fae78;
  background: #217346;
}

.label-type-divider {
  margin-top: 12px;
}

.label-type-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.label-type-option {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #f7f8ff;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.label-type-option:hover {
  transform: translateY(-1px);
  border-color: rgba(121, 156, 255, 0.75);
  background: rgba(76, 103, 255, 0.17);
}

.label-type-option.selected {
  border-color: #5db581;
  background: #1b3828;
  box-shadow: 0 8px 20px rgba(6, 39, 20, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.label-type-option span {
  font-size: 12px;
  font-weight: 800;
}

.layout-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.layout-option {
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #f7f8ff;
  text-align: left;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.layout-option:hover {
  transform: translateY(-2px);
  border-color: rgba(121, 156, 255, 0.75);
  background: rgba(76, 103, 255, 0.17);
}

.layout-option.selected {
  border-color: #5db581;
  background: #1b3828;
  box-shadow: 0 8px 20px rgba(6, 39, 20, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.layout-option span {
  font-size: 12px;
  font-weight: 800;
}

.layout-option small {
  color: #aeb7cc;
  font-size: 8px;
  line-height: 1.3;
}

.current-period {
  margin: 0;
  padding: 10px 14px 0;
  color: #98a3ba;
  font-size: 9px;
  line-height: 1.35;
  text-align: center;
}

.menu-footer {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #101713;
}

.apply-view-button {
  position: relative;
  z-index: 4;
  width: calc(100% - 28px);
  flex: 0 0 auto;
  min-height: 42px;
  margin: 8px 14px 14px;
  border: 1px solid #5db581;
  border-radius: 14px;
  color: #ffffff;
  background: #217346;
  box-shadow: 0 8px 20px rgba(6, 39, 20, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  font: 800 12px/1 Arial, Helvetica, sans-serif;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.apply-view-button:hover {
  transform: translateY(-1px);
  border-color: #7bc99a;
  background: #2a8254;
}

.apply-view-button:active {
  transform: translateY(1px);
}

@keyframes menu-shine {
  0%, 60% { transform: rotate(20deg) translateX(-110%); }
  82%, 100% { transform: rotate(20deg) translateX(360%); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes menu-slide-in {
  from { opacity: 0; transform: translateY(-32px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 520px) {
  .period-menu {
    width: calc(100% - 12px);
    height: auto;
    max-height: min(80dvh, 680px);
    margin: 6px 6px 0;
    border-radius: 18px;
  }
  .period-menu-header { padding-inline: 12px; }
  .period-menu-body { padding-inline: 12px; }
  .current-period { padding-inline: 12px; }
  .apply-view-button { width: calc(100% - 24px); margin-inline: 12px; }
  .view-mode-switch { gap: 6px; }
  .view-mode-button { min-height: 62px; }
}

@media (min-width: 600px) {
  .workbook-shell {
    border-inline: 1px solid rgba(255, 255, 255, 0.12);
  }
}

@media (min-width: 900px) {
  :root {
    --brand-header-height: 64px;
    --desktop-bottom-height: 64px;
  }

  html,
  body {
    background:
      radial-gradient(circle at 15% 0%, rgba(33, 115, 70, 0.18), transparent 32%),
      radial-gradient(circle at 85% 100%, rgba(47, 96, 165, 0.14), transparent 34%),
      #070b0d;
  }

  .workbook-shell {
    top: 24px;
    right: 24px;
    bottom: auto;
    left: 24px;
    width: auto;
    max-width: 1800px;
    height: calc(100dvh - 48px);
    margin-inline: auto;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0;
    background: #eef1f3;
    box-shadow: 0 32px 90px rgba(0, 0, 0, 0.52);
  }

  .brand-header {
    height: var(--brand-header-height);
    padding: 0 24px;
    border-bottom: 0;
    background: #000000;
    grid-template-columns: minmax(80px, 1fr) 164px minmax(80px, 1fr);
  }

  .header-button {
    font-size: 14px;
    min-width: 80px;
  }

  .header-logo {
    height: 56px;
  }

  .mobile-tab-bar {
    inset: auto 0 0;
    height: var(--desktop-bottom-height);
    grid-template-columns: repeat(4, minmax(120px, 160px));
    justify-content: center;
    gap: 6px;
    padding: 8px 24px;
    border-top: 0;
    background: #000000;
  }

  .mobile-tab {
    min-height: 48px;
    flex-direction: row;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
  }

  .mobile-tab:hover,
  .mobile-tab:focus-visible {
    border-color: rgba(116, 197, 147, 0.28);
    background: rgba(91, 174, 123, 0.13);
  }

  .mobile-tab:active {
    transform: translateY(1px);
    background: rgba(91, 174, 123, 0.2);
  }

  .mobile-tab > .nav-icon {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
  }

  .mobile-tab small {
    font-size: 12px;
    letter-spacing: 0.055em;
  }

  .sheet-viewport {
    top: var(--brand-header-height);
    bottom: var(--desktop-bottom-height);
    scrollbar-width: thin;
    scrollbar-color: #6e7c76 #d7ddda;
    background:
      linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)),
      #eef1f3;
  }

  .sheet-viewport::-webkit-scrollbar {
    display: block;
    width: 11px;
    height: 11px;
  }

  .sheet-viewport::-webkit-scrollbar-track {
    background: #d7ddda;
  }

  .sheet-viewport::-webkit-scrollbar-thumb {
    border: 3px solid #d7ddda;
    border-radius: 999px;
    background: #68756f;
  }

  .sheet-grid {
    min-width: 100%;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  }

  .sheet-cell {
    padding-inline: calc(4px * var(--sheet-scale));
  }

  .sheet-cell.positive-data-cell,
  .sheet-cell.negative-data-cell {
    padding-inline: calc(3.5px * var(--sheet-scale));
  }

  .sheet-grid.compact-headers .sheet-cell,
  .sheet-grid.compact-headers .sheet-cell span {
    font-size: calc(12px * var(--sheet-scale)) !important;
  }

  .live-header-period,
  .live-header-metric,
  .dated-header-period,
  .dated-header-metric {
    font-size: calc(11px * var(--sheet-scale));
  }

  .live-header-date,
  .dated-header-date {
    font-size: calc(9px * var(--sheet-scale));
  }

  .menu-backdrop {
    top: var(--brand-header-height);
    bottom: var(--desktop-bottom-height);
    align-items: center;
    padding: 24px 32px;
    background: rgba(3, 8, 6, 0.56);
  }

  .period-menu {
    width: min(760px, calc(100% - 64px));
    max-height: min(760px, calc(100dvh - 140px));
    margin: 0;
    border-radius: 20px;
  }

  .period-menu-header {
    min-height: 66px;
    padding: 14px 20px;
  }

  .period-menu-body {
    padding: 18px 20px 20px;
  }

  .period-menu h2 {
    font-size: 24px;
  }

  .category-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .period-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-option,
  .period-option,
  .layout-option {
    min-height: 68px;
  }

  .menu-footer {
    padding-inline: 6px;
  }

  body.capture-mode .workbook-shell {
    top: 0;
    right: 0;
    left: 0;
    height: 100%;
    border-radius: 0;
  }

  body.capture-mode .sheet-viewport {
    top: 0;
    bottom: 0;
  }
}

/* Approved mobile option 8: navigation and compact sheet rows share one height. */
@media (max-width: 899px) {
  :root {
    --mobile-line-height: 30px;
    --brand-header-height: calc(var(--mobile-line-height) + env(safe-area-inset-top));
    --mobile-bottom-height: env(safe-area-inset-bottom);
  }

  /* One fixed surface, not three nested fixed viewport roots. */
  html, body { position: static; background: #000000; }

  .workbook-shell {
    height: 100%;
    height: 100dvh;
    height: var(--app-viewport-height, 100dvh);
    top: var(--app-viewport-top, 0px);
    left: calc(var(--app-viewport-left, 0px) + max(0px, (var(--app-viewport-width, 100vw) - 480px) / 2));
    right: auto;
    width: min(var(--app-viewport-width, 100vw), 480px);
    bottom: auto;
    margin: 0;
    background: #000000;
  }
  .mobile-tab-bar { display: none; }

  .brand-header {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 0;
    padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
    border-radius: 15px;
  }

  .brand-header .header-button {
    position: relative;
    justify-self: center;
    width: 44px;
    min-width: 44px;
    height: var(--mobile-line-height);
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    overflow: visible;
  }

  /* No expanded hit area over the spreadsheet below the shorter top bar. */
  .brand-header .header-button::after { display: none; }

  .sheet-grid { --mobile-grid-header-height: var(--mobile-line-height); }
  .sheet-grid:not(.compact-headers) {
    --mobile-grid-header-height: max(var(--mobile-line-height), calc(40px * var(--sheet-scale)));
  }
  .sheet-grid .sheet-cell { height: var(--mobile-line-height) !important; }
  .sheet-grid .header-cell { height: var(--mobile-grid-header-height) !important; }
  .sheet-grid .total-cell { top: var(--mobile-grid-header-height); }

  .brand-header .header-button:active { opacity: 0.7; }
  .brand-header .desktop-header-content { display: none; }
  .brand-header .header-logo { width: max-content; max-width: 100%; }
  .mobile-header-icon { display: block; width: 16px; height: 16px; }
  .header-person { stroke: none; }
  .header-person path { clip-path: inset(0 round 3px) fill-box; }
  .mobile-header-logo { display: flex; align-items: center; gap: 6px; }

  .header-word {
    position: relative;
    display: block;
    flex-shrink: 0;
    width: 62.8px;
    height: 10px;
    overflow: hidden;
  }

  .header-logo .header-word img {
    position: absolute;
    display: block;
    width: 125.45%;
    max-width: none;
    height: auto;
    left: -12.4%;
    pointer-events: none;
    filter: grayscale(1) brightness(1.7) contrast(4);
  }

  .header-word-dolce img { top: -93.78%; }
  .header-word-agent img { top: -212.45%; }
  .mobile-header-view { display: block; }
  .mobile-header-view .layout-option { min-height: 58px; }

  /* Full-screen monochrome menu. Only the middle content area scrolls. */
  .menu-backdrop {
    top: var(--brand-header-height);
    bottom: 0;
    align-items: stretch;
    overflow: hidden;
    overscroll-behavior: none;
    background: #000000;
    backdrop-filter: none;
    animation: none;
  }

  .menu-backdrop .period-menu {
    width: 100%;
    height: 100%;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    color: #ffffff;
    background: #000000;
    box-shadow: none;
    animation: none;
  }

  .menu-backdrop .period-menu-header,
  .menu-backdrop .menu-footer {
    border: 0;
    background: #000000;
    backdrop-filter: none;
  }

  .menu-backdrop .period-menu-header {
    padding: 8px 16px 12px;
    min-height: 64px;
  }
  .menu-backdrop .period-menu-header > div:first-child {
    position: absolute;
    inset-inline: 68px;
    text-align: center;
    pointer-events: none;
  }
  .menu-backdrop .menu-header-actions { width: 100%; }
  .menu-backdrop .menu-close { margin-left: auto; }
  .menu-backdrop .menu-brand { display: none; }
  .menu-backdrop .period-menu h2 { font-size: 24px; }
  .menu-backdrop .period-menu-body {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    max-width: 480px;
    align-self: center;
    padding: 4px 16px 20px;
    text-align: center;
    overscroll-behavior: none;
    overflow-anchor: none;
    scroll-behavior: auto;
    scroll-padding-block: 16px;
    touch-action: pan-y;
    scrollbar-width: none;
  }
  .menu-backdrop .period-menu-body::-webkit-scrollbar { display: none; }
  .menu-backdrop .menu-footer { padding-bottom: env(safe-area-inset-bottom); }

  .menu-backdrop .period-menu button,
  .menu-backdrop .period-menu button:hover,
  .menu-backdrop .period-menu button:active {
    min-height: 44px;
    border: 1px solid #ffffff;
    border-radius: 8px;
    color: #ffffff;
    background: #000000;
    box-shadow: none;
    text-shadow: none;
    transform: none;
    transition: none;
  }

  .menu-backdrop .period-menu button[aria-pressed="true"],
  .menu-backdrop .period-menu .apply-view-button {
    color: #000000;
    background: #ffffff;
  }

  .menu-backdrop .period-menu button :is(span, small, b) { color: inherit; }
  .menu-backdrop .period-menu button:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
  }
  .menu-backdrop .period-menu button:disabled { opacity: 1; border-style: dashed; }
  .menu-backdrop .period-menu :is(.menu-back, .menu-close) {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
    border: 0;
  }

  .menu-backdrop .settings-shortcuts {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    margin-bottom: 20px;
  }
  .menu-backdrop .settings-shortcuts button {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
    gap: 8px;
    padding: 12px;
  }
  .menu-backdrop .settings-shortcuts button > span { width: 100%; }
  .menu-backdrop .settings-shortcuts span { font-size: 16px; }
  .menu-backdrop .settings-shortcuts :is(small, b) { font-size: 12px; }
  .menu-backdrop .menu-divider {
    margin: 20px 0 10px;
    color: #ffffff;
    font-size: 12px;
    letter-spacing: 0.06em;
    justify-content: center;
  }
  .menu-backdrop .menu-divider::before,
  .menu-backdrop .menu-divider::after { display: none; }
  .menu-backdrop .zoom-panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #000000;
  }
  .menu-backdrop .zoom-value { color: #ffffff; font-size: 24px; }
  .menu-backdrop .zoom-preset { font-size: 14px; }
  .menu-backdrop .period-menu :is(.category-option, .period-option, .layout-option) {
    min-height: 64px;
    padding: 12px;
    align-items: center;
    justify-items: center;
    text-align: center;
  }
  .menu-backdrop :is(.category-option, .period-option, .layout-option, .label-type-option) span {
    font-size: 14px;
  }
  .menu-backdrop :is(.category-option, .period-option, .layout-option) small {
    font-size: 12px;
    overflow-wrap: anywhere;
  }
  .menu-backdrop .category-option { grid-template-columns: minmax(0, 1fr); }
  .menu-backdrop .category-option small { grid-column: 1; }
  .menu-backdrop .category-option i { display: none; }
  .menu-backdrop .current-period { color: #ffffff; font-size: 12px; }
  .menu-backdrop .period-menu .apply-view-button {
    min-height: 48px;
    width: calc(100% - 32px);
    margin: 10px 16px 12px;
    font-size: 14px;
  }
  .menu-backdrop .login-notice,
  .menu-backdrop .login-notice p { color: #ffffff; background: #000000; }
}

@media (prefers-reduced-motion: reduce) {
  .menu-trigger::before,
  .menu-backdrop,
  .period-menu { animation: none; }
  .menu-trigger,
  .menu-close,
  .category-option,
  .period-option,
  .layout-option,
  .zoom-step-button,
  .zoom-preset,
  .view-mode-button,
  .apply-view-button { transition: none; }
}

@media print {
  html,
  body,
  .workbook-shell,
  .sheet-viewport {
    width: auto;
    height: auto;
    overflow: visible;
  }

  .sheet-grid {
    grid-template-columns: var(--print-columns);
  }
}
