/* =====================================================
   GLOBAL TABLE STYLES – Shared across P&L + Planning tabs
   ===================================================== */

/* Wrapper – enables horizontal scroll */
.plan-table-wrap,
#plWrap {
  overflow: auto;
  max-height: 75vh;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: white;
}

/* Base table – shared */
.plan-table,
#plTable {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1000px;
  font-size: 0.875rem; /* text-sm */
}

/* Ultra-tight, professional padding (~1mm vertical) */
.plan-table th,
.plan-table td,
#plTable th,
#plTable td {
  white-space: nowrap;
  padding: 3px 8px;           /* exactly as requested: 3px top/bottom, 8px left/right */
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
}

/* Left-align first column (labels) */
.plan-table th:first-child,
.plan-table td:first-child,
#plTable th:first-child,
#plTable td:first-child {
  text-align: left;
  font-weight: 500;
}

/* Sticky header */
.plan-table thead th,
#plTable thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f9fafb;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
  font-weight: 600;
}

/* Sticky first column – used by both P&L and planning tabs */
.plan-table .sticky-col,
#plTable .sticky-col {
  position: sticky;
  left: 0;
  z-index: 9;
  background: #ffffff;
  min-width: 140px;
  font-weight: 500;
  box-shadow: 1px 0 0 rgba(0,0,0,0.06);
}

/* Sticky second column – only used in planning tabs (Rate, Unit, etc.) */
.plan-table .sticky-col-2 {
  position: sticky;
  left: 14rem; /* adjust if your first column is wider/narrower */
  z-index: 9;
  background: #ffffff;
  min-width: 100px;
  box-shadow: 1px 0 0 rgba(0,0,0,0.06);
}

/* Corner cells – header + sticky column(s) */
.plan-table thead th.sticky-col,
.plan-table thead th.sticky-col-2,
#plTable thead th.sticky-col {
  z-index: 20;
  background: #f1f5f9;
}

/* Row hover & zebra striping */
.plan-table tbody tr:hover,
#plTable tbody tr:hover {
  background-color: #e5e7eb !important;
}

.plan-table tbody tr.pl-row:nth-child(odd),
#plTable tbody tr.pl-row:nth-child(odd) {
  background: #f9fafb;
}

/* Summary / total row emphasis */
.plan-table tbody tr.summary-row,
#plTable tbody tr.summary-row {
  border-top: 2px solid #94a3b8;
  background: #f3f4f6 !important;
  font-weight: 700;
}

/* Profit & Margin rows (P&L only) */
#plTable tbody tr.profit-row,
.plan-table tbody tr.profit-row {
  background-color: #ecfdf5 !important;
  font-weight: 600;
  color: #166534;
}

#plTable tbody tr.margin-row,
.plan-table tbody tr.margin-row {
  background-color: #eff6ff !important;
  font-weight: 600;
  color: #1d4ed8;
}

/* Subtle alternating month column background */
.plan-table .month-col:nth-child(odd),
#plTable thead th:nth-child(n+3):nth-child(odd),
#plTable tbody td:nth-child(n+3):nth-child(odd) {
  background-color: #f8fafc;
}

/* Sticky right column – Year Total (P&L + planning) */
#plTable th:last-child,
#plTable td:last-child,
.plan-table th:last-child,
.plan-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 8;
  background-color: #f8fafc;
  font-weight: 700;
  box-shadow: -2px 0 4px -2px rgba(0, 0, 0, 0.1);
}

#plTable thead th:last-child,
.plan-table thead th:last-child {
  z-index: 11;
  background: #e2e8f0;
}

/* Generic row striping for planning tables */
tbody tr.pl-row:nth-child(even) td:not(.sticky-col) {
  background-color: #f8fafc; /* Tailwind's slate-50 */
}

/* Shared zebra striping and totals row for planning grids */
.pl-row:nth-child(odd) td {
  background-color: #ffffff;
}

.pl-row:nth-child(even) td {
  background-color: #f9fafb; /* light gray, same feel as Subs tab */
}

.summary-row td {
  background-color: #f3f4f6; /* slightly darker for totals */
  border-top: 1px solid #e5e7eb;
  font-weight: 600;
}
