/*
 * Spreadsheet application styles — Arrival Sheets.
 * Uses suite design tokens from @docx-engine/common/styles.
 * Canvas direction: warm neutrals + arrival green.
 */

:root {
  /* Suite tokens (inline for standalone; apps/common/design-tokens.css is canonical) */
  --suite-primary: #0a8c7a;
  --suite-primary-hover: #077a6a;
  --suite-primary-light: #d1faf0;
  --suite-accent: #0a8c7a;
  --suite-gray-50: #faf8f6;
  --suite-gray-100: #f4f2ef;
  --suite-gray-200: #e8e5e0;
  --suite-gray-300: #d4d0ca;
  --suite-gray-400: #a6a099;
  --suite-gray-500: #706b64;
  --suite-gray-600: #403c38;
  --suite-gray-700: #2a2725;
  --suite-gray-800: #2a2725;
  --suite-bg: #fff;
  --suite-bg-secondary: var(--suite-gray-50);
  --suite-border: var(--suite-gray-200);
  --suite-border-strong: var(--suite-gray-300);
  --suite-text: var(--suite-gray-700);
  --suite-text-secondary: var(--suite-gray-500);
  --suite-font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --suite-font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", monospace;
  --suite-shadow-sm: 0 1px 2px rgba(42, 39, 37, 0.06);
  --suite-shadow-md: 0 2px 8px rgba(42, 39, 37, 0.08);
  --suite-radius-sm: 2px;
  --suite-radius-md: 4px;
  --suite-radius-lg: 8px;
  --suite-transition-fast: 100ms ease;

  /* Sheet-specific */
  --sheet-grid-border: #d4d0ca;
  --sheet-header-bg: var(--suite-gray-50);
  --sheet-header-text: var(--suite-gray-600);
  --sheet-active-header: var(--suite-primary-light);
  --sheet-select-bg: rgba(10, 140, 122, 0.08);
  --sheet-select-border: var(--suite-primary);
  --sheet-cell-height: 24px;
  --sheet-cell-padding: 0 6px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body, #root {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--suite-font-sans);
  font-size: 13px;
  color: var(--suite-text);
  background: var(--suite-bg);
}

/* ---------- Arrival logo ---------- */

.arrival-logo {
  font-family: var(--suite-font-sans);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  user-select: none;
}
.arrival-logo .ar { color: var(--suite-gray-700); }
.arrival-logo .rival { color: var(--suite-primary); }
.arrival-logo-sm { font-size: 22px; }

/* ---------- Loading ---------- */

.sheet-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  background: var(--suite-gray-50);
}
.sheet-loading-sub {
  font-size: 15px;
  font-weight: 400;
  color: var(--suite-text-secondary);
  letter-spacing: 0.08em;
  margin-top: -4px;
}
.sheet-loading-spinner {
  width: 24px;
  height: 24px;
  margin-top: 16px;
  border: 2.5px solid var(--suite-gray-200);
  border-top-color: var(--suite-primary);
  border-radius: 50%;
  animation: sheet-spin 0.7s linear infinite;
}
@keyframes sheet-spin {
  to { transform: rotate(360deg); }
}

/* ---------- Login ---------- */

.sheet-login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--suite-gray-50);
  position: relative;
  overflow: hidden;
}
.sheet-login-grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--suite-gray-200) 1px, transparent 1px),
    linear-gradient(90deg, var(--suite-gray-200) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.45;
  mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, black 20%, transparent 70%);
}
.sheet-login-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 48px 56px;
  background: var(--suite-bg);
  border: 1px solid var(--suite-gray-300);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(42, 39, 37, 0.08), 0 1px 3px rgba(42, 39, 37, 0.06);
}
.sheet-login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.sheet-login-app-name {
  font-size: 15px;
  font-weight: 400;
  color: var(--suite-text-secondary);
  letter-spacing: 0.08em;
}
.sheet-login-tagline {
  font-size: 14px;
  line-height: 1.6;
  color: var(--suite-text-secondary);
  text-align: center;
  max-width: 260px;
}
.sheet-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  border: none;
  border-radius: var(--suite-radius-lg);
  background: var(--suite-primary);
  color: #fff;
  font-family: var(--suite-font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(10, 140, 122, 0.25);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
  width: 100%;
  margin-top: 4px;
}
.sheet-login-btn:hover {
  background: var(--suite-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(10, 140, 122, 0.3);
}
.sheet-login-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(10, 140, 122, 0.2);
}
.sheet-login-trust {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.sheet-trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--suite-text-secondary);
}
.sheet-trust-badge svg { flex-shrink: 0; }

/* ---------- Doc list ---------- */

.sheet-doc-list {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--suite-gray-50);
}
.sheet-doc-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--suite-gray-200);
  background: var(--suite-bg);
  flex-shrink: 0;
}
.sheet-doc-list-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.sheet-doc-list-app {
  font-size: 15px;
  font-weight: 400;
  color: var(--suite-text-secondary);
  letter-spacing: 0.04em;
}
.sheet-doc-list-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sheet-doc-list-body {
  flex: 1;
  overflow-y: auto;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* New spreadsheet card */
.sheet-new-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  background: var(--suite-bg);
  border: 1.5px dashed var(--suite-gray-300);
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--suite-font-sans);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.sheet-new-card:hover {
  border-color: var(--suite-primary);
  box-shadow: 0 2px 12px rgba(10, 140, 122, 0.1);
  transform: translateY(-1px);
}
.sheet-new-card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--suite-primary-light);
  border-radius: 10px;
  color: var(--suite-primary);
}
.sheet-new-card-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--suite-text);
}

/* Doc section */
.sheet-doc-section {
  margin-top: 32px;
}
.sheet-doc-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--suite-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}
.sheet-doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

/* Doc card */
.sheet-doc-card {
  display: flex;
  flex-direction: column;
  background: var(--suite-bg);
  border: 1px solid var(--suite-gray-200);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 150ms ease, transform 150ms ease, border-color 150ms ease;
}
.sheet-doc-card:hover {
  border-color: var(--suite-gray-300);
  box-shadow: var(--suite-shadow-md);
  transform: translateY(-2px);
}
.sheet-doc-card-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  background: var(--suite-gray-50);
  border-bottom: 1px solid var(--suite-gray-200);
  color: var(--suite-gray-400);
}
.sheet-doc-card-info {
  padding: 12px 14px;
}
.sheet-doc-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--suite-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.sheet-doc-card-date {
  font-size: 11.5px;
  color: var(--suite-text-secondary);
}

/* Empty state */
.sheet-doc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 0 48px;
  text-align: center;
}
.sheet-doc-empty-icon {
  color: var(--suite-gray-300);
  margin-bottom: 4px;
}
.sheet-doc-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--suite-text);
}
.sheet-doc-empty-sub {
  font-size: 13px;
  color: var(--suite-text-secondary);
  max-width: 260px;
}

/* ---------- Button (suite) ---------- */

.suite-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 16px;
  border: 1px solid var(--suite-border-strong);
  border-radius: var(--suite-radius-md);
  background: var(--suite-bg);
  color: var(--suite-text);
  font-family: var(--suite-font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--suite-transition-fast);
  white-space: nowrap;
  user-select: none;
}
.suite-btn:hover { background: var(--suite-gray-100); }
.suite-btn-primary {
  background: var(--suite-primary);
  color: #fff;
  border-color: var(--suite-primary);
}
.suite-btn-primary:hover { background: var(--suite-primary-hover); }
.suite-btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------- App layout ---------- */

.sheet-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ---------- Top bar ---------- */

.sheet-top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  background: #fff;
  border-bottom: 1px solid var(--suite-border);
  font-size: 13px;
  min-height: 34px;
  flex-shrink: 0;
}
.sheet-top-bar .suite-btn {
  color: var(--suite-text-secondary);
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: var(--suite-radius-sm);
}
.sheet-top-bar .suite-btn:hover {
  background: var(--suite-gray-100);
  color: var(--suite-text);
}
.sheet-doc-name {
  font-weight: 500;
  font-size: 13px;
  color: var(--suite-text);
}
.sheet-title-editable {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 8px;
  transition: background 0.15s ease;
}
.sheet-title-editable:hover {
  background: var(--suite-gray-100, #f0f0f0);
}
.sheet-title-input {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--suite-text);
  border: 1px solid var(--suite-primary, #2e7d32);
  border-radius: 4px;
  padding: 2px 8px;
  outline: none;
  background: #fff;
  width: 220px;
  max-width: 100%;
}
.arrival-logo-xs {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  user-select: none;
}
.arrival-logo-xs .ar { color: var(--suite-gray-700); }
.arrival-logo-xs .rival { color: var(--suite-primary); }

/* Back-to-landing animated logo link */
.arrival-home-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.arrival-home-link:hover { transform: scale(1.12); }
.arrival-home-link .ar,
.arrival-home-link .rival { transition: color 0.25s ease; }
.arrival-home-link:hover .ar,
.arrival-home-link:hover .rival { color: var(--suite-primary); }
.arrival-chevron {
  color: var(--suite-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin: 0 -0.02em;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.arrival-chevron svg { height: 0.48em; width: auto; display: block; }
.arrival-home-link:hover .arrival-chevron { transform: scaleX(-1); }
.sheet-connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 4px;
}
.sheet-connection-dot[data-status="connected"] { background: #16a34a; }
.sheet-connection-dot[data-status="connecting"] { background: #d97706; }
.sheet-connection-dot[data-status="disconnected"] { background: #dc2626; }

/* ---------- Toolbar / Ribbon ---------- */

.sheet-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  background: var(--suite-bg);
  border-bottom: 1px solid var(--suite-border);
  min-height: 40px;
  flex-shrink: 0;
  overflow-x: auto;
}
.sheet-toolbar-group {
  display: flex;
  align-items: center;
  gap: 1px;
}
.sheet-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: var(--suite-radius-sm);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--suite-text);
  transition: background var(--suite-transition-fast);
  padding: 0 4px;
}
.sheet-toolbar-btn:hover {
  background: var(--suite-gray-100);
  border-color: var(--suite-border);
}
.sheet-toolbar-btn--active {
  background: var(--suite-gray-200);
  border-color: var(--suite-border-strong);
}
.sheet-toolbar-btn--text {
  gap: 4px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
}
.sheet-toolbar-btn--text span {
  font-size: 11px;
}
.sheet-toolbar-btn svg {
  flex-shrink: 0;
}
.sheet-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--suite-border);
  margin: 0 6px;
  flex-shrink: 0;
}
.sheet-toolbar-select {
  height: 28px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-sm);
  background: var(--suite-bg);
  font-family: var(--suite-font-sans);
  font-size: 12px;
  color: var(--suite-text);
  padding: 0 4px;
  cursor: pointer;
  outline: none;
}
.sheet-toolbar-select:hover {
  border-color: var(--suite-border-strong);
}
.sheet-toolbar-select:focus {
  border-color: var(--suite-primary);
}
.sheet-toolbar-select--font {
  width: 130px;
}
.sheet-toolbar-select--size {
  width: 52px;
}
.sheet-toolbar-select--format {
  width: 110px;
}
.sheet-toolbar-color {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  border-radius: var(--suite-radius-sm);
}
.sheet-toolbar-color:hover {
  background: var(--suite-gray-100);
  border-color: var(--suite-border);
}
.sheet-toolbar-color-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.sheet-toolbar-color-icon {
  font-weight: 700;
  font-size: 14px;
  border-bottom: 3px solid var(--suite-primary);
  line-height: 1;
  padding-bottom: 1px;
}
.sheet-toolbar-fill-icon {
  display: block;
}

/* ---------- Formula bar ---------- */

.sheet-formula-bar {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--suite-border);
  background: var(--suite-bg);
  min-height: 28px;
  flex-shrink: 0;
}
.sheet-formula-bar-ref {
  width: 80px;
  padding: 0 8px;
  font-family: var(--suite-font-mono);
  font-size: 12px;
  text-align: center;
  color: var(--suite-text);
  border-right: 1px solid var(--suite-border);
  user-select: none;
  flex-shrink: 0;
}
.sheet-formula-bar-sep {
  width: 1px;
  height: 20px;
  background: var(--suite-border);
}
.sheet-formula-bar-fx {
  padding: 0 8px;
  flex-shrink: 0;
}
.sheet-fx-icon {
  font-style: italic;
  font-weight: 600;
  font-size: 12px;
  color: var(--suite-text-secondary);
}
.sheet-formula-bar-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 4px 8px;
  font-family: var(--suite-font-sans);
  font-size: 13px;
  background: transparent;
}
.sheet-formula-bar-input:focus {
  background: #fff;
}

/* ---------- Grid container ---------- */

.sheet-grid-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  outline: none;
  background: var(--suite-bg);
}
.sheet-grid-container:focus {
  outline: none;
}

.sheet-corner {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--sheet-header-bg);
  border-right: 1px solid var(--sheet-grid-border);
  border-bottom: 1px solid var(--sheet-grid-border);
  z-index: 3;
}

.sheet-col-headers {
  position: absolute;
  top: 0;
  overflow: visible;
  z-index: 2;
  right: 0;
}
.sheet-col-header {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sheet-header-bg);
  border-right: 1px solid var(--sheet-grid-border);
  border-bottom: 1px solid var(--sheet-grid-border);
  font-size: 11px;
  font-weight: 500;
  color: var(--sheet-header-text);
  user-select: none;
}
.sheet-header--active {
  background: var(--sheet-active-header);
  color: var(--suite-primary);
  font-weight: 600;
}

.sheet-row-headers {
  position: absolute;
  left: 0;
  overflow: visible;
  z-index: 2;
  bottom: 0;
}
.sheet-row-header {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sheet-header-bg);
  border-right: 1px solid var(--sheet-grid-border);
  border-bottom: 1px solid var(--sheet-grid-border);
  font-size: 11px;
  font-weight: 500;
  color: var(--sheet-header-text);
  user-select: none;
}

.sheet-scroll-area {
  position: absolute;
  right: 0;
  bottom: 0;
  overflow: auto;
}
.sheet-cells-canvas {
  position: relative;
}

/* ---------- Cells ---------- */

.sheet-cell {
  display: flex;
  align-items: center;
  padding: var(--sheet-cell-padding);
  border-right: 1px solid var(--sheet-grid-border);
  border-bottom: 1px solid var(--sheet-grid-border);
  overflow: hidden;
  white-space: nowrap;
  cursor: cell;
  font-size: 13px;
  line-height: var(--sheet-cell-height);
  background: var(--suite-bg);
}
.sheet-cell--selected {
  background: var(--sheet-select-bg);
}
.sheet-cell--editing {
  z-index: 2;
  border: 2px solid var(--suite-primary);
  padding: 0;
  background: #fff;
}
.sheet-cell-text {
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.sheet-cell-input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 0 5px;
  font-family: var(--suite-font-sans);
  font-size: 13px;
  background: #fff;
}

/* Active cell highlight */
.sheet-active-cell {
  border: 2px solid var(--sheet-select-border);
  border-radius: 0;
  z-index: 1;
}
.sheet-active-cell::after {
  content: "";
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 6px;
  height: 6px;
  background: var(--sheet-select-border);
  border-radius: 1px;
  cursor: crosshair;
}

/* ---------- Sheet tabs ---------- */

.sheet-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 4px;
  background: var(--suite-bg-secondary);
  border-top: 1px solid var(--suite-border);
  min-height: 30px;
  overflow-x: auto;
  flex-shrink: 0;
}
.sheet-tab-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  color: var(--suite-text-secondary);
  border-radius: var(--suite-radius-sm);
  flex-shrink: 0;
}
.sheet-tab-add:hover {
  background: var(--suite-gray-200);
  color: var(--suite-text);
}
.sheet-tab {
  display: flex;
  align-items: center;
  padding: 4px 16px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--suite-text-secondary);
  white-space: nowrap;
  user-select: none;
  transition: color var(--suite-transition-fast), border-color var(--suite-transition-fast);
}
.sheet-tab:hover {
  color: var(--suite-text);
  background: var(--suite-gray-100);
}
.sheet-tab--active {
  color: var(--suite-primary);
  border-bottom-color: var(--suite-primary);
  font-weight: 500;
}
.sheet-tab-rename {
  border: 1px solid var(--suite-primary);
  border-radius: 2px;
  padding: 0 4px;
  font-size: 12px;
  font-family: inherit;
  width: 80px;
  outline: none;
}

/* ---------- Status bar ---------- */

.sheet-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--suite-primary);
  color: rgba(255, 255, 255, 0.9);
  min-height: 22px;
  font-size: 11px;
  flex-shrink: 0;
}
.sheet-status-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet-status-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.sheet-status-stat {
  white-space: nowrap;
}
.sheet-status-stat strong {
  font-weight: 600;
}
.sheet-status-connection {
  font-size: 10px;
}
.sheet-status-connection--connected { color: #81c784; }
.sheet-status-connection--connecting { color: #fff176; }
.sheet-status-connection--disconnected { color: #ef5350; }
.sheet-status-connection--reconnecting { color: #ffb74d; }

/* ================================================================
   Context Menu
   ================================================================ */

.sheet-context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  background: var(--suite-bg);
  border: 1px solid var(--suite-border);
  border-radius: 6px;
  box-shadow: var(--suite-shadow-md);
  padding: 4px 0;
  font-size: 13px;
  user-select: none;
}
.sheet-context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--suite-text);
  transition: background var(--suite-transition-fast);
}
.sheet-context-menu-item:hover {
  background: var(--suite-gray-100);
}
.sheet-context-menu-item--active,
.sheet-context-menu-item--selected {
  background: var(--suite-primary-light);
  color: var(--suite-primary);
}
.sheet-context-menu-item--disabled {
  color: var(--suite-gray-400);
  pointer-events: none;
}
.sheet-context-menu-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--suite-text-secondary);
}
.sheet-context-menu-item--active .sheet-context-menu-icon,
.sheet-context-menu-item--selected .sheet-context-menu-icon {
  color: var(--suite-primary);
}
.sheet-context-menu-label {
  flex: 1;
}
.sheet-context-menu-shortcut {
  font-size: 11px;
  color: var(--suite-gray-400);
  margin-left: auto;
  padding-left: 24px;
}
.sheet-context-menu-separator {
  height: 1px;
  background: var(--suite-border);
  margin: 4px 0;
}

/* ================================================================
   Find and Replace
   ================================================================ */

.sheet-find-replace {
  position: fixed;
  top: 120px;
  right: 24px;
  z-index: 100;
  width: 360px;
  background: var(--suite-bg);
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-lg);
  box-shadow: var(--suite-shadow-md);
  font-size: 13px;
  transition: opacity 150ms ease, transform 150ms ease;
}
.sheet-find-replace--entering {
  opacity: 0;
  transform: translateY(-8px);
}
.sheet-find-replace--visible {
  opacity: 1;
  transform: translateY(0);
}
.sheet-find-replace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 0;
}
.sheet-find-replace-tabs {
  display: flex;
  gap: 0;
}
.sheet-find-replace-tab {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--suite-text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--suite-transition-fast), border-color var(--suite-transition-fast);
}
.sheet-find-replace-tab:hover {
  color: var(--suite-text);
}
.sheet-find-replace-tab--active {
  color: var(--suite-primary);
  border-bottom-color: var(--suite-primary);
}
.sheet-find-replace-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--suite-radius-sm);
  background: transparent;
  color: var(--suite-text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--suite-transition-fast);
}
.sheet-find-replace-close:hover {
  background: var(--suite-gray-100);
  color: var(--suite-text);
}
.sheet-find-replace-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sheet-find-replace-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sheet-find-replace-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.sheet-find-replace-input-wrap .sheet-find-replace-search-icon {
  position: absolute;
  left: 8px;
  color: var(--suite-gray-400);
  font-size: 13px;
  pointer-events: none;
}
.sheet-find-replace-input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  padding: 0 8px;
  padding-left: 28px;
  font-family: var(--suite-font-sans);
  font-size: 13px;
  background: var(--suite-bg);
  color: var(--suite-text);
  outline: none;
  transition: border-color var(--suite-transition-fast);
}
.sheet-find-replace-input:focus {
  border-color: var(--suite-primary);
}
.sheet-find-replace-input--replace {
  padding-left: 8px;
}
.sheet-find-replace-count {
  font-size: 11px;
  color: var(--suite-text-secondary);
  background: var(--suite-gray-100);
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.sheet-find-replace-nav {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.sheet-find-replace-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-sm);
  background: var(--suite-bg);
  color: var(--suite-text);
  cursor: pointer;
  font-size: 12px;
  transition: background var(--suite-transition-fast);
}
.sheet-find-replace-nav-btn:hover {
  background: var(--suite-gray-100);
}
.sheet-find-replace-options {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--suite-text-secondary);
}
.sheet-find-replace-options label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.sheet-find-replace-options input[type="checkbox"] {
  accent-color: var(--suite-primary);
}
.sheet-find-replace-actions {
  display: flex;
  gap: 6px;
}

/* ================================================================
   Column Resize Handle
   ================================================================ */

.sheet-col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 4;
}
.sheet-col-resize-handle::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 0;
  width: 2px;
  height: 100%;
  background: transparent;
  transition: background var(--suite-transition-fast);
}
.sheet-col-resize-handle:hover::after {
  background: var(--suite-accent);
}
.sheet-col-resize-handle--active::after {
  background: var(--suite-primary);
}

.sheet-row-resize-handle {
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 6px;
  cursor: row-resize;
  z-index: 4;
}
.sheet-row-resize-handle::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: transparent;
  transition: background var(--suite-transition-fast);
}
.sheet-row-resize-handle:hover::after {
  background: var(--suite-accent);
}
.sheet-row-resize-handle--active::after {
  background: var(--suite-primary);
}

/* ================================================================
   Charts
   ================================================================ */

.sheet-chart-container {
  position: absolute;
  z-index: 10;
  background: var(--suite-bg);
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  box-shadow: var(--suite-shadow-md);
  min-width: 320px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
}
.sheet-chart-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  padding: 0 8px;
  background: var(--suite-gray-50);
  border-bottom: 1px solid var(--suite-border);
  cursor: move;
  flex-shrink: 0;
  user-select: none;
}
.sheet-chart-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--suite-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-chart-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: var(--suite-radius-sm);
  background: transparent;
  color: var(--suite-text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--suite-transition-fast);
}
.sheet-chart-close:hover {
  background: var(--suite-gray-200);
  color: var(--suite-text);
}
.sheet-chart-canvas {
  flex: 1;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.sheet-chart-canvas canvas {
  max-width: 100%;
  max-height: 100%;
}

/* Chart dialog */
.sheet-chart-dialog {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
}
.sheet-chart-dialog-panel {
  width: 640px;
  max-height: 80vh;
  background: var(--suite-bg);
  border-radius: var(--suite-radius-lg);
  box-shadow: var(--suite-shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-chart-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--suite-border);
}
.sheet-chart-dialog-header h3 {
  font-size: 15px;
  font-weight: 600;
}
.sheet-chart-dialog-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.sheet-chart-type-grid {
  width: 180px;
  border-right: 1px solid var(--suite-border);
  padding: 12px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
}
.sheet-chart-type-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  cursor: pointer;
  font-size: 10px;
  color: var(--suite-text-secondary);
  text-align: center;
  transition: border-color var(--suite-transition-fast), background var(--suite-transition-fast);
}
.sheet-chart-type-item:hover {
  border-color: var(--suite-border-strong);
  background: var(--suite-gray-50);
}
.sheet-chart-type-item--selected {
  border-color: var(--suite-primary);
  background: var(--suite-primary-light);
  color: var(--suite-primary);
}
.sheet-chart-type-item-icon {
  font-size: 22px;
}
.sheet-chart-settings {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet-chart-preview {
  width: 260px;
  border-left: 1px solid var(--suite-border);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--suite-gray-50);
}
.sheet-chart-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--suite-border);
}

/* ================================================================
   Conditional Format Dialog
   ================================================================ */

.sheet-cf-dialog {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
}
.sheet-cf-dialog-panel {
  width: 480px;
  max-height: 70vh;
  background: var(--suite-bg);
  border-radius: var(--suite-radius-lg);
  box-shadow: var(--suite-shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-cf-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--suite-border);
}
.sheet-cf-dialog-header h3 {
  font-size: 15px;
  font-weight: 600;
}
.sheet-cf-dialog-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sheet-cf-rule-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sheet-cf-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  background: var(--suite-gray-50);
  transition: border-color var(--suite-transition-fast);
}
.sheet-cf-rule:hover {
  border-color: var(--suite-border-strong);
}
.sheet-cf-rule--selected {
  border-color: var(--suite-primary);
  background: var(--suite-primary-light);
}
.sheet-cf-rule-drag {
  cursor: grab;
  color: var(--suite-gray-400);
  font-size: 14px;
  flex-shrink: 0;
}
.sheet-cf-rule-summary {
  flex: 1;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-cf-rule-preview {
  width: 48px;
  height: 20px;
  border-radius: var(--suite-radius-sm);
  border: 1px solid var(--suite-border);
  flex-shrink: 0;
}
.sheet-cf-rule-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--suite-radius-sm);
  background: transparent;
  color: var(--suite-gray-400);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  transition: background var(--suite-transition-fast), color var(--suite-transition-fast);
}
.sheet-cf-rule-remove:hover {
  background: var(--suite-gray-200);
  color: var(--suite-text);
}
.sheet-cf-add-btn {
  align-self: flex-start;
}
.sheet-cf-type-select {
  height: 30px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  padding: 0 8px;
  font-family: var(--suite-font-sans);
  font-size: 13px;
  background: var(--suite-bg);
  color: var(--suite-text);
  outline: none;
  cursor: pointer;
}
.sheet-cf-type-select:focus {
  border-color: var(--suite-primary);
}
.sheet-cf-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sheet-cf-color-row label {
  font-size: 12px;
  color: var(--suite-text-secondary);
  min-width: 70px;
}
.sheet-cf-color-input {
  width: 32px;
  height: 26px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-sm);
  padding: 1px;
  cursor: pointer;
  background: var(--suite-bg);
}
.sheet-cf-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--suite-border);
}

/* ================================================================
   Data Bar (in-cell)
   ================================================================ */

.sheet-data-bar {
  position: absolute;
  left: 1px;
  top: 50%;
  transform: translateY(-50%);
  height: calc(100% - 4px);
  border-radius: 2px;
  background: var(--suite-primary-light);
  pointer-events: none;
  z-index: 0;
  transition: width 200ms ease;
}
.sheet-cell--has-data-bar {
  position: relative;
}
.sheet-cell--has-data-bar .sheet-cell-text {
  position: relative;
  z-index: 1;
}

/* ================================================================
   Auto-filter Dropdown
   ================================================================ */

.sheet-filter-dropdown {
  position: absolute;
  z-index: 200;
  width: 240px;
  max-height: 340px;
  background: var(--suite-bg);
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  box-shadow: var(--suite-shadow-md);
  display: flex;
  flex-direction: column;
  font-size: 12px;
  overflow: hidden;
}
.sheet-filter-dropdown-search {
  padding: 8px;
  border-bottom: 1px solid var(--suite-border);
}
.sheet-filter-dropdown-search input {
  width: 100%;
  height: 28px;
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-sm);
  padding: 0 8px;
  font-family: var(--suite-font-sans);
  font-size: 12px;
  outline: none;
}
.sheet-filter-dropdown-search input:focus {
  border-color: var(--suite-primary);
}
.sheet-filter-dropdown-controls {
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--suite-border);
}
.sheet-filter-dropdown-controls button {
  border: none;
  background: transparent;
  color: var(--suite-accent);
  font-family: var(--suite-font-sans);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 0;
}
.sheet-filter-dropdown-controls button:hover {
  text-decoration: underline;
}
.sheet-filter-dropdown-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.sheet-filter-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background var(--suite-transition-fast);
}
.sheet-filter-dropdown-item:hover {
  background: var(--suite-gray-100);
}
.sheet-filter-dropdown-item input[type="checkbox"] {
  accent-color: var(--suite-primary);
  flex-shrink: 0;
}
.sheet-filter-dropdown-item label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.sheet-filter-dropdown-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--suite-border);
}
.sheet-filter-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--suite-gray-400);
  font-size: 10px;
  cursor: pointer;
  border-radius: var(--suite-radius-sm);
  transition: background var(--suite-transition-fast);
}
.sheet-filter-icon:hover {
  background: var(--suite-gray-200);
  color: var(--suite-text);
}
.sheet-filter-icon--active {
  color: var(--suite-primary);
}

/* ================================================================
   Selection Range
   ================================================================ */

.sheet-selection-range {
  position: absolute;
  background: rgba(33, 115, 70, 0.08);
  border: 1px solid var(--sheet-select-border);
  pointer-events: none;
  z-index: 1;
}
.sheet-selection-range--cut {
  background: transparent;
  border: 2px dashed var(--suite-gray-400);
  animation: sheet-marching-ants 0.5s linear infinite;
}
@keyframes sheet-marching-ants {
  0% { border-color: var(--suite-gray-400); }
  50% { border-color: transparent; }
  100% { border-color: var(--suite-gray-400); }
}

/* ================================================================
   Frozen Pane Indicators
   ================================================================ */

.sheet-frozen-row-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-bottom: 2px solid var(--suite-gray-400);
  z-index: 5;
  pointer-events: none;
}
.sheet-frozen-col-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-right: 2px solid var(--suite-gray-400);
  z-index: 5;
  pointer-events: none;
}

/* ================================================================
   Merged Cells
   ================================================================ */

.sheet-cell--merged {
  overflow: visible;
  z-index: 1;
  background: var(--suite-bg);
  border-right: 1px solid var(--sheet-grid-border);
  border-bottom: 1px solid var(--sheet-grid-border);
}
.sheet-cell--merged-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* ================================================================
   Print Styles
   ================================================================ */

@media print {
  .sheet-top-bar,
  .sheet-toolbar,
  .sheet-ribbon,
  .sheet-formula-bar,
  .sheet-tabs,
  .sheet-status-bar,
  .sheet-find-replace,
  .sheet-chart-dialog,
  .sheet-cf-dialog,
  .sheet-context-menu,
  .sheet-filter-dropdown,
  .sheet-autocomplete {
    display: none !important;
  }
  html, body, #root {
    height: auto;
    overflow: visible;
  }
  .sheet-app {
    height: auto;
    overflow: visible;
  }
  .sheet-grid-container {
    overflow: visible;
    position: static;
  }
  .sheet-scroll-area {
    overflow: visible;
    position: static;
  }
  .sheet-cell {
    border-color: #999 !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .sheet-col-header,
  .sheet-row-header,
  .sheet-corner {
    background: #eee !important;
    border-color: #999 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .sheet-active-cell,
  .sheet-selection-range {
    border-color: transparent !important;
    background: transparent !important;
  }
  .sheet-active-cell::after {
    display: none;
  }
  .sheet-data-bar {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .sheet-frozen-row-line,
  .sheet-frozen-col-line {
    display: none;
  }
  .sheet-chart-container {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #999;
  }
}

/* ========================================================================== */
/*  Ribbon Tab System                                                          */
/* ========================================================================== */

.sheet-ribbon {
  display: flex;
  flex-direction: column;
  background: var(--suite-bg);
  border-bottom: 1px solid var(--suite-border);
  flex-shrink: 0;
  user-select: none;
}

/* Quick-access row (undo/redo) */
.sheet-ribbon-quick-access {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  background: var(--suite-gray-50);
  border-bottom: 1px solid var(--suite-gray-200);
  min-height: 24px;
}
.sheet-ribbon-quick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  color: var(--suite-text-secondary);
  transition: background 100ms ease, color 100ms ease;
}
.sheet-ribbon-quick-btn:hover {
  background: var(--suite-gray-200);
  color: var(--suite-text);
}

/* Tab strip */
.sheet-ribbon-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding: 0 8px;
  background: var(--suite-gray-50);
  border-bottom: 1px solid var(--suite-gray-200);
}
.sheet-ribbon-tab {
  position: relative;
  padding: 6px 16px 5px;
  border: none;
  background: transparent;
  font-family: var(--suite-font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--suite-text-secondary);
  cursor: pointer;
  transition: color 100ms ease, background 100ms ease;
  border-radius: 4px 4px 0 0;
}
.sheet-ribbon-tab:hover {
  color: var(--suite-text);
  background: rgba(10, 140, 122, 0.04);
}
.sheet-ribbon-tab--active {
  color: #0a8c7a;
  background: var(--suite-bg);
  border: 1px solid var(--suite-gray-200);
  border-bottom: 1px solid var(--suite-bg);
  margin-bottom: -1px;
  z-index: 1;
}
.sheet-ribbon-tab--active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #0a8c7a;
  border-radius: 2px 2px 0 0;
}

/* Panel (the content area below tabs) */
.sheet-ribbon-panel {
  display: flex;
  align-items: stretch;
  padding: 4px 8px 2px;
  min-height: 72px;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

/* Group: vertical container with controls on top, label on bottom */
.sheet-ribbon-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px;
  min-width: 0;
}
.sheet-ribbon-group-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-height: 0;
}
.sheet-ribbon-group-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--suite-text-secondary);
  text-align: center;
  padding: 1px 0 2px;
  white-space: nowrap;
  letter-spacing: 0.03em;
}

/* Divider between groups */
.sheet-ribbon-divider {
  width: 1px;
  align-self: stretch;
  margin: 4px 2px;
  background: var(--suite-gray-200);
  flex-shrink: 0;
}

/* Standard ribbon button */
.sheet-ribbon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  font-family: var(--suite-font-sans);
  font-size: 11px;
  color: var(--suite-text);
  transition: background 80ms ease, border-color 80ms ease;
  white-space: nowrap;
}
.sheet-ribbon-btn:hover {
  background: var(--suite-gray-100);
  border-color: var(--suite-gray-200);
}
.sheet-ribbon-btn:active {
  background: rgba(10, 140, 122, 0.08);
}
.sheet-ribbon-btn--active {
  background: rgba(10, 140, 122, 0.08);
  border-color: rgba(10, 140, 122, 0.25);
  color: #0a8c7a;
}
.sheet-ribbon-btn--active:hover {
  background: rgba(10, 140, 122, 0.12);
}
.sheet-ribbon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.sheet-ribbon-btn svg {
  flex-shrink: 0;
}
.sheet-ribbon-btn-label {
  font-size: 10.5px;
  font-weight: 450;
  line-height: 1.1;
}

/* Large button (icon on top, label below) */
.sheet-ribbon-btn--large {
  flex-direction: column;
  height: auto;
  min-width: 44px;
  padding: 4px 6px 2px;
  gap: 2px;
}
.sheet-ribbon-btn--large svg {
  width: 20px;
  height: 20px;
}
.sheet-ribbon-btn--large .sheet-ribbon-btn-label {
  font-size: 10px;
  text-align: center;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stack: two buttons stacked vertically */
.sheet-ribbon-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: stretch;
}

/* Row: buttons in a horizontal row (used for multi-row groups) */
.sheet-ribbon-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Ribbon selects */
.sheet-ribbon-select {
  height: 24px;
  border: 1px solid var(--suite-gray-200);
  border-radius: 3px;
  background: var(--suite-bg);
  font-family: var(--suite-font-sans);
  font-size: 11px;
  color: var(--suite-text);
  padding: 0 4px;
  cursor: pointer;
  outline: none;
  transition: border-color 100ms ease;
}
.sheet-ribbon-select:hover {
  border-color: var(--suite-gray-300);
}
.sheet-ribbon-select:focus {
  border-color: #0a8c7a;
}
.sheet-ribbon-select--font {
  width: 120px;
}
.sheet-ribbon-select--size {
  width: 46px;
}
.sheet-ribbon-select--format {
  width: 120px;
}

/* Color picker button */
.sheet-ribbon-color-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  border-radius: 3px;
  transition: background 80ms ease;
}
.sheet-ribbon-color-btn:hover {
  background: var(--suite-gray-100);
  border-color: var(--suite-gray-200);
}
.sheet-ribbon-color-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.sheet-ribbon-color-swatch {
  font-weight: 700;
  font-size: 13px;
  border-bottom: 3px solid #0a8c7a;
  line-height: 1;
  padding-bottom: 1px;
}

/* ================================================================
   Formula Autocomplete
   ================================================================ */

.sheet-autocomplete {
  position: fixed;
  z-index: 50;
  background: var(--suite-bg);
  border: 1px solid var(--suite-border);
  border-radius: var(--suite-radius-md);
  box-shadow: 0 4px 16px rgba(42, 39, 37, 0.12);
  font-size: 12px;
  min-width: 280px;
  max-width: 480px;
  overflow: hidden;
}

.sheet-autocomplete__hint {
  padding: 6px 10px;
  background: var(--suite-gray-50);
  border-bottom: 1px solid var(--suite-border);
  font-size: 12px;
  color: var(--suite-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-autocomplete__hint-func {
  font-weight: 600;
  color: var(--suite-primary);
}
.sheet-autocomplete__hint-arg {
  font-weight: 600;
  color: var(--suite-text);
}
.sheet-autocomplete__hint-desc {
  color: var(--suite-text-secondary);
}

.sheet-autocomplete__list {
  max-height: 200px;
  overflow-y: auto;
  padding: 3px 0;
  scrollbar-width: thin;
}

.sheet-autocomplete__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background var(--suite-transition-fast);
}
.sheet-autocomplete__item:hover {
  background: var(--suite-gray-100);
}
.sheet-autocomplete__item--selected {
  background: var(--suite-primary-light);
}

.sheet-autocomplete__name {
  font-family: var(--suite-font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--suite-text);
  flex-shrink: 0;
}
.sheet-autocomplete__name strong {
  color: var(--suite-primary);
  font-weight: 700;
}

.sheet-autocomplete__desc {
  color: var(--suite-text-secondary);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.sheet-autocomplete__detail {
  padding: 8px 10px;
  border-top: 1px solid var(--suite-border);
  background: var(--suite-gray-50);
  font-size: 11px;
}
.sheet-autocomplete__syntax {
  font-family: var(--suite-font-mono);
  font-size: 11px;
  color: var(--suite-text);
  margin-bottom: 4px;
}
.sheet-autocomplete__args {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sheet-autocomplete__arg {
  color: var(--suite-text-secondary);
  font-size: 11px;
}
.sheet-autocomplete__arg-name {
  font-weight: 600;
  color: var(--suite-text);
}

.sheet-autocomplete__category {
  display: inline-block;
  margin-top: 6px;
  padding: 1px 8px;
  background: rgba(10, 140, 122, 0.1);
  color: var(--suite-primary);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
}

/* Responsive: hide labels on narrow viewports */
@media (max-width: 900px) {
  .sheet-ribbon-btn-label {
    display: none;
  }
  .sheet-ribbon-btn--large {
    min-width: 30px;
    padding: 4px 3px 2px;
  }
  .sheet-ribbon-btn--large .sheet-ribbon-btn-label {
    display: block;
    font-size: 9px;
  }
  .sheet-ribbon-group {
    padding: 0 4px;
  }
}

/* Print: hide ribbon */
@media print {
  .sheet-ribbon {
    display: none !important;
  }
}

/* Column/Row resize handles */
.sheet-col-resize-handle {
  position: absolute;
  top: 0;
  right: -2px;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}
.sheet-col-resize-handle:hover,
.sheet-col-resize-handle--active {
  background: var(--suite-primary);
}
.sheet-row-resize-handle {
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 4px;
  cursor: row-resize;
  z-index: 5;
}
.sheet-row-resize-handle:hover,
.sheet-row-resize-handle--active {
  background: var(--suite-primary);
}

/* Drag selection visual */
.sheet-selection-range {
  position: absolute;
  background: rgba(10, 140, 122, 0.08);
  border: 1.5px solid var(--suite-primary);
  pointer-events: none;
  z-index: 3;
}

/* Formula preview */
.sheet-formula-preview {
  position: absolute;
  top: 100%;
  left: 60px;
  margin-top: 2px;
  padding: 3px 8px;
  background: var(--suite-gray-700);
  color: #fff;
  font-size: 11px;
  font-family: var(--suite-font-mono);
  border-radius: 4px;
  white-space: nowrap;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(42, 39, 37, 0.15);
}

/* =========================================================================
   Feature Dialogs — Conditional Format, Data Validation, Named Ranges, Protection
   ========================================================================= */

/* --- Shared dialog field patterns --- */
.sheet-cf-body,
.sheet-dv-body,
.sheet-nr-body,
.sheet-prot-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 360px;
  max-width: 480px;
  font-size: 13px;
  color: var(--suite-text);
}

.sheet-cf-label,
.sheet-dv-label,
.sheet-prot-label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--suite-gray-600);
}

.sheet-cf-select,
.sheet-dv-select,
.sheet-prot-select {
  display: block;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--suite-border-strong);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--suite-font-sans);
  background: var(--suite-bg);
  color: var(--suite-text);
  outline: none;
  transition: border-color 120ms ease;
}
.sheet-cf-select:focus,
.sheet-dv-select:focus,
.sheet-prot-select:focus {
  border-color: var(--suite-primary);
}

.sheet-cf-input,
.sheet-dv-input,
.sheet-nr-input,
.sheet-prot-input {
  display: block;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--suite-border-strong);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--suite-font-sans);
  background: var(--suite-bg);
  color: var(--suite-text);
  outline: none;
  box-sizing: border-box;
  transition: border-color 120ms ease;
}
.sheet-cf-input:focus,
.sheet-dv-input:focus,
.sheet-nr-input:focus,
.sheet-prot-input:focus {
  border-color: var(--suite-primary);
}

.sheet-cf-field,
.sheet-dv-field,
.sheet-prot-field {
  display: flex;
  flex-direction: column;
}

.sheet-cf-row,
.sheet-dv-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.sheet-cf-check,
.sheet-dv-check,
.sheet-prot-perm {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.sheet-cf-section,
.sheet-dv-section,
.sheet-prot-section {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--suite-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-cf-section-title,
.sheet-dv-section-title,
.sheet-prot-section-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--suite-gray-600);
}

/* --- Conditional Format Dialog --- */
.sheet-cf-color-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.sheet-cf-color-field input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid var(--suite-border-strong);
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  background: var(--suite-bg);
}

.sheet-cf-preview {
  padding: 8px 12px;
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--suite-border);
}

.sheet-cf-range-hint {
  font-size: 11px;
  color: var(--suite-text-secondary);
  padding-top: 4px;
}

/* --- Data Validation Dialog --- */
.sheet-dv-tabs {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--suite-border);
  padding-bottom: 6px;
  margin-bottom: 4px;
}
.sheet-dv-tab,
.sheet-dv-tab-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--suite-text-secondary);
  cursor: pointer;
  padding-bottom: 4px;
}
.sheet-dv-tab--active {
  color: var(--suite-primary);
  border-bottom: 2px solid var(--suite-primary);
}

.sheet-dv-textarea {
  display: block;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--suite-border-strong);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--suite-font-sans);
  background: var(--suite-bg);
  color: var(--suite-text);
  outline: none;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 120ms ease;
}
.sheet-dv-textarea:focus {
  border-color: var(--suite-primary);
}

/* --- Named Ranges Dialog --- */
.sheet-nr-empty {
  text-align: center;
  color: var(--suite-text-secondary);
  padding: 16px 0;
  font-size: 13px;
}

.sheet-nr-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--suite-border);
  border-radius: 6px;
}

.sheet-nr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--suite-border);
}
.sheet-nr-item:last-child {
  border-bottom: none;
}

.sheet-nr-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet-nr-item-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--suite-text);
}

.sheet-nr-item-ref {
  font-size: 11px;
  color: var(--suite-text-secondary);
  font-family: var(--suite-font-mono);
}

.sheet-nr-delete-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--suite-gray-400);
  font-size: 18px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 120ms ease;
}
.sheet-nr-delete-btn:hover {
  color: #c62828;
  background: #fbe9e7;
  border-color: #ef9a9a;
}

.sheet-nr-add-section {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--suite-border);
}

.sheet-nr-add-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--suite-gray-600);
  margin-bottom: 8px;
}

.sheet-nr-add-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.sheet-nr-add-row .sheet-nr-input {
  flex: 1;
}

.sheet-nr-add-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.sheet-nr-error {
  color: #c62828;
  font-size: 12px;
  margin-top: 4px;
}

/* --- Protection Dialog --- */
.sheet-prot-status {
  padding: 8px 0;
}

.sheet-prot-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}

.sheet-prot-toggle-label {
  font-weight: 600;
}

.sheet-prot-permissions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

/* Freeze pane styles */
.sheet-frozen-col-pane,
.sheet-frozen-row-pane,
.sheet-frozen-corner-pane {
  background: var(--suite-gray-50, #f9f8f7);
}
.sheet-frozen-col-pane .sheet-cell,
.sheet-frozen-row-pane .sheet-cell,
.sheet-frozen-corner-pane .sheet-cell {
  pointer-events: auto;
}
.sheet-freeze-line-col,
.sheet-freeze-line-row {
  background: var(--suite-border, #e0ddd9);
}
