:root {
  --bg-base: #0c0517;
  --bg-surface: #140826;
  --bg-card: #190a30;
  --border-subtle: #2d1454;
  --purple-primary: #7e17c7;
  --ink: #ede6fc;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-base);
  color: var(--ink);
}
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* Cell table styling */
.sheet-table th, 
.sheet-table td {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Allow typing and caret navigation inside active cell inputs */
.sheet-cell, 
.sheet-select {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
  cursor: text !important;
}

select, option {
  background-color: #190a30 !important;
  color: #ffffff !important;
}
select:focus { outline: none; }

.sheet-table {
  border-collapse: collapse;
  table-layout: fixed;
}
.sheet-table th, .sheet-table td {
  border: 1px solid var(--border-subtle);
  padding: 0;
  position: relative;
}

/* Cell Selection States */
td.cell-selected {
  background-color: rgba(168, 85, 247, 0.25) !important;
}
td.cell-focused {
  box-shadow: inset 0 0 0 2px #c084fc !important;
  background-color: rgba(168, 85, 247, 0.35) !important;
}
tr.row-selected td {
  background-color: rgba(147, 51, 234, 0.22) !important;
}

/* Single Floating Fill Handle */
.fill-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: #ffffff;
  border: 1.5px solid #7e17c7;
  cursor: crosshair !important;
  z-index: 40;
  border-radius: 1px;
  pointer-events: auto;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  display: none;
}
.fill-handle:hover {
  background-color: #c084fc;
  transform: scale(1.25);
}

/* Fill Drag Preview Range */
td.cell-fill-preview {
  box-shadow: inset 0 0 0 1px #a855f7 !important;
  background-color: rgba(168, 85, 247, 0.18) !important;
}

/* True Cell Input */
.sheet-cell {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 8px 10px;
  color: #ffffff;
  font-size: 12px;
  font-family: inherit;
}
.sheet-cell:hover { background-color: #240f47; }
.sheet-cell:focus {
  background-color: #2a1152 !important;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8) sepia(1) saturate(5) hue-rotate(240deg);
  cursor: pointer;
  opacity: 0.7;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

.sheet-select {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 8px 24px 8px 10px;
  color: #ede6fc;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23caa2ff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
}
.sheet-select:hover { background-color: #240f47; }
.sheet-select:focus { background-color: #2a1152; }

.col-header-delete-btn {
  display: none;
}
th:hover .col-header-delete-btn {
  display: inline-flex;
}

#contextMenu {
  position: fixed;
  z-index: 100;
  background-color: #1c0c38;
  border: 1px solid #441d7d;
  border-radius: 12px;
  box-shadow: 0 16px 38px rgba(0,0,0,0.85);
  min-width: 190px;
  padding: 6px;
}

.filter-popover {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  background-color: #1c0c38;
  border: 1px solid #441d7d;
  border-radius: 12px;
  box-shadow: 0 16px 38px rgba(0,0,0,0.85);
  min-width: 200px;
  padding: 8px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0c0517; }
::-webkit-scrollbar-thumb { background: #3b176d; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #7e17c7; }

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  body * { 
    visibility: hidden !important; 
  }
  
  #printableDocSheet, 
  #printableDocSheet * { 
    visibility: visible !important; 
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  #printableDocSheet {
    position: absolute !important; 
    left: 0 !important; 
    top: 0 !important; 
    width: 100% !important;
    background: #ffffff !important; 
    color: #000000 !important;
    padding: 24px 30px !important; 
    margin: 0 !important;
    border: none !important; 
    box-shadow: none !important;
  }

  /* Force sharp solid borders and visible fills on printed tables */
  #printableDocSheet table {
    border: 1.5px solid #000000 !important;
    border-collapse: collapse !important;
    width: 100% !important;
  }

  #printableDocSheet th {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #000000 !important;
    font-weight: 800 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #printableDocSheet td {
    border: 1px solid #1c1917 !important;
    color: #000000 !important;
  }

  #printableDocSheet .bg-stone-50,
  #printableDocSheet .bg-stone-100 {
    background-color: #f3f4f6 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #printableDocSheet .bg-purple-50 {
    background-color: #f5f3ff !important;
    border: 1.5px solid #581c87 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}