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

/* ═══════════════════════════════════════
   LIGHT THEME (Google Sheets)
   ═══════════════════════════════════════ */
[data-theme="light"] {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-raised: #f1f3f4;
  --surface-hover: #e8eaed;
  --toolbar-bg: #ffffff;
  --border: #dadce0;
  --border-strong: #c0c0c0;
  --text: #202124;
  --text-secondary: #5f6368;
  --text-tertiary: #80868b;
  --text-on-primary: #ffffff;
  --primary: #188038;
  --primary-light: #e6f4ea;
  --primary-hover: #1a7431;
  --header-bg: #f8f9fa;
  --header-text: #202124;
  --row-alt: #f8f9fb;
  --row-hover: #e8f0fe;
  --cell-border: #e2e2e2;
  --cell-border-strong: #c0c0c0;
  --selected-bg: #e8f0fe;
  --selected-border: #1a73e8;
  --success: #188038;
  --danger: #d93025;
  --shadow-sm: 0 1px 2px rgba(60,64,67,0.1);
  --shadow-md: 0 1px 3px rgba(60,64,67,0.15), 0 4px 8px rgba(60,64,67,0.1);
  --shadow-lg: 0 1px 3px rgba(60,64,67,0.15), 0 8px 24px rgba(60,64,67,0.12);
  --upload-border: #dadce0;
  --upload-bg: #ffffff;
  --pill-bg: #ffffff;
  --pill-border: #dadce0;
  --pill-active-bg: #e6f4ea;
  --pill-active-border: #188038;
  --pill-active-text: #188038;
  --toggle-bg: #dadce0;
  --toggle-active: #188038;
  --btn-secondary-bg: #ffffff;
  --btn-secondary-border: #dadce0;
  --btn-secondary-text: #3c4043;
  --btn-primary-bg: #188038;
  --btn-primary-text: #ffffff;
  --scrollbar-track: #f1f3f4;
  --scrollbar-thumb: #dadce0;
  --scrollbar-thumb-hover: #bdc1c6;
  --toast-bg: #323232;
  --toast-text: #ffffff;
  --row-num-bg: #f8f9fa;
  --row-num-text: #80868b;
  --formula-bg: #ffffff;
}

/* ═══════════════════════════════════════
   DARK THEME
   ═══════════════════════════════════════ */
[data-theme="dark"] {
  --bg: #1e1e1e;
  --surface: #262626;
  --surface-raised: #2d2d2d;
  --surface-hover: #353535;
  --toolbar-bg: #2d2d2d;
  --border: #3c3c3c;
  --border-strong: #4a4a4a;
  --text: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-tertiary: #6b7075;
  --text-on-primary: #ffffff;
  --primary: #81c995;
  --primary-light: rgba(129,201,149,0.12);
  --primary-hover: #6bbf82;
  --header-bg: #2d2d2d;
  --header-text: #e8eaed;
  --row-alt: rgba(255,255,255,0.02);
  --row-hover: rgba(138,180,248,0.08);
  --cell-border: #3c3c3c;
  --cell-border-strong: #4a4a4a;
  --selected-bg: rgba(138,180,248,0.12);
  --selected-border: #8ab4f8;
  --success: #81c995;
  --danger: #f28b82;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.4), 0 4px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 1px 3px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.35);
  --upload-border: #4a4a4a;
  --upload-bg: #262626;
  --pill-bg: #2d2d2d;
  --pill-border: #4a4a4a;
  --pill-active-bg: rgba(129,201,149,0.12);
  --pill-active-border: #81c995;
  --pill-active-text: #81c995;
  --toggle-bg: #4a4a4a;
  --toggle-active: #81c995;
  --btn-secondary-bg: #2d2d2d;
  --btn-secondary-border: #4a4a4a;
  --btn-secondary-text: #e8eaed;
  --btn-primary-bg: #81c995;
  --btn-primary-text: #1e1e1e;
  --scrollbar-track: #2d2d2d;
  --scrollbar-thumb: #4a4a4a;
  --scrollbar-thumb-hover: #5f6368;
  --toast-bg: #e8eaed;
  --toast-text: #1e1e1e;
  --row-num-bg: #2d2d2d;
  --row-num-text: #6b7075;
  --formula-bg: #2d2d2d;
}

html { font-size: 14px; }
body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

/* ─── Top Bar (Google Sheets style) ─── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.topbar-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-icon svg { width: 28px; height: 28px; }

.topbar-title-area {
  flex: 1;
  min-width: 0;
}
.topbar-title {
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.3;
}
.topbar-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

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

/* Theme toggle */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s ease;
}
.theme-toggle:hover {
  background: var(--surface-hover);
}
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-moon,
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ─── Main Layout ─── */
.main-content {
  padding: 16px 20px 24px;
  max-width: 100%;
}

/* ─── Upload Zone ─── */
.upload-zone {
  border: 2px dashed var(--upload-border);
  border-radius: 8px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--upload-bg);
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone.has-file {
  padding: 14px 20px;
  border-style: solid;
  border-width: 1px;
  border-color: var(--border);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-tertiary);
}
.upload-zone:hover .upload-icon,
.upload-zone.dragover .upload-icon { color: var(--primary); }

.upload-label {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.upload-label strong {
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
}
.upload-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.file-info-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.file-icon {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-icon svg { width: 18px; height: 18px; color: var(--primary); }
.file-name {
  font-family: 'Roboto Mono', monospace;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}
.file-remove {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  flex-shrink: 0;
}
.file-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(217,48,37,0.04);
}

#file-input { display: none; }

/* ─── Toolbar (below upload) ─── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--toolbar-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  transition: background 0.25s ease, border-color 0.25s ease;
}

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

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
}

.separator-pills {
  display: flex;
  gap: 2px;
}
.sep-pill {
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: 'Roboto', sans-serif;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
}
.sep-pill:hover {
  background: var(--surface-hover);
}
.sep-pill.active {
  background: var(--pill-active-bg);
  border-color: var(--pill-active-border);
  color: var(--pill-active-text);
  font-weight: 500;
}

.custom-sep-input {
  width: 48px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  font-family: 'Roboto Mono', monospace;
  color: var(--text);
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease;
}
.custom-sep-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.custom-sep-input::placeholder {
  color: var(--text-tertiary);
}

/* Toggle switch */
.header-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  width: 34px;
  height: 20px;
  background: var(--toggle-bg);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s ease;
}
.toggle-track.on {
  background: var(--toggle-active);
}
.toggle-thumb {
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-track.on .toggle-thumb {
  left: 16px;
}

/* ─── Search Input ─── */
.search-group {
  position: relative;
  flex: 1;
  max-width: 320px;
  min-width: 140px;
}
.search-icon {
  width: 16px;
  height: 16px;
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
.search-input {
  width: 100%;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: 4px;
  padding: 5px 28px 5px 28px;
  font-size: 12px;
  font-family: 'Roboto', sans-serif;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.search-input::placeholder {
  color: var(--text-tertiary);
}
.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 2px;
}
.search-clear:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.toolbar-spacer { flex: 1; }

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--btn-secondary-border);
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow-sm);
}
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}
[data-theme="dark"] .btn-primary:hover {
  background: #6bbf82;
  border-color: #6bbf82;
}

/* ─── Spreadsheet Container ─── */
.spreadsheet-wrapper {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: background 0.25s ease, border-color 0.25s ease;
}

/* ─── Formula Bar ─── */
.formula-bar {
  display: flex;
  align-items: center;
  height: 32px;
  border-bottom: 1px solid var(--border);
  background: var(--formula-bg);
  transition: background 0.25s ease;
}
.formula-bar-label {
  width: 56px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  border-right: 1px solid var(--border);
  background: var(--header-bg);
  font-family: 'Roboto Mono', monospace;
}
.formula-bar-content {
  flex: 1;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'Roboto Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-scroll {
  overflow: auto;
  max-height: 70vh;
}

.table-scroll::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
.table-scroll::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border: 3px solid var(--scrollbar-track);
  border-radius: 6px;
}
.table-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}
.table-scroll::-webkit-scrollbar-corner {
  background: var(--scrollbar-track);
}

/* ─── The Data Table (Spreadsheet grid) ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Column headers — like Google Sheets */
.data-table th {
  background: var(--header-bg);
  font-weight: 500;
  font-size: 12px;
  color: var(--header-text);
  padding: 0 24px 0 8px;
  height: 28px;
  text-align: left;
  border-bottom: 1px solid var(--cell-border-strong);
  border-right: 1px solid var(--cell-border);
  white-space: nowrap;
  position: relative;
  transition: background 0.25s ease;
  font-family: 'Roboto', sans-serif;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table th:last-child {
  border-right: none;
}

/* Sortable column headers */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table th.sortable:hover {
  background: var(--surface-hover);
}
.data-table th.sort-asc,
.data-table th.sort-desc {
  color: var(--primary);
  background: var(--primary-light);
}

/* Column filter button in header */
.col-filter-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 2px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.col-filter-btn svg {
  width: 12px;
  height: 12px;
}
.data-table th:hover .col-filter-btn,
.col-filter-btn.active {
  opacity: 1;
}
.col-filter-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.col-filter-btn.active {
  color: var(--primary);
}
.data-table th.has-filter {
  background: var(--primary-light);
}

/* Column letter label (A, B, C...) */
.col-letter {
  display: inline-block;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 400;
  margin-left: 4px;
}

/* Resize handle on column headers */
.data-table th::after {
  content: '';
  position: absolute;
  right: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  cursor: col-resize;
}
.data-table th:hover::after {
  background: var(--primary);
  border-radius: 2px;
}

/* Row number column — fixed left like Google Sheets */
.data-table th.row-num-col,
.data-table td.row-num-col {
  width: 46px;
  min-width: 46px;
  max-width: 46px;
  text-align: center;
  color: var(--row-num-text);
  font-size: 11px;
  font-weight: 400;
  background: var(--row-num-bg);
  border-right: 1px solid var(--cell-border-strong);
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 0;
  transition: background 0.25s ease;
}
.data-table th.row-num-col {
  z-index: 3;
  background: var(--header-bg);
}

/* Data cells — spreadsheet grid */
.data-table td {
  padding: 0 8px;
  height: 24px;
  border-bottom: 1px solid var(--cell-border);
  border-right: 1px solid var(--cell-border);
  color: var(--text);
  font-family: 'Roboto Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.05s ease;
}
.data-table td:last-child {
  border-right: none;
}

.data-table tbody tr:nth-child(even) td {
  background: var(--row-alt);
}
.data-table tbody tr:nth-child(even) td.row-num-col {
  background: var(--row-num-bg);
}
.data-table tbody tr:hover td {
  background: var(--row-hover);
}
.data-table tbody tr:hover td.row-num-col {
  background: var(--surface-hover);
}

/* Selected cell */
.data-table td.selected {
  outline: 2px solid var(--selected-border);
  outline-offset: -1px;
  background: var(--selected-bg) !important;
}

/* ─── Status / Sheet Bar ─── */
.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 36px;
  border-top: 1px solid var(--border);
  background: var(--header-bg);
  font-size: 12px;
  color: var(--text-secondary);
  transition: background 0.25s ease;
}

.sheet-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
}
.sheet-tab {
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
  background: transparent;
  cursor: default;
  white-space: nowrap;
}
.sheet-tab.active {
  background: var(--surface);
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.sheet-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'Roboto Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary);
}
.sheet-stats .stat-label {
  color: var(--text-tertiary);
}
.sheet-stats .stat-value {
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Pagination ─── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  padding: 3px 8px;
  font-size: 11px;
  font-family: 'Roboto', sans-serif;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
}
.page-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.page-info {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 0 6px;
  font-family: 'Roboto Mono', monospace;
}

/* ─── Filter Dropdown ─── */
.filter-dropdown {
  position: fixed;
  z-index: 50;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 360px;
  overflow: hidden;
}
.filter-search {
  margin: 8px 8px 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--pill-bg);
  color: var(--text);
  font-size: 12px;
  font-family: 'Roboto', sans-serif;
  outline: none;
}
.filter-search:focus {
  border-color: var(--primary);
}
.filter-search::placeholder {
  color: var(--text-tertiary);
}
.filter-actions {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.filter-action-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 11px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
}
.filter-action-btn:hover {
  background: var(--primary-light);
}
.filter-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  max-height: 220px;
}
.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.1s ease;
}
.filter-item:hover {
  background: var(--surface-hover);
}
.filter-item input[type="checkbox"] {
  accent-color: var(--primary);
  flex-shrink: 0;
}
.filter-item-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Roboto Mono', monospace;
  font-size: 11px;
}
.filter-more {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
}
.filter-apply-btn {
  margin: 4px 8px 8px;
  padding: 6px 12px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
.filter-apply-btn:hover {
  background: var(--primary-hover);
}

/* ─── Active Filters Bar ─── */
.active-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--toolbar-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--primary);
  white-space: nowrap;
}
.filter-chip-label {
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-chip-remove {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 50%;
  opacity: 0.7;
}
.filter-chip-remove:hover {
  opacity: 1;
  background: rgba(0,0,0,0.06);
}
[data-theme="dark"] .filter-chip-remove:hover {
  background: rgba(255,255,255,0.1);
}
.filter-clear-all {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 11px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  margin-left: 4px;
}
.filter-clear-all:hover {
  color: var(--danger);
}

/* ─── Search Highlight ─── */
mark.search-highlight {
  background: #fde293;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}
[data-theme="dark"] mark.search-highlight {
  background: rgba(253, 226, 147, 0.3);
  color: #fde293;
}

/* ─── Hidden ─── */
.hidden { display: none !important; }

/* ─── Animations ─── */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeSlideIn 0.25s ease forwards;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--toast-bg);
  border-radius: 8px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--toast-text);
  z-index: 100;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  font-family: 'Google Sans', 'Roboto', sans-serif;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast-icon {
  width: 18px;
  height: 18px;
  color: var(--success);
}
[data-theme="dark"] .toast-icon {
  color: #81c995;
}

/* ─── Feature Tour ─── */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
[data-theme="dark"] .tour-overlay {
  background: rgba(0, 0, 0, 0.6);
}
.tour-overlay.visible {
  display: flex;
}

.tour-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 480px;
  max-width: 92vw;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.tour-slides {
  position: relative;
  overflow: hidden;
}

.tour-slide {
  display: none;
  padding: 36px 32px 24px;
  text-align: center;
  animation: tourSlideIn 0.3s ease;
}

.tour-slide.active {
  display: block;
}

@keyframes tourSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.tour-icon {
  margin-bottom: 16px;
  color: var(--primary);
}
.tour-icon svg {
  width: 44px;
  height: 44px;
}

.tour-heading {
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 10px;
  color: var(--text);
}

.tour-text {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 380px;
  margin: 0 auto 16px;
}

.tour-hint {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 auto;
  max-width: 400px;
}

.tour-hint code {
  font-family: 'Roboto Mono', monospace;
  font-size: 11.5px;
  color: var(--primary);
  word-break: break-word;
}

.tour-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
}

.tour-dots {
  display: flex;
  gap: 6px;
}

.tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.2s;
  cursor: pointer;
}

.tour-dot.active {
  background: var(--primary);
  transform: scale(1.25);
}

.tour-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tour-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border: none;
  border-radius: 4px;
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tour-btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}

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

.tour-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.tour-btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.tour-skip {
  color: var(--text-tertiary) !important;
  font-size: 11px !important;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .topbar { padding: 8px 12px; }
  .main-content { padding: 12px; }
  .toolbar { gap: 8px; padding: 6px 8px; }
  .upload-zone { padding: 32px 16px; }
  .action-buttons { gap: 4px; }
  .btn { padding: 6px 10px; font-size: 12px; }
  .sheet-stats { display: none; }
}
