/* ══ Chat data tables ═══════════════════════════════════════════════════
 * Two themes, both scoped by wrapper so the light ag-grid look used by
 * DORA, dashboards and reports is untouched:
 *   Indigo stage — .gr-chat-page .gr-chat-widget  (Lemon-led, white ink)
 *   Editorial    — .gr-ed-widget                   (cream, Indigo-led, rules)
 * ag-grid cells are tagged by AGGrid.jsx (tblEnhanceColumns, `.tbl-styled`
 * grids only); markdown cells are tagged at sanitize time (tbl-md-*).
 * No drop shadows: frames are hairlines and tints. */

/* ── Shared: ag-grid cell parts ─────────────────────────────────────── */
.ag-theme-quartz.tbl-styled .ag-cell { font-variant-numeric: tabular-nums; }
.ag-theme-quartz.tbl-styled .ag-header-cell,
.ag-theme-quartz.tbl-styled .ag-cell { padding-left: 16px; padding-right: 16px; }
.ag-theme-quartz.tbl-styled .ag-header-cell-text {
  font-family: var(--gr-font-mono);
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.ag-theme-quartz.tbl-styled .tbl-cell-num,
.ag-theme-quartz.tbl-styled .tbl-cell-rank { text-align: right; }
.ag-theme-quartz.tbl-styled .tbl-cell-id,
.ag-theme-quartz.tbl-styled .tbl-cell-rank { font-family: var(--gr-font-mono); font-size: 12.5px; letter-spacing: 0.01em; }
.ag-theme-quartz.tbl-styled .tbl-cell-long { font-weight: 500; }

/* Data bar for the primary measure */
.tbl-bar { display: inline-flex; align-items: center; gap: 12px; width: 100%; vertical-align: middle; line-height: 1.2; }
.tbl-bar-track { flex: 1 1 auto; min-width: 24px; height: 6px; border-radius: 1px 4px 4px 1px; overflow: hidden; }
.tbl-bar-fill { display: block; height: 100%; border-radius: 1px 4px 4px 1px; }
.tbl-bar-val { flex: 0 0 auto; min-width: 3.2em; text-align: right; font-weight: 600; }

/* Status pills */
.tbl-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 24px; padding: 0 11px 0 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1;
  white-space: nowrap; vertical-align: middle;
}
.tbl-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }

/* People: initials disc */
.tbl-person { display: inline-flex; align-items: center; gap: 9px; vertical-align: middle; line-height: 1.2; max-width: 100%; }
.tbl-avatar {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--gr-font-mono); font-size: 9.5px; font-weight: 600; letter-spacing: 0.02em;
}
.tbl-person-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Indigo stage: glassy rows on the Indigo panel ─────────────────── */
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled {
  --ag-background-color: transparent;
  --ag-odd-row-background-color: transparent;
  --ag-header-background-color: rgba(16, 18, 104, 0.42);
  --ag-row-hover-color: rgba(255, 255, 255, 0.075);
  --ag-row-border-color: rgba(255, 255, 255, 0.075);
  --ag-border-color: rgba(255, 255, 255, 0.16);
  --ag-header-foreground-color: #c3c4f5;
  --ag-data-color: #ffffff;
  --ag-foreground-color: #ffffff;
  --ag-font-size: 13.5px;
  --ag-wrapper-border-radius: 14px;
  --ag-header-column-resize-handle-color: rgba(255, 255, 255, 0.14);
}
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-root-wrapper {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.16);
}
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-header { border-bottom: 1px solid rgba(255, 222, 76, 0.38); }
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-header-cell-text { color: #c3c4f5; }
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .tbl-head-primary .ag-header-cell-text,
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-header-cell-sorted-asc .ag-header-cell-text,
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-header-cell-sorted-desc .ag-header-cell-text { color: #ffde4c; }
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-row-hover { box-shadow: inset 3px 0 0 #ffde4c; }
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .tbl-cell-id { color: #c3c4f5; }
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .tbl-cell-rank { color: rgba(228, 229, 255, 0.6); }
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .tbl-cell-text,
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .tbl-cell-num { color: #e4e5ff; }
.gr-chat-page .gr-chat-widget .tbl-bar-track { background: rgba(255, 255, 255, 0.12); }
.gr-chat-page .gr-chat-widget .tbl-bar-fill { background: #ffde4c; }
.gr-chat-page .gr-chat-widget .tbl-bar-val { color: #ffffff; }
.gr-chat-page .gr-chat-widget .tbl-avatar { background: rgba(195, 196, 245, 0.2); color: #ffffff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.gr-chat-page .gr-chat-widget .tbl-pill.is-good { background: rgba(197, 239, 76, 0.16); color: #d6f39a; }
.gr-chat-page .gr-chat-widget .tbl-pill.is-bad { background: rgba(240, 160, 124, 0.18); color: #ffc3a8; }
.gr-chat-page .gr-chat-widget .tbl-pill.is-wait { background: rgba(255, 222, 76, 0.16); color: #ffde4c; }
.gr-chat-page .gr-chat-widget .tbl-pill.is-neutral { background: rgba(195, 196, 245, 0.18); color: #e4e5ff; }
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-paging-panel {
  border-top-color: rgba(255, 255, 255, 0.12);
  font-family: var(--gr-font-mono); font-size: 11px; letter-spacing: 0.04em;
  color: rgba(228, 229, 255, 0.72);
}
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-paging-panel .ag-paging-number,
.gr-chat-page .gr-chat-widget .ag-theme-quartz.tbl-styled .ag-paging-panel .ag-paging-row-summary-panel-number { color: #ffde4c; }

/* ── Editorial: cream, hairlines, Deep Sea ink, Lemon highlighter ──── */
.gr-ed-widget .ag-theme-quartz.tbl-styled {
  --ag-background-color: transparent;
  --ag-odd-row-background-color: transparent;
  --ag-header-background-color: transparent;
  --ag-row-hover-color: rgba(255, 222, 76, 0.3);
  --ag-row-border-color: rgba(27, 31, 123, 0.1);
  --ag-border-color: transparent;
  --ag-header-foreground-color: #2929c8;
  --ag-data-color: #1b1f7b;
  --ag-foreground-color: #1b1f7b;
  --ag-font-size: 13.5px;
  --ag-header-column-resize-handle-color: rgba(27, 31, 123, 0.14);
}
.gr-ed-widget .ag-theme-quartz.tbl-styled .ag-root-wrapper { border: 0; border-bottom: 1px solid #1b1f7b; border-radius: 0; }
.gr-ed-widget .ag-theme-quartz.tbl-styled .ag-header { border-bottom: 1px solid #1b1f7b; }
.gr-ed-widget .ag-theme-quartz.tbl-styled .ag-header-cell-text { color: #2929c8; }
.gr-ed-widget .ag-theme-quartz.tbl-styled .tbl-head-primary .ag-header-cell-text { color: #1b1f7b; font-weight: 700; }
.gr-ed-widget .ag-theme-quartz.tbl-styled .tbl-cell-id { color: #2929c8; }
.gr-ed-widget .ag-theme-quartz.tbl-styled .tbl-cell-rank { color: #6a6e93; }
.gr-ed-widget .ag-theme-quartz.tbl-styled .tbl-cell-text,
.gr-ed-widget .ag-theme-quartz.tbl-styled .tbl-cell-num { color: #2f3366; }
.gr-ed-widget .ag-theme-quartz.tbl-styled .tbl-cell-long { font-family: var(--gr-font-serif); font-size: 15px; font-weight: 500; color: #1b1f7b; }
.gr-ed-widget .tbl-bar-track { background: rgba(41, 41, 200, 0.1); }
.gr-ed-widget .tbl-bar-fill { background: #2929c8; }
.gr-ed-widget .tbl-bar-val { color: #1b1f7b; font-family: var(--gr-font-serif); font-size: 15px; line-height: 1; position: relative; top: -1px; }
.gr-ed-widget .tbl-avatar { background: #e4e4fa; color: #2929c8; }
.gr-ed-widget .tbl-pill.is-good { background: #e8f5c8; color: #3d5410; }
.gr-ed-widget .tbl-pill.is-bad { background: #f6ddd3; color: #8a3517; }
.gr-ed-widget .tbl-pill.is-wait { background: rgba(255, 222, 76, 0.55); color: #1b1f7b; }
.gr-ed-widget .tbl-pill.is-neutral { background: #e4e4fa; color: #2929c8; }
.gr-ed-widget .ag-theme-quartz.tbl-styled .ag-paging-panel {
  border-top: 0;
  font-family: var(--gr-font-mono); font-size: 11px; letter-spacing: 0.04em; color: #6a6e93;
}
.gr-ed-widget .ag-theme-quartz.tbl-styled .ag-paging-panel .ag-paging-number,
.gr-ed-widget .ag-theme-quartz.tbl-styled .ag-paging-panel .ag-paging-row-summary-panel-number { color: #1b1f7b; }

/* ── Markdown tables in answers — Indigo stage (default) ───────────── */
.gr-chat-page .gr-md table {
  display: table;
  width: 100%;
  max-width: 100%;
  margin: 0.9rem 0 1rem;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid rgba(27, 31, 123, 0.16);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(195, 196, 245, 0.1);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.gr-chat-page .gr-md thead th {
  background: #1b1f7b;
  color: #ffde4c;
  font-family: var(--gr-font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.8rem 1rem 0.75rem;
  border: 0;
  white-space: nowrap;
}
.gr-chat-page .gr-md td {
  padding: 0.72rem 1rem;
  border: 0;
  border-top: 1px solid rgba(27, 31, 123, 0.08);
  color: #2f3366;
  background: transparent;
}
.gr-chat-page .gr-md tbody tr:first-child td { border-top: 0; }
.gr-chat-page .gr-md tr:nth-child(even) td { background: transparent; }
.gr-chat-page .gr-md tbody tr:hover td { background: rgba(255, 222, 76, 0.2); }
.gr-chat-page .gr-md td:first-child { color: #1b1f7b; font-weight: 500; }
.gr-chat-page .gr-md td code { background: rgba(41, 41, 200, 0.08); color: #1b1f7b; }
.gr-chat-page .gr-md thead th.tbl-md-num,
.gr-chat-page .gr-md td.tbl-md-num { text-align: right; white-space: nowrap; }
.gr-chat-page .gr-md td.tbl-md-delta { font-weight: 600; }
.gr-chat-page .gr-md td.tbl-md-delta::before {
  display: inline-block;
  margin-right: 6px;
  font-size: 0.62em;
  vertical-align: 0.18em;
}
.gr-chat-page .gr-md td.tbl-md-delta.is-up { color: #3d5410; }
.gr-chat-page .gr-md td.tbl-md-delta.is-up::before { content: "\25B2"; color: #5b7f12; }
.gr-chat-page .gr-md td.tbl-md-delta.is-down { color: #8a3517; }
.gr-chat-page .gr-md td.tbl-md-delta.is-down::before { content: "\25BC"; color: #c2532d; }
.gr-chat-page .gr-md td.tbl-md-delta.is-flat { color: #6a6e93; }

/* ── Markdown tables — Editorial: newspaper rules, not boxes ───────── */
.gr-chat-page:has(.gr-ed-widget) .gr-md table,
.gr-ed-md .gr-md table {
  border: 0;
  border-top: 2px solid #1b1f7b;
  border-bottom: 1px solid #1b1f7b;
  border-radius: 0;
  background: transparent;
}
.gr-chat-page:has(.gr-ed-widget) .gr-md thead th,
.gr-ed-md .gr-md thead th {
  background: transparent;
  color: #2929c8;
  border-bottom: 1px solid #1b1f7b;
  padding: 0.7rem 0.9rem 0.6rem;
}
.gr-chat-page:has(.gr-ed-widget) .gr-md td,
.gr-ed-md .gr-md td { padding: 0.7rem 0.9rem; border-top-color: rgba(27, 31, 123, 0.12); }
.gr-chat-page:has(.gr-ed-widget) .gr-md td:first-child,
.gr-ed-md .gr-md td:first-child { padding-left: 0.15rem; }
.gr-chat-page:has(.gr-ed-widget) .gr-md th:first-child,
.gr-ed-md .gr-md th:first-child { padding-left: 0.15rem; }
.gr-chat-page:has(.gr-ed-widget) .gr-md td:last-child,
.gr-chat-page:has(.gr-ed-widget) .gr-md th:last-child,
.gr-ed-md .gr-md td:last-child,
.gr-ed-md .gr-md th:last-child { padding-right: 0.15rem; }
.gr-chat-page:has(.gr-ed-widget) .gr-md tbody tr:hover td,
.gr-ed-md .gr-md tbody tr:hover td { background: rgba(255, 222, 76, 0.3); }
.gr-chat-page:has(.gr-ed-widget) .gr-md td.tbl-md-num,
.gr-ed-md .gr-md td.tbl-md-num { font-family: var(--gr-font-serif); font-size: 1.05rem; color: #1b1f7b; }
.gr-chat-page:has(.gr-ed-widget) .gr-md td.tbl-md-delta.is-up,
.gr-ed-md .gr-md td.tbl-md-delta.is-up { color: #3d5410; }
.gr-chat-page:has(.gr-ed-widget) .gr-md td.tbl-md-delta.is-down,
.gr-ed-md .gr-md td.tbl-md-delta.is-down { color: #8a3517; }

/* ── Phones: scroll inside the frame, never the page ───────────────── */
@media (max-width: 640px) {
  .gr-chat-page .gr-md table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .gr-chat-page .gr-md td { white-space: nowrap; }
  .ag-theme-quartz.tbl-styled .ag-header-cell,
  .ag-theme-quartz.tbl-styled .ag-cell { padding-left: 12px; padding-right: 12px; }
}
