/* ================================================================
   ListFlow – E-commerce Bulk Listing Portal
   Designed & Developed by Gagan Taneja
   Style: Clean Excel-like spreadsheet UI & Ribbon
   ================================================================ */

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
  --border-grid: #b0b8c4;
  /* cell grid lines — stronger, like real Excel */
  --border-light: #d1d5db;
  --border-active: #22c55e;
  /* green for active/selected */
  --bg-header: #e8ecf0;
  /* column header background — slightly darker like Excel */
  --bg-active-col: #f0fdf4;
  /* active column header bg */
  --bg-row-hover: #d6eaf8;
  /* stronger blue hover, clearly visible */
  --bg-row-selected: #eff6ff;
  --bg-row-num: #f1f5f9;
  --text-main: #111827;
  --text-muted: #6b7280;
  --text-tiny: #9ca3af;
  --green-600: #16a34a;
  --green-100: #dcfce7;
  --drag-handle: #d1d5db;
  --drag-handle-hover: #6b7280;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ── Base ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background-color: #f1f5f9;
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* ── Custom Scrollbars ────────────────────────────────────────── */
::-webkit-scrollbar {
  height: 7px;
  width: 7px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── Branding ─────────────────────────────────────────────────── */
.creator-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
  border: 1px solid #a7f3d0;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #065f46;
  letter-spacing: 0.01em;
}

.creator-footer {
  border-top: 1px solid #e2e8f0;
  background-color: #fff;
  padding: 0.4rem 1rem;
}

.creator-highlight {
  font-weight: 700;
  color: #111827;
}

/* ── Toolbar Separator & Labels ──────────────────────────────── */
.toolbar-sep {
  height: 18px;
  width: 1px;
  background-color: #e2e8f0;
}

.toolbar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.03em;
}

.danger-btn {
  color: #e11d48 !important;
  border-color: #fecdd3 !important;
}

.danger-btn:hover {
  background: #fff1f2 !important;
}

/* ── Toolbar Buttons ─────────────────────────────────────────── */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #374151;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  white-space: nowrap;
}

.toolbar-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.toolbar-btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.toolbar-btn-active {
  background: #ecfdf5 !important;
  border-color: #22c55e !important;
  color: #15803d !important;
}

.toolbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 0.25rem;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  cursor: pointer;
  transition: background 0.1s;
}

.toolbar-icon-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.toolbar-icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.select-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid #d1d5db;
  border-radius: 0.3rem;
  background: #fff;
  color: #374151;
  cursor: pointer;
}

.select-sm:focus {
  outline: none;
  border-color: #22c55e;
  box-shadow: 0 0 0 2px #bbf7d0;
}

/* ── Dropdown Menus ───────────────────────────────────────────── */
.dd-menu {
  display: none;
  position: fixed;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 99999 !important;
  padding: 0.35rem 0;
  min-width: 180px;
}

.dd-menu.show {
  display: block !important;
}

.dd-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: #334155;
  background: transparent;
  border: none;
  cursor: pointer;
}

.dd-item:hover {
  background-color: #f0fdf4;
  color: #166534;
}

/* ================================================================
   EXCEL RIBBON TABS & PANELS
   ================================================================ */
#excel-ribbon {
  user-select: none;
}

.ribbon-tab {
  padding: 0.3rem 0.8rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  border-top-left-radius: 0.375rem;
  border-top-right-radius: 0.375rem;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.1s;
}

.ribbon-tab:hover {
  color: #0f172a;
  background: #f8fafc;
}

.ribbon-tab-active {
  color: #15803d !important;
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  border-bottom: 2px solid #ffffff !important;
  margin-bottom: -1px;
}

.ribbon-panel {
  display: flex;
  align-items: stretch;
  padding: 0.35rem 0.75rem;
  background: #ffffff;
  overflow-x: auto;
  gap: 0.75rem;
}

.ribbon-panel.hidden {
  display: none;
}

.ribbon-group {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.25rem;
}

.ribbon-group-title {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}

.ribbon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}

.ribbon-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.ribbon-btn:active {
  background: #e2e8f0;
}

.ribbon-sep-v {
  width: 1px;
  background: #e2e8f0;
  align-self: stretch;
  margin: 0.1rem 0;
}

/* ================================================================
   FORMULA BAR
   ================================================================ */
#formula-bar {
  min-height: 28px;
}

.formula-cell-ref {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  color: #1e293b;
  min-width: 48px;
  text-align: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  padding: 0.1rem 0.3rem;
}

.formula-bar-input {
  width: 100%;
  padding: 0.2rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 0.25rem;
  color: #0f172a;
  outline: none;
}

.formula-bar-input:focus {
  background: #ffffff;
  border-color: #22c55e;
  box-shadow: 0 0 0 2px #dcfce7;
}

/* Formula Autocomplete Dropdown */
.formula-autocomplete-item {
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.formula-autocomplete-item:hover,
.formula-autocomplete-item.selected {
  background-color: #f0fdf4;
}

.formula-fn-name {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #15803d;
}

.formula-fn-desc {
  font-size: 0.65rem;
  color: #64748b;
}

/* ================================================================
   LIVE EXCEL TABLE (Virtual Scrolling Spreadsheet Grid)
   ================================================================ */
.live-excel-table {
  border-collapse: collapse;
  /* solid borders everywhere */
  width: max-content;
  min-width: 100%;
  font-size: 0.75rem;
  table-layout: fixed;
  /* ⚡ Lightning-Fast: Layout is computed once from colgroup, no scanning cells */
}

/* Fixed row heights for precision virtual scrolling */
.live-excel-table thead tr th {
  height: 36px;
  max-height: 36px;
}

.live-excel-table tbody tr:not(.virt-spacer-tr) {
  height: 32px;
  max-height: 32px;
}

/* Virtual scroll top & bottom spacers (invisible height providers) */
.virt-spacer-tr td {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

/* ── Column Header Cells ─────────────────────────────────────── */
.live-excel-table thead tr th {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0;
  border: 1px solid var(--border-grid);
  background: var(--bg-header);
  user-select: none;
  vertical-align: top;
}

/* Drag-handle header */
.th-drag-handle {
  width: 26px !important;
  min-width: 26px !important;
  max-width: 26px !important;
  background: #f1f5f9 !important;
  text-align: center;
  color: var(--drag-handle);
  font-size: 0.9rem;
  font-weight: 900;
  position: sticky !important;
  left: 0;
  z-index: 20 !important;
}

/* Row-number header */
.th-row-num {
  width: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  background: #f1f5f9 !important;
  text-align: center;
  padding: 5px 2px;
  position: sticky !important;
  left: 26px;
  z-index: 20 !important;
  border-right: 2px solid #adb5bd !important;
}

/* ACTIVE column header (green = selected / editable) */
.col-th-active {
  background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%) !important;
  border-bottom: 2px solid var(--border-active) !important;
  cursor: pointer;
  padding: 5px 8px;
  box-sizing: border-box;
}

.col-th-active:hover {
  background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%) !important;
}

/* INACTIVE column header (dimmed = deselected / read-only) */
.col-th-inactive {
  background: #f8fafc !important;
  opacity: 0.72;
  cursor: pointer;
  padding: 5px 8px;
  box-sizing: border-box;
}

.col-th-inactive:hover {
  opacity: 1;
  background: #f1f5f9 !important;
}

/* Column header internals */
.col-name-text {
  font-weight: 700;
  font-size: 0.72rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1f2937;
  margin: 1px 0;
}

.col-status-badge {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 3px;
}

.col-status-active {
  color: #15803d;
  background: #bbf7d0;
}

.col-status-inactive {
  color: #9ca3af;
}

/* ── Data Row Cells ──────────────────────────────────────────── */
.live-excel-table tbody tr td {
  border: 1px solid var(--border-grid);
  /* clear visible grid lines */
  padding: 0;
  background: #ffffff;
  vertical-align: middle;
}

/* Clean Excel Row styling: no distracting row-wide hover, only subtle row number highlight */
.live-excel-table tbody tr:not(.row-selected) .td-row-num:hover {
  background: #e2e8f0 !important;
}

/* Explicitly Selected row styling */
.live-excel-table tbody tr.row-selected > td {
  background: var(--bg-row-selected) !important;
}

.live-excel-table tbody tr.row-selected > .td-drag-handle {
  background: #dbeafe !important;
  color: #0284c7 !important;
}

/* Active column cells */
.cell-active {
  background: #ffffff !important;
}

/* Inactive column cells (dimmed) */
.cell-inactive {
  background: #fafafa !important;
  opacity: 0.6;
}

/* Image cell wrapper */
.img-cell-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 4px;
}

.img-thumb {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 3px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

/* ── Drag Handle Cell (body) ─────────────────────────────────── */
.td-drag-handle {
  width: 26px !important;
  min-width: 26px !important;
  max-width: 26px !important;
  text-align: center;
  cursor: grab;
  background: #f9fafb !important;
  color: var(--drag-handle);
  font-size: 0.85rem;
  font-weight: 900;
  user-select: none;
  border-right: 1px solid #e5e7eb !important;
  position: sticky;
  left: 0;
  z-index: 4;
  transition: color 0.1s, background 0.1s;
}

.td-drag-handle:hover {
  color: var(--drag-handle-hover);
  background: #f1f5f9 !important;
  cursor: grab;
}

.td-drag-handle:active {
  cursor: grabbing;
}

/* ── Row Number Header (head) ─────────────────────────────────── */
.th-row-num {
  width: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  background: #f1f5f9 !important;
  text-align: center;
  padding: 5px 2px;
  position: sticky !important;
  left: 26px;
  z-index: 20 !important;
  border-right: 2px solid #adb5bd !important;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease;
}

.th-row-num:hover {
  background: #e2e8f0 !important;
}

/* ── Row Number Cell (body) ──────────────────────────────────── */
.td-row-num {
  width: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  background: var(--bg-row-num) !important;
  text-align: center;
  padding: 3px 2px;
  border-right: 2px solid #adb5bd !important;
  position: sticky;
  left: 26px;
  z-index: 4;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease, border-color 0.1s ease;
}

.td-row-num:hover:not(.row-num-selected) {
  background: #e2e8f0 !important;
}

.td-row-num.row-num-selected,
tr.row-selected > .td-row-num {
  background: #bae6fd !important;
  border-left: 3px solid #0284c7 !important;
}

.td-row-num.row-num-selected .rn-visual,
tr.row-selected > .td-row-num .rn-visual {
  color: #0369a1 !important;
  font-weight: 800;
}

/* Visual row number (current position) */
.rn-visual {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1;
}

/* Original Excel row number */
.rn-original {
  display: block;
  font-size: 0.58rem;
  font-family: var(--font-mono);
  color: var(--text-tiny);
  line-height: 1;
  margin-top: 1px;
}

/* When original ≠ visual (row was reordered) */
.rn-original-changed {
  color: #f59e0b;
  font-weight: 700;
}

/* Displacement Directional Tags */
.rn-tag {
  display: inline-block;
  font-size: 0.58rem;
  font-family: var(--font-mono);
  line-height: 1.1;
  padding: 1px 3px;
  border-radius: 3px;
  margin-top: 1px;
  white-space: nowrap;
}

.rn-tag-orig {
  color: #94a3b8;
  background: transparent;
}

.rn-tag-up {
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  font-weight: 700;
}

.rn-tag-down {
  color: #9a3412;
  background: #ffedd5;
  border: 1px solid #fdba74;
  font-weight: 700;
}

/* Reordered Row Markers on Drag Handle */
tr.row-reordered>td.td-drag-handle {
  border-left: 3px solid #f59e0b !important;
  background: #fffbeb !important;
}

tr.row-reordered.row-moved-up>td.td-drag-handle {
  border-left: 3px solid #10b981 !important;
  background: #ecfdf5 !important;
}

tr.row-reordered.row-moved-down>td.td-drag-handle {
  border-left: 3px solid #f97316 !important;
  background: #fff7ed !important;
}

/* ── CELL INPUT ──────────────────────────────────────────────── */
.cell-input {
  width: 100%;
  height: 30px;
  min-width: 60px;
  padding: 2px 6px;
  font-size: 0.74rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: transparent;
  border: 1.5px solid transparent;
  color: var(--text-main);
  outline: none;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-input:hover:not([readonly]) {
  background: #fafafa;
  border-color: #e5e7eb;
  border-radius: 2px;
}

.cell-input:focus:not([readonly]) {
  background: #fffde7 !important;
  /* Excel-style yellow highlight on active cell */
  border-color: #1565c0 !important;
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.25);
  z-index: 2;
  position: relative;
}

.cell-input[readonly] {
  color: var(--text-muted);
  cursor: default;
}

/* Cell stays highlighted when formula bar has focus (formula-bar-active class) */
.cell-formula-bar-active {
  background: #fffde7 !important;
  /* same yellow as :focus */
  border: 2px solid #1565c0 !important;
  border-radius: 2px;
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.2), inset 0 0 0 1px rgba(21, 101, 192, 0.15) !important;
  z-index: 2;
  position: relative;
  outline: none;
}

/* Formula-computed cells — subtle visual hint (light purple tint like Excel) */
.formula-cell {
  font-style: italic;
  color: #4338ca !important;
}

/* ── COMPACT ROW MODE ────────────────────────────────────────── */
.compact-mode .cell-input {
  padding: 2px 4px !important;
  font-size: 0.7rem !important;
}

.compact-mode .td-row-num {
  padding: 1px 2px !important;
}

.compact-mode .img-thumb {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
}

/* ================================================================
   EXCEL MULTI-CELL RANGE SELECTION & HIGHLIGHT
   ================================================================ */
td.cell-in-range {
  background-color: #dbeafe !important;
  /* Soft Excel selection blue */
}

td.cell-in-range .cell-input:not(:focus) {
  background-color: transparent !important;
}

td.range-top {
  border-top: 2px solid #2563eb !important;
}

td.range-bottom {
  border-bottom: 2px solid #2563eb !important;
}

td.range-left {
  border-left: 2px solid #2563eb !important;
}

td.range-right {
  border-right: 2px solid #2563eb !important;
}

/* ================================================================
   ROW STATES
   ================================================================ */

/* Checkbox-selected rows */
.row-selected>td {
  background: var(--bg-row-selected) !important;
}

/* Row being dragged (multi-row or single row) */
.row-dragging>td {
  background: #eff6ff !important;
  opacity: 0.45 !important;
}

/* Industry-Grade Insertion Drop Indicator — Top */
.drag-over-top>td {
  border-top: 3.5px solid #2563eb !important;
  background: #eff6ff !important;
}

.drag-over-top>td:first-child {
  position: relative;
}

.drag-over-top>td:first-child::before {
  content: "●";
  position: absolute;
  top: -8px;
  left: 1px;
  color: #2563eb;
  font-size: 14px;
  line-height: 1;
  z-index: 30;
}

/* Industry-Grade Insertion Drop Indicator — Bottom */
.drag-over-bottom>td {
  border-bottom: 3.5px solid #2563eb !important;
  background: #eff6ff !important;
}

.drag-over-bottom>td:first-child {
  position: relative;
}

.drag-over-bottom>td:first-child::after {
  content: "●";
  position: absolute;
  bottom: -8px;
  left: 1px;
  color: #2563eb;
  font-size: 14px;
  line-height: 1;
  z-index: 30;
}

/* Smooth Flash Animation when row is dropped */
@keyframes rowDropHighlight {
  0% {
    background-color: #86efac !important;
  }

  50% {
    background-color: #dcfce7 !important;
  }

  100% {
    background-color: transparent;
  }
}

.row-drop-flash>td {
  animation: rowDropHighlight 1.2s ease-out;
}

/* ── Google Sheets Style Cloud Auto-Save Pill ─────────────────── */
.cloud-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.65rem;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cloud-status-pill.saved {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.cloud-status-pill.saved:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.cloud-status-pill.saving {
  background: #fefce8;
  color: #a16207;
  border-color: #fde047;
  animation: pulseSaving 1.5s infinite;
}

.cloud-status-pill.local {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

@keyframes pulseSaving {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.55;
  }
}

/* ================================================================
   FREEZE PANE (Multi-Column Sticky Freeze)
   ================================================================ */

.freeze-col-th,
.freeze-first-col-th {
  position: sticky !important;
  z-index: 15 !important;
  background: #f8fafc !important;
}

.freeze-col-td,
.freeze-first-col-td {
  position: sticky !important;
  z-index: 3 !important;
  background: #ffffff !important;
}

/* Accent divider on the right of the last frozen column */
.freeze-col-last {
  border-right: 2px solid #0284c7 !important;
  box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.16) !important;
}

/* ================================================================
   COLUMN RESIZING (Google Sheets / Excel Drag border)
   ================================================================ */
.col-th-active {
  position: relative !important;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -5px;
  width: 10px;
  height: 100%;
  cursor: col-resize !important;
  z-index: 50;
  user-select: none;
  touch-action: none;
}

.col-resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  right: 4px;
  width: 2px;
  height: 100%;
  background: transparent;
  transition: background 0.1s ease;
  pointer-events: none;
}

.col-resize-handle:hover::after,
.col-resize-handle.resizing::after {
  background: #0284c7 !important;
  width: 3px;
  right: 3px;
}

body.col-resizing-active,
body.col-resizing-active * {
  cursor: col-resize !important;
  user-select: none !important;
}

/* ================================================================
   MODALS (Find & Replace, Fill Series)
   ================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 0.9rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.2rem;
}

.modal-close-btn:hover {
  color: #0f172a;
}

.modal-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.25rem;
}

.modal-input {
  width: 100%;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  outline: none;
}

.modal-input:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px #dcfce7;
}

/* ================================================================
   TOAST NOTIFICATION
   ================================================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  z-index: 9999;
  background: #0f172a;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #1e293b;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 360px;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* ================================================================
   KBD HINT
   ================================================================ */
.kbd-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  border-radius: 3px;
  color: #334155;
}

/* ================================================================
   SCROLL ENGINE OPTIMIZATIONS (Hardware accelerated 60fps)
   ================================================================ */
#table-scroll-wrap {
  overflow-anchor: none;
  scroll-behavior: auto !important;
  overscroll-behavior: contain;
}

/* Eliminate hover recalculations during active scrolling */
.is-scrolling,
.is-scrolling * {
  pointer-events: none !important;
}

/* ================================================================
   SCROLLBAR (table area specific)
   ================================================================ */
#table-scroll-wrap::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

#table-scroll-wrap::-webkit-scrollbar-track {
  background: #f1f5f9;
}

#table-scroll-wrap::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

#table-scroll-wrap::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

#table-scroll-wrap::-webkit-scrollbar-corner {
  background: #f1f5f9;
}

/* ================================================================
   CELL DATA VALIDATION DROPDOWN STYLING
   ================================================================ */
.cell-dropdown-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.cell-dropdown-wrap .cell-input {
  padding-right: 22px !important;
}

.cell-dropdown-btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  border-radius: 2px;
  opacity: 0.6;
  transition: all 0.1s ease;
  user-select: none;
}

.cell-dropdown-wrap:hover .cell-dropdown-btn,
.cell-dropdown-wrap:focus-within .cell-dropdown-btn {
  opacity: 1;
  background: #f1f5f9;
  color: #0f172a;
  border-color: #94a3b8;
}

.cell-dropdown-btn:hover {
  background: #e2e8f0 !important;
  color: #15803d !important;
  border-color: #22c55e !important;
}

/* Floating Cell Dropdown Popup */
#cell-dropdown-popup {
  position: fixed;
  z-index: 99999;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  max-height: 260px;
  width: 220px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#cell-dropdown-popup.hidden {
  display: none !important;
}

.cell-dropdown-search {
  padding: 6px 8px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.cell-dropdown-search input {
  width: 100%;
  padding: 4px 6px;
  font-size: 11px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  outline: none;
  font-family: inherit;
}

.cell-dropdown-search input:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px #dcfce7;
}

.cell-dropdown-list {
  overflow-y: auto;
  max-height: 210px;
}

.cell-dropdown-item {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  transition: background 0.1s;
}

.cell-dropdown-item:hover,
.cell-dropdown-item.active {
  background: #f0fdf4;
  color: #15803d;
  font-weight: 600;
}

.col-dropdown-indicator {
  display: inline-block;
  margin-left: 2px;
  font-size: 8px;
  color: #15803d;
  background: #dcfce7;
  padding: 1px 3px;
  border-radius: 2px;
  vertical-align: middle;
}

/* ── Preset Pills & Column Manager ───────────────────────────── */
.preset-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 9999px;
  border-width: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.preset-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.preset-pill:active {
  transform: translateY(0);
}

.col-mgr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.col-mgr-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.col-mgr-item.active {
  background: #f0fdf4;
  border-color: #86efac;
}