.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.analytics-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  opacity: 0.85;
}

.analytics-field input,
.analytics-field select {
  width: 100%;
}

.analytics-actions .btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.analytics-hint {
  margin-top: 10px;
  font-size: 12px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(0,0,0,0.02);
}

.kpi-label {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.7;
}

.kpi-value {
  font-size: 22px;
  font-weight: 900;
  margin-top: 4px;
}

.table-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.analytics-table th {
  cursor: pointer;
  user-select: none;
}

@media (max-width: 900px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- Analytics Layout Polish ---- */

.analytics-container .card {
  margin-bottom: 18px;
}

#tsFilters strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.filters-grid input,
.filters-grid select {
  min-width: 160px;
}

/* Results table improvements */
.analytics-table th {
  position: sticky;
  top: 0;
  background: #0d4a86;
  z-index: 2;
}

.analytics-table tr:hover {
  background: #a2bff8;
  color: #111827;
}

/* Section separators */
#tsResults h3 {
  margin-bottom: 10px;
}

/* Meta text */
#resultsMeta {
  font-size: 12px;
  color: #6b7280;
}

/* ================================
   Analytics Modal (Scoped Fix)
   ================================ */

/* Modal backdrop already inline-styled in JS */

/* =========================================
   Analytics Modal – FULL Scoped Readability
   Applies to: Employee, Payroll, Charts, Cost
   ========================================= */

/* Modal panel */
#tsModal > div {
  background: #ffffff;
  color: #111827;
}

/* All text inside analytics modal */
#tsModal,
#tsModal * {
  color: #111827;
}

/* Headings */
#tsModal strong,
#tsModal h3 {
  color: #111827;
}

/* Muted text */
#tsModal .muted {
  color: #6b7280;
}

/* Tables inside modal */
#tsModal table {
  background: #ffffff;
  border-collapse: collapse;
}

#tsModal th {
  background: #f3f4f6;
  font-weight: 600;
}

#tsModal th,
#tsModal td {
  border-bottom: 1px solid #e5e7eb;
  padding: 6px 8px;
}

/* Hover rows */
#tsModal tr:hover td {
  background: #f9fafb;
}

/* Inputs (payroll rates) */
#tsModal input {
  background: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 4px 6px;
}

/* Buttons */
#tsModal button {
  background: #f3f4f6;
  color: #111827;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}

#tsModal button:hover {
  background: #e5e7eb;
}

/* Horizontal rules */
#tsModal hr {
  border: none;
  border-top: 1px solid #d1d5db;
}

/* Charts canvas readability */
#tsModal canvas {
  background: #ffffff;
}

/* Heatmap table cells */
#tsModal td[style*="background"] {
  color: inherit;
}

/* =========================================
   Analytics Modal – Color & Clarity Enhancer
   Scoped to analytics only
   ========================================= */

/* Section titles inside modal */
#tsModal strong {
  color: #1e40af;               /* subtle blue */
  font-weight: 700;
}

/* Modal main title */
#tsModal #tsModalTitle {
  color: #1e3a8a;
  font-size: 16px;
}

/* Tables: header row */
#tsModal th {
  background: #e5edff;          /* soft blue tint */
  color: #1e3a8a;
}

/* Totals / summary emphasis */
#tsModal td:last-child,
#tsModal .total,
#tsModal .hours,
#tsModal .cost {
  font-weight: 600;
  color: #0f172a;
}

/* Highlight summary rows (payroll & cost tables) */
#tsModal tr:last-child td {
  background: #f8fafc;
}

/* Payroll rate inputs – FIX VISIBILITY */
#tsModal input[type="number"] {
  background: #ffffff !important;
  color: #111827 !important;
  font-weight: 600;
}

/* Placeholder text */
#tsModal input::placeholder {
  color: #9ca3af;
}

/* Focus state for inputs */
#tsModal input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Buttons: subtle primary accent */
#tsModal button {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e3a8a;
}

#tsModal button:hover {
  background: #dbeafe;
}

/* Charts canvas border & contrast */
#tsModal canvas {
  border: 1px solid #c7d2fe;
  background: #ffffff;
}

/* Heatmap label row */
#tsModal table th:first-child {
  background: #dbeafe;
}

/* Payroll totals / cost emphasis */
#tsModal td[style*="font-weight:800"],
#tsModal td[style*="font-weight:700"] {
  color: #065f46; /* muted green for totals */
}

/* ============================
   Analytics Action Bar
============================ */

.analytics-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.actions-left,
.actions-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Base button */
.action-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #d0d5dd;
  background: #f9fafb;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: #eef2f7;
}

/* Primary action buttons */
.action-btn.primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.action-btn.primary:hover {
  background: #1e40af;
}
/* =========================================
   Analytics Filters – Readability Fix
   Scoped, safe, non-breaking
   ========================================= */

.analytics-container select,
.analytics-container input {
  background-color: #ffffff;
  color: #111827;
  border: 1px solid #d1d5db;
}

/* Dropdown options */
.analytics-container select option {
  background-color: #ffffff;
  color: #111827;
}

/* Labels */
.analytics-container label,
.analytics-container strong {
  color: #111827;
}

/* Focus state (matches app style) */
.analytics-container select:focus,
.analytics-container input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Placeholder text */
.analytics-container input::placeholder {
  color: #030303;
}
/* =========================================
   Analytics – Employee Totals Readability Fix
   (KPIs, totals, summaries)
   ========================================= */

.kpi,
.kpi *,
.analytics-table,
.analytics-table * {
  color: #111827;
}

/* KPI cards background */
.kpi {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}

/* KPI labels & values */
.kpi-label {
  color: #475569;
}

.kpi-value {
  color: #dce1ec;
}

/* Tables outside modal */
.analytics-table {
  background: #0a1224;
}

.analytics-table th {
  background: #e5edff;
  color: #1e3a8a;
}

.analytics-table td {
  color: #eaebee;
}

/* Hover clarity */
.analytics-table tr:hover td {
  background: #eef2ff;
  color: #dee0e4;
}
