/* === Landing Page === */
#landing {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0a15 0%, #1a1a2e 50%, #0f0f1a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e0e0ff;
}

.landing-content {
  max-width: 900px;
  width: 100%;
  text-align: center;
}

.landing-hero { margin-bottom: 50px; }

.landing-logo {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  margin-bottom: 16px;
}

.landing-hero h1 {
  font-size: 42px;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe, #00cec9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-tagline {
  font-size: 18px;
  color: #8888bb;
  margin-bottom: 28px;
}

.landing-cta {
  padding: 14px 40px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.landing-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(108, 92, 231, 0.4);
}

.landing-sub {
  font-size: 13px;
  color: #6666aa;
  margin-top: 14px;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 50px;
}

.landing-feature {
  background: rgba(26, 26, 46, 0.6);
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 24px 18px;
  text-align: center;
  transition: all 0.2s;
}

.landing-feature:hover {
  border-color: #6c5ce7;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.15);
}

.landing-feature-icon {
  font-size: 28px;
  margin-bottom: 10px;
  color: #6c5ce7;
  font-weight: 700;
  font-style: italic;
}

.landing-feature h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #e0e0ff;
}

.landing-feature p {
  font-size: 12px;
  color: #8888bb;
  line-height: 1.5;
}

.landing-bottom { margin-top: 10px; }

.landing-badges {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.landing-badges span {
  padding: 5px 14px;
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid #2a2a4a;
  border-radius: 20px;
  font-size: 12px;
  color: #8888bb;
}

@media (max-width: 768px) {
  .landing-hero h1 { font-size: 28px; }
  .landing-tagline { font-size: 15px; }
  .landing-features { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .landing-feature { padding: 18px 14px; }
}

@media (max-width: 400px) {
  .landing-features { grid-template-columns: 1fr; }
}

/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --bg-cell: #12122a;
  --bg-hover: #1f1f3a;
  --bg-selected: #2a2a5a;
  --border: #2a2a4a;
  --border-light: #3a3a6a;
  --text: #e0e0ff;
  --text-dim: #8888bb;
  --accent: #6c5ce7;
  --accent-hover: #7f6ff0;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --success: #00cec9;
  --warning: #fdcb6e;
  --danger: #ff6b6b;
  --header-bg: #13132d;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --radius: 6px;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 13px;
}

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

/* === Top Bar === */
.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.brand-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
}

/* Pro button */
.donate-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.donate-btn:hover { transform: scale(1.05); box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4); }

/* Donate modal */
.donate-body { text-align: center; }

.donate-paypal-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: #0070ba;
  color: white;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
}

.donate-paypal-btn:hover { background: #005ea6; box-shadow: 0 2px 10px rgba(0, 112, 186, 0.4); }

.donate-crypto {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 auto;
  max-width: 420px;
}

.donate-crypto code {
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
  flex: 1;
  text-align: left;
  font-family: var(--font-mono);
}

.donate-crypto button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.file-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

#file-name {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 14px;
  padding: 4px 8px;
  border-radius: var(--radius);
  width: 220px;
  transition: border-color 0.2s;
}

#file-name:hover, #file-name:focus {
  border-color: var(--border-light);
  outline: none;
}

.file-buttons {
  display: flex;
  gap: 4px;
}

.file-buttons button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
  white-space: nowrap;
}

.file-buttons button:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-light);
}

/* === Toolbar === */
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 6px;
}

.toolbar button {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

.toolbar button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.toolbar button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.toolbar button:has(svg) + span,
.toolbar button svg { pointer-events: none; }

/* Chart button wider */
.toolbar button:has(svg):last-child { width: auto; padding: 0 8px; gap: 4px; }

.color-picker-label {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 30px;
  height: 30px;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-dim);
  transition: background 0.15s;
}

.color-picker-label:hover { background: var(--bg-hover); }

.color-picker-label input[type="color"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.color-bar {
  position: absolute;
  bottom: 2px;
  left: 5px;
  right: 5px;
  height: 3px;
  border-radius: 2px;
}

.toolbar select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

/* === Formula Bar === */
.formula-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.cell-ref {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: 4px;
  min-width: 60px;
  text-align: center;
  border: 1px solid var(--border);
}

.formula-icon {
  color: var(--text-dim);
  font-style: italic;
  font-size: 13px;
  font-weight: 600;
}

#formula-input {
  flex: 1;
  background: var(--bg-cell);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s;
}

#formula-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* === Sheet === */
.sheet-container {
  flex: 1;
  overflow: auto;
  position: relative;
}

.sheet-container::-webkit-scrollbar { width: 10px; height: 10px; }
.sheet-container::-webkit-scrollbar-track { background: var(--bg-primary); }
.sheet-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
.sheet-container::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
.sheet-container::-webkit-scrollbar-corner { background: var(--bg-primary); }

#sheet {
  border-collapse: collapse;
  table-layout: fixed;
  user-select: none;
}

#sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header-bg);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  min-width: 80px;
  text-align: center;
  cursor: pointer;
}

#sheet thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 40px;
  width: 40px;
  background: var(--header-bg);
}

#sheet thead th:hover { background: var(--bg-hover); }
#sheet thead th.col-selected { background: var(--accent); color: white; }

#sheet tbody td {
  border: 1px solid var(--border);
  padding: 0;
  height: 26px;
  min-width: 80px;
  position: relative;
  font-size: 13px;
}

#sheet tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--header-bg);
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
  font-weight: 500;
  min-width: 40px;
  width: 40px;
  cursor: pointer;
  padding: 0 4px;
}

#sheet tbody td:first-child:hover { background: var(--bg-hover); }
#sheet tbody td:first-child.row-selected { background: var(--accent); color: white; }

#sheet tbody td .cell {
  width: 100%;
  height: 100%;
  padding: 2px 6px;
  display: flex;
  align-items: center;
  cursor: cell;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-height: 26px;
}

#sheet tbody td.selected .cell {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: var(--bg-selected);
}

#sheet tbody td.in-range .cell {
  background: rgba(108, 92, 231, 0.12);
}

#sheet tbody td .cell-input {
  width: 100%;
  height: 100%;
  background: var(--bg-cell);
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 2px 6px;
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* Formula reference highlights */
#sheet tbody td.formula-ref .cell {
  transition: outline 0.15s, background-color 0.15s;
}

/* Floating charts on sheet */
.floating-chart {
  position: absolute;
  z-index: 10;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  width: 500px;
}

.floating-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
}

.floating-chart-header:active { cursor: grabbing; }

.floating-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.floating-chart-actions { display: flex; gap: 4px; flex-shrink: 0; }

.floating-chart-btn {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.floating-chart-btn:hover { background: var(--bg-hover); color: var(--text); }

.floating-chart-canvas { display: block; width: 100%; height: auto; }

.anchored-chart {
  border: 2px solid var(--accent);
  border-radius: 0;
  pointer-events: auto;
}

.anchored-chart .floating-chart-header {
  cursor: default;
  padding: 3px 8px;
}

.anchored-chart .floating-chart-title { font-size: 11px; }

.floating-chart-resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--border-light) 50%);
  border-radius: 0 0 10px 0;
}

/* Date picker popup */
.date-picker-popup {
  position: fixed;
  z-index: 200;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.date-picker-popup input[type="date"] {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  color-scheme: dark;
}

.date-picker-popup input[type="date"]:focus { border-color: var(--accent); }

.date-picker-popup button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.date-picker-popup button:hover { background: var(--bg-hover); color: var(--text); }

/* Picking cell mode for quick formula */
.sheet-container.picking-cell { cursor: crosshair; }
.sheet-container.picking-cell .cell { cursor: crosshair; }

/* Data type styling */
.cell[data-type="number"], .cell[data-type="currency"], .cell[data-type="percent"] {
  justify-content: flex-end;
  font-family: var(--font-mono);
  font-size: 12px;
}

.cell[data-type="date"] {
  color: var(--success);
}

.cell[data-type="formula"] {
  color: var(--warning);
}

/* Column resize handle */
.col-resize {
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 4;
}

.col-resize:hover, .col-resize.resizing {
  background: var(--accent);
}

/* === Sheet Tabs === */
.sheet-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.tabs-list {
  display: flex;
  gap: 2px;
}

.sheet-tab {
  padding: 4px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-bottom: none;
  color: var(--text-dim);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}

.sheet-tab:hover { background: var(--bg-hover); color: var(--text); }
.sheet-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.sheet-tab .tab-close {
  margin-left: 6px;
  opacity: 0;
  font-size: 10px;
  transition: opacity 0.15s;
}

.sheet-tab:hover .tab-close { opacity: 0.7; }
.sheet-tab .tab-close:hover { opacity: 1; }

.add-sheet-btn {
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.add-sheet-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-light); }

/* === Status Bar === */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 12px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

#status-sum {
  font-family: var(--font-mono);
  color: var(--success);
}

/* === Modals === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 500px;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-lg { width: 700px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 16px; font-weight: 600; }

.modal-header button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.modal-header button:hover { background: var(--bg-hover); color: var(--text); }

.modal-body { padding: 20px; }

/* Templates */
.templates-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.template-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.template-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.template-card h3 { font-size: 14px; margin-bottom: 4px; }
.template-card p { font-size: 11px; color: var(--text-dim); }

/* Conditional Format & Validation */
.cond-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cond-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.cond-form select, .cond-form input[type="text"], .cond-form input[type="number"] {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

.cond-form select:focus, .cond-form input:focus { border-color: var(--accent); }

.cond-colors {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.cond-color-btn {
  padding: 6px 12px;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.15s;
}

.cond-color-btn:hover { opacity: 0.8; }
.cond-color-btn.selected { border-color: white; transform: scale(1.05); }

.cond-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.cond-actions button:not(.btn-primary) {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.cond-actions button:not(.btn-primary):hover { background: var(--bg-hover); }

/* Dropdown indicator */
td .cell.has-dropdown::after {
  content: '▾';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 10px;
}

td .cell.has-dropdown { position: relative; padding-right: 16px; }

.cell-dropdown {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 120px;
  max-height: 150px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.cell-dropdown button {
  display: block;
  width: 100%;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.cell-dropdown button:hover { background: var(--bg-hover); }

/* Freeze Panes */
.freeze-border-bottom { border-bottom: 2px solid var(--accent) !important; }
.freeze-border-right { border-right: 2px solid var(--accent) !important; }

/* Find & Replace */
.find-replace-bar {
  position: absolute;
  top: 0;
  right: 20px;
  z-index: 50;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 8px 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.find-row, .replace-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.find-replace-bar input {
  background: var(--bg-cell);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  width: 200px;
}

.find-replace-bar input:focus { border-color: var(--accent); }

.find-replace-bar button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.find-replace-bar button:hover { background: var(--bg-hover); color: var(--text); }

.find-count { font-size: 11px; color: var(--text-dim); min-width: 50px; text-align: center; }

td.find-highlight .cell { outline: 2px solid var(--warning) !important; background: rgba(253, 203, 110, 0.15) !important; }

/* Shortcuts */
.shortcuts-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.shortcut-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(42, 42, 74, 0.5);
  gap: 12px;
}

.shortcut-row kbd {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  min-width: fit-content;
}

.shortcut-row span {
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
}

/* Chart options */
.chart-options {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chart-options label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.chart-options select, .chart-options input[type="text"] {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

.chart-options input:focus, .chart-options select:focus {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 180px;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.context-menu::-webkit-scrollbar { width: 6px; }
.context-menu::-webkit-scrollbar-track { background: transparent; }
.context-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.context-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
}

.context-menu button:hover { background: var(--bg-hover); }
.context-menu .separator { height: 1px; background: var(--border); margin: 4px 0; }

.context-submenu {
  position: relative;
}

.context-submenu .submenu-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.context-submenu .submenu {
  display: none;
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 140px;
  z-index: 201;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.context-submenu .submenu.show { display: block; }

/* Help modal */
.help-body { display: flex; flex-direction: column; gap: 20px; max-height: 70vh; overflow-y: auto; }

.help-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.help-section p, .help-section li { font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.help-section p { margin-bottom: 6px; }
.help-section ul, .help-section ol { padding-left: 20px; margin-bottom: 8px; }
.help-section li { margin-bottom: 4px; }
.help-section code { background: var(--bg-tertiary); padding: 1px 6px; border-radius: 3px; font-family: var(--font-mono); font-size: 12px; color: var(--warning); }
.help-section kbd { background: var(--bg-tertiary); border: 1px solid var(--border-light); border-radius: 4px; padding: 1px 6px; font-family: var(--font-mono); font-size: 11px; color: var(--text); }
.help-section strong { color: var(--text); }

.help-colors { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.help-color { padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; }

/* === Auto-fill handle === */
.autofill-handle {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border: 1px solid var(--bg-primary);
  cursor: crosshair;
  z-index: 5;
}

.autofill-preview td .cell {
  background: rgba(108, 92, 231, 0.08);
  border: 1px dashed var(--accent);
}

/* === Column filters === */
.col-filter-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 8px;
  color: var(--text-dim);
  cursor: pointer;
  vertical-align: middle;
}

.col-filter-arrow:hover { color: var(--accent); }

.filter-dropdown {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 180px;
  max-height: 250px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.filter-dropdown label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  border-radius: 3px;
}

.filter-dropdown label:hover { background: var(--bg-hover); }

.filter-dropdown .filter-actions {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.filter-dropdown .filter-actions button {
  flex: 1;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}

.filter-dropdown .filter-actions button:hover { background: var(--bg-hover); color: var(--text); }

.toolbar button.filter-active {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

/* === Cell comments === */
td .cell.has-comment {
  position: relative;
}

td .cell.has-comment::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-top: 6px solid var(--danger);
  z-index: 1;
}

.comment-tooltip {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  max-width: 250px;
  z-index: 300;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  white-space: pre-wrap;
}

/* === Print styles === */
@media print {
  .top-bar, .toolbar, .formula-bar, .status-bar, .sheet-tabs,
  .find-replace-bar, .context-menu, .modal-overlay,
  .autofill-handle, .comment-tooltip, .filter-dropdown,
  .autocomplete-dropdown { display: none !important; }

  body { background: white; color: black; overflow: visible; }
  #app { height: auto; overflow: visible; }

  .sheet-container {
    overflow: visible !important;
    height: auto !important;
    flex: none;
  }

  #sheet { width: 100%; }

  #sheet thead th {
    background: #f0f0f0 !important;
    color: #333 !important;
    border: 1px solid #999 !important;
    position: static;
  }

  #sheet thead th:first-child {
    position: static;
  }

  #sheet tbody td {
    border: 1px solid #ccc !important;
    color: black !important;
    position: static;
  }

  #sheet tbody td:first-child {
    background: #f0f0f0 !important;
    color: #333 !important;
    position: static;
  }

  #sheet tbody td .cell {
    color: black !important;
  }

  @page {
    margin: 1cm;
  }

  body::before {
    content: attr(data-print-title);
    display: block;
    font-size: 16pt;
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
    color: black;
  }

  .print-watermark {
    display: block !important;
    text-align: center;
    font-size: 9pt;
    color: #999;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
  }
}

.print-watermark { display: none; }



/* === Row/Column hide indicators === */
.hidden-row-indicator td:first-child {
  border-top: 3px double var(--accent) !important;
}

.hidden-col-indicator {
  border-left: 3px double var(--accent) !important;
}

/* === Row drag === */
/* Block drag */
.sheet-container.block-dragging { cursor: grabbing; }
.sheet-container.block-dragging .cell { cursor: grabbing; }

td.block-drop-target .cell {
  outline: 2px dashed var(--accent) !important;
  outline-offset: -1px;
  background: rgba(108, 92, 231, 0.15) !important;
}

tr.row-dragging {
  opacity: 0.5;
}

.row-drop-indicator td {
  border-top: 2px solid var(--accent) !important;
}

/* === Dark/Light theme toggle === */
[data-theme="light"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8e8e8;
  --bg-cell: #ffffff;
  --bg-hover: #eeeef5;
  --bg-selected: #d5d5f0;
  --border: #d0d0d0;
  --border-light: #b0b0b0;
  --text: #1a1a2e;
  --text-dim: #555580;
  --accent: #6c5ce7;
  --accent-hover: #7f6ff0;
  --accent-glow: rgba(108, 92, 231, 0.2);
  --success: #00a89d;
  --warning: #e0a800;
  --danger: #e05555;
  --header-bg: #eaeaf0;
}

[data-theme="light"] .sheet-container::-webkit-scrollbar-track { background: #f0f0f0; }
[data-theme="light"] .sheet-container::-webkit-scrollbar-thumb { background: #c0c0c0; }
[data-theme="light"] .date-picker-popup input[type="date"] { color-scheme: light; }

/* === Autocomplete dropdown === */
.autocomplete-dropdown {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 150px;
  max-height: 160px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.autocomplete-dropdown .ac-item {
  display: block;
  width: 100%;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.autocomplete-dropdown .ac-item:hover,
.autocomplete-dropdown .ac-item.ac-selected {
  background: var(--bg-hover);
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
  body { font-size: 12px; overflow-x: hidden; }
  #app { max-width: 100vw; overflow-x: hidden; }

  /* Top bar: stack vertically */
  .top-bar {
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 6px;
    max-width: 100vw;
    overflow: hidden;
  }

  .brand-name { display: none; }

  .file-controls {
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  #file-name {
    width: 100%;
    font-size: 13px;
    padding: 3px 6px;
  }

  .file-buttons {
    flex-wrap: nowrap;
    gap: 3px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .file-buttons::-webkit-scrollbar { display: none; }

  /* Icon-only buttons on mobile */
  .file-buttons button {
    padding: 6px 8px;
    font-size: 0;
    flex-shrink: 0;
    min-width: 34px;
    justify-content: center;
  }

  .file-buttons button svg { width: 16px; height: 16px; }

  /* Toolbar: scrollable */
  .toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .toolbar::-webkit-scrollbar { display: none; }

  .toolbar button { width: 28px; height: 28px; flex-shrink: 0; }

  .toolbar-divider { margin: 0 3px; }

  /* Formula bar */
  .formula-bar { padding: 3px 6px; gap: 4px; }

  .cell-ref {
    min-width: 45px;
    padding: 3px 6px;
    font-size: 11px;
  }

  #formula-input {
    font-size: 12px;
    padding: 4px 6px;
  }

  /* Sheet cells */
  #sheet thead th {
    padding: 4px 2px;
    font-size: 10px;
    min-width: 65px;
  }

  #sheet thead th:first-child { min-width: 32px; width: 32px; }

  #sheet tbody td {
    height: 24px;
    min-width: 65px;
    font-size: 12px;
  }

  #sheet tbody td:first-child {
    min-width: 32px;
    width: 32px;
    font-size: 10px;
  }

  #sheet tbody td .cell {
    padding: 1px 4px;
    min-height: 24px;
  }

  /* Sheet tabs */
  .sheet-tabs {
    padding: 3px 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sheet-tabs::-webkit-scrollbar { display: none; }

  .sheet-tab { padding: 3px 10px; font-size: 11px; flex-shrink: 0; }

  /* Status bar */
  .status-bar { padding: 2px 6px; font-size: 10px; }

  /* Modals: full width on mobile */
  .modal { width: 95vw; max-height: 85vh; border-radius: 10px; }
  .modal-lg { width: 95vw; }

  .modal-header { padding: 12px 14px; }
  .modal-header h2 { font-size: 15px; }
  .modal-body { padding: 14px; }

  /* Shortcuts grid: single column */
  .shortcuts-body { grid-template-columns: 1fr; gap: 14px; }

  /* Templates: single column */
  .templates-grid { grid-template-columns: 1fr; }

  /* Chart options: stack */
  .chart-options { flex-direction: column; align-items: stretch; }

  /* Find & replace */
  .find-replace-bar {
    right: 5px;
    left: 5px;
    padding: 6px 8px;
  }

  .find-replace-bar input { width: 100%; min-width: 0; }
  .find-row, .replace-row { flex-wrap: wrap; }

  /* Context menu */
  .context-menu { min-width: 160px; }
  .context-menu button { padding: 9px 12px; font-size: 13px; }

  /* Date picker */
  .date-picker-popup { left: 10px !important; right: 10px; }

  /* Floating charts */
  .floating-chart { width: 90vw !important; }

  /* Donate button */
  .donate-btn { padding: 4px 8px; font-size: 10px; }

  /* Help modal */
  .help-body { max-height: 65vh; }

}

@media (max-width: 400px) {
  .donate-btn { padding: 3px 6px; font-size: 9px; }
}
