/* ============================================================
   08 · DATA TABLE & REPORT STUDIO
   AutoCAD Model Space Linework, Tabular Alignments, & RAG Highlights
   ============================================================ */

/* ============================================================
   1. PRIMARY PORTAL DATA TABLE
   ============================================================ */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: var(--cad-line);
  border-radius: var(--radius-xs);
  background: var(--cad-panel);
  box-sizing: border-box;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-family: var(--font-body);
  font-size: 13px;
}

/* Headers */
.portal-table th {
  background: var(--cad-subpanel);
  color: var(--text-muted);
  padding: 10px 14px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--cad-border);
  white-space: nowrap;
}

/* Body Cells */
.portal-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--cad-border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.portal-table tbody tr {
  transition: background-color 0.12s ease;
}

.portal-table tbody tr:hover { 
  background: var(--cad-hover); 
}

/* Typography & Tabular Alignment */
.font-bold { 
  font-weight: 700; 
}

.num-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

/* Ghosted Zero State */
.num-cell.num-cell-zero {
  color: var(--text-muted) !important;
  font-weight: 500;
  opacity: 0.45;
}

/* CAD Block Tag for Regions */
.region-pill {
  display: inline-block;
  background: var(--cad-subpanel);
  border: 1px solid var(--cad-border);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: var(--radius-none);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* Site Links */
.site-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.12s ease;
}

.site-link:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Sorting Controls */
.sortable-header {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease;
}

.sortable-header:hover { 
  background: var(--cad-hover); 
  color: var(--text-primary); 
}

.sort-indicator {
  font-size: 9px;
  margin-left: 6px;
  color: var(--text-muted);
  display: inline-block;
}

.sortable-header:hover .sort-indicator { 
  color: var(--link-hover); 
}

/* ============================================================
   2. TIERED HEATMAP HIGHLIGHT RANKS (AutoCAD RAG Layers)
   ============================================================ */
.rank-bad-1, .rank-bad-2, .rank-bad-3,
.rank-good-1, .rank-good-2, .rank-good-3 {
  font-weight: 800 !important;
  text-align: center !important;
}

/* High Is Bad (Red / Amber spectrum) */
.rank-bad-1 { 
  background-color: var(--rag-red-dim) !important; 
  color: var(--rag-red) !important; 
}
.rank-bad-2 { 
  background-color: var(--rag-amber-dim) !important; 
  color: var(--rag-amber) !important; 
}
.rank-bad-3 { 
  background-color: rgba(255, 183, 0, 0.08) !important; 
  color: var(--text-primary) !important; 
}

/* High Is Good (Green spectrum) */
.rank-good-1 { 
  background-color: var(--rag-green-dim) !important; 
  color: var(--rag-green) !important; 
}
.rank-good-2 { 
  background-color: rgba(0, 230, 118, 0.10) !important; 
  color: var(--rag-green) !important; 
}
.rank-good-3 { 
  background-color: rgba(0, 230, 118, 0.06) !important; 
  color: var(--text-primary) !important; 
}

/* ============================================================
   3. PINNED TOTAL SUMMARY ROW
   ============================================================ */
.portal-table tbody tr.row-total,
.portal-table tbody tr[data-is-total="true"] {
  background: var(--accent-dim) !important;
  border-bottom: 2px solid var(--accent-line) !important;
  border-top: 2px solid var(--accent-line) !important;
}

.portal-table tbody tr.row-total td,
.portal-table tbody tr[data-is-total="true"] td {
  color: var(--link-hover) !important;
  font-weight: 800 !important;
  padding-top: 12px !important;
  padding-bottom: 12px !important;
}

.portal-table tbody tr.row-total td:first-child,
.portal-table tbody tr[data-is-total="true"] td:first-child {
  color: var(--text-primary) !important;
  letter-spacing: 0.05em !important;
  font-family: var(--font-display);
}

/* ============================================================
   4. REPORT STUDIO & AD-HOC LOADER
   ============================================================ */
.report-sidebar-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  box-sizing: border-box;
}

.report-sidebar-card {
  background: var(--cad-panel);
  border: 1px solid var(--cad-border);
  border-radius: var(--radius-none);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-sidebar-card.flex-grow {
  flex-grow: 1;
}

.report-sidebar-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.report-select-dropdown {
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--radius-none);
  border: 1px solid var(--cad-border);
  background: var(--cad-bg);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-body);
  outline: none;
  box-sizing: border-box;
}

.report-select-dropdown:focus {
  border-color: var(--accent-line);
}

/* Primary Report Loader Button (RJ McLeod Machinery Yellow) */
.report-btn-load {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-none);
  background: var(--accent-fill);
  color: var(--accent-on-fill);
  border: 1px solid var(--accent-line);
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  transition: filter 0.12s ease;
}

.report-btn-load:hover {
  filter: brightness(1.08);
}

/* Drag & Drop CAD Zone */
.report-dropzone {
  flex-grow: 1;
  min-height: 100px;
  border: 2px dashed var(--cad-border);
  border-radius: var(--radius-none);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  background: var(--cad-subpanel);
  transition: border-color 0.15s ease;
}

.report-dropzone.is-dragover {
  border-color: var(--accent-line);
  background: var(--accent-dim);
}

.report-dropzone-icon {
  margin-bottom: 6px;
  stroke: var(--text-muted);
}

.report-dropzone-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.report-dropzone-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.report-loaded-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--rag-green);
  font-weight: 700;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.report-loaded-badge.is-hidden {
  display: none;
}

/* Export Buttons Grid */
.report-export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.report-export-btn {
  padding: 8px 6px;
  border-radius: var(--radius-none);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.04em;
  transition: opacity 0.12s ease;
}

.report-export-btn:hover {
  opacity: 0.9;
}

.report-export-btn.btn-csv  { background: var(--rag-green-dim); color: var(--rag-green); border-color: var(--rag-green); }
.report-export-btn.btn-pdf  { background: var(--rag-red-dim); color: var(--rag-red); border-color: var(--rag-red); }
.report-export-btn.btn-png  { background: var(--cad-cyan-dim); color: var(--cad-cyan); border-color: var(--cad-cyan); }
.report-export-btn.btn-pptx { background: var(--rag-amber-dim); color: var(--rag-amber); border-color: var(--rag-amber); }

.report-btn-clear {
  width: 100%;
  padding: 6px;
  border-radius: var(--radius-none);
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--cad-border);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-mono);
  transition: all 0.12s ease;
}

.report-btn-clear:hover {
  background: var(--cad-hover);
  color: var(--text-primary);
  border-color: var(--cad-border-bold);
}

/* ============================================================
   5. REPORT VIEWPORT & DATA TABLE
   ============================================================ */
.report-canvas-empty {
  height: 100%;
  min-height: 350px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--cad-border);
  border-radius: var(--radius-none);
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
  background-color: var(--cad-panel);
}

.report-empty-icon {
  margin-bottom: 8px;
  opacity: 0.5;
}

.report-empty-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.report-empty-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.report-viewport-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

.report-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.report-header-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.report-header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.report-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-instant-search {
  padding: 5px 8px;
  border-radius: var(--radius-none);
  border: 1px solid var(--cad-border);
  background: var(--cad-bg);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  font-family: var(--font-body);
}

.report-instant-search:focus {
  border-color: var(--accent-line);
}

.report-row-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.report-table-container {
  flex-grow: 1;
  overflow: auto;
  border: var(--cad-line);
  border-radius: var(--radius-none);
  background: var(--cad-panel);
}

.report-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.report-data-table thead {
  position: sticky;
  top: 0;
  background: var(--cad-subpanel);
  z-index: 2;
  border-bottom: 2px solid var(--cad-border);
}

.report-data-table th {
  padding: 8px 10px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  color: var(--text-muted);
}

.report-data-table th.th-number,
.report-data-table td.td-number {
  text-align: right;
  font-family: var(--font-mono);
}

.report-data-table th .th-sort-icon {
  font-size: 9px;
  color: var(--link-hover);
  margin-left: 4px;
}

.report-data-table tbody tr {
  border-bottom: 1px solid var(--cad-border-subtle);
  transition: background-color 0.12s ease;
}

.report-data-table tbody tr:hover {
  background: var(--cad-hover);
}

.report-data-table td {
  padding: 8px 10px;
  white-space: nowrap;
  color: var(--text-primary);
}

.report-data-table td.td-number {
  font-weight: 600;
}

.report-data-table td.report-no-data {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}