/* FB Ads specific table styling */
.table-wrap {
  max-height: 70vh;
  overflow: auto;
}

.table-wrap table {
  width: 100%;
  table-layout: fixed;
}

.table-wrap th,
.table-wrap td {
  font-size: 0.8rem;
  padding: 8px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap th {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--thbg);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: normal;
  line-height: 1.2;
  vertical-align: middle;
  text-align: center;
  padding: 6px 4px;
}

.table-wrap td {
  white-space: nowrap;
}

/* Ad Name and Campaign Name columns - flexible width */
.table-wrap th:nth-child(1),
.table-wrap td:nth-child(1) {
  width: 18%;
  min-width: 150px;
}

.table-wrap th:nth-child(2),
.table-wrap td:nth-child(2) {
  width: 18%;
  min-width: 150px;
}

/* Numeric columns - compact */
.table-wrap th:nth-child(3),
.table-wrap td:nth-child(3),
.table-wrap th:nth-child(8),
.table-wrap td:nth-child(8),
.table-wrap th:nth-child(10),
.table-wrap td:nth-child(10) {
  width: 7%;
  min-width: 60px;
}

/* Cost columns - slightly wider */
.table-wrap th:nth-child(4),
.table-wrap td:nth-child(4),
.table-wrap th:nth-child(9),
.table-wrap td:nth-child(9),
.table-wrap th:nth-child(11),
.table-wrap td:nth-child(11) {
  width: 8%;
  min-width: 70px;
}

/* Other columns */
.table-wrap th:nth-child(5),
.table-wrap td:nth-child(5),
.table-wrap th:nth-child(6),
.table-wrap td:nth-child(6),
.table-wrap th:nth-child(7),
.table-wrap td:nth-child(7) {
  width: 7%;
  min-width: 65px;
}

.table-wrap th:nth-child(1),
.table-wrap th:nth-child(2),
.table-wrap td:nth-child(1),
.table-wrap td:nth-child(2) {
  text-align: left;
  white-space: nowrap;
}

/* Tooltip cursor for name columns */
.table-wrap td:nth-child(1)[title],
.table-wrap td:nth-child(2)[title] {
  cursor: help;
}

/* Highlight important columns */
.table-wrap td:nth-child(3),
.table-wrap th:nth-child(3) {
  background: rgba(99, 102, 241, 0.05);
}

.table-wrap td:nth-child(8),
.table-wrap th:nth-child(8) {
  background: rgba(168, 85, 247, 0.05);
}

.table-wrap td:nth-child(10),
.table-wrap th:nth-child(10) {
  background: rgba(34, 197, 94, 0.05);
}

/* Category cards styling - override base styles */
#categories .category-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  grid-template-columns: unset;
  align-items: stretch;
}

.cat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.08));
  border-bottom: 2px solid var(--border);
  margin: -14px -14px 0 -14px;
  border-radius: 8px 8px 0 0;
}

.cat-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--heading);
}

.cat-count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}

.cat-spend {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 20px 16px 16px;
}

.metric-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.metric-group h4 {
  margin: 0 0 12px 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 6px;
  text-align: center;
}

.metric-group .metric {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.metric-group .metric:last-child {
  border-bottom: none;
}

.metric-group .metric-label {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: left;
}

.metric-group .metric-value {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
  text-align: right;
}

/* Responsive: stack on smaller screens */
@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
