/* Thin layer over Bootstrap. Keep it small — Bootstrap handles 95% of it. */

:root {
  --gr-sidebar-bg: #1d2330;
  --gr-sidebar-fg: #d8dde8;
  --gr-sidebar-fg-muted: #8a93a8;
  --gr-sidebar-width: 220px;
  --gr-accent: #4f7cff;
}

html, body, #root {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f5f6f8;
  color: #1d2330;
}

/* ── Shared form styles ─────────────────────────────────────── */

.gr-field {
  display: block;
  margin-bottom: 1rem;
}
.gr-field > span {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  color: #344054;
}
.gr-field input, .gr-field select, .gr-field textarea, .gr-byod-stream-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
.gr-field input:focus, .gr-field select:focus, .gr-field textarea:focus, .gr-byod-stream-input:focus {
  outline: none;
  border-color: var(--gr-accent);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.12);
}
.gr-field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: #6b7280;
}

.gr-btn-primary {
  width: 100%;
  padding: 0.6rem;
  background: var(--gr-accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.gr-btn-primary:disabled { opacity: 0.6; cursor: wait; }

.gr-btn-secondary {
  padding: 0.5rem 0.85rem;
  min-height: 36px;
  background: #fff;
  color: #1d2330;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.gr-btn-secondary:hover { background: #f9fafb; }

.gr-btn-danger {
  padding: 0.5rem 0.85rem;
  min-height: 36px;
  background: #dc2626;
  color: #fff;
  border: 0;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

.gr-error {
  background: #fde7e7;
  color: #9b1c1c;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.gr-info {
  background: #e0f2fe;
  color: #075985;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.gr-success {
  background: #d1fae5;
  color: #065f46;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.gr-auth-links {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}
.gr-auth-links a { color: var(--gr-accent); text-decoration: none; }
.gr-auth-links a:hover { text-decoration: underline; }

/* ── Card / panel ───────────────────────────────────────────── */

.gr-card {
  background: #fff;
  border: 1px solid #e4e7ee;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.gr-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

/* ── Table ──────────────────────────────────────────────────── */

.gr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.gr-table th, .gr-table td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #e4e7ee;
}
.gr-table th { background: #f9fafb; font-weight: 600; }
.gr-table tbody tr:hover { background: #f9fafb; }

/* ── KPI cards ──────────────────────────────────────────────── */

.gr-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.gr-kpi {
  background: #fff;
  border: 1px solid #e4e7ee;
  border-radius: 10px;
  padding: 1rem;
}
.gr-kpi-label {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 0.35rem;
}
.gr-kpi-value {
  font-size: 1.5rem;
  font-weight: 600;
}

/* ── Tabs ───────────────────────────────────────────────────── */

.gr-tabs {
  display: flex;
  border-bottom: 1px solid #e4e7ee;
  margin-bottom: 1rem;
  gap: 0.25rem;
}
.gr-tab {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.gr-tab.is-active {
  color: var(--gr-accent);
  border-bottom-color: var(--gr-accent);
}

/* ── Stepper ────────────────────────────────────────────────── */

.gr-stepper {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.gr-step {
  flex: 1;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid #e4e7ee;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #6b7280;
}
.gr-step.is-active {
  border-color: var(--gr-accent);
  color: var(--gr-accent);
  font-weight: 600;
}
.gr-step.is-done {
  background: #d1fae5;
  border-color: #34d399;
  color: #065f46;
}

.gr-onboarding-option {
  display: block;
  padding: 0.85rem 1rem;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.gr-onboarding-option:hover {
  border-color: var(--gr-accent);
  background: #f5f8ff;
}
.gr-onboarding-option strong { display: block; margin-bottom: 0.2rem; }
.gr-onboarding-option span { color: #6b7280; font-size: 0.85rem; }

/* ── Auth shell ─────────────────────────────────────────────── */

.gr-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1d2330 0%, #2b3a5a 100%);
  padding: 2rem 1rem;
}

.gr-auth-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  padding: 2rem;
  width: 100%;
  max-width: 24rem;
}

.gr-auth-card h1 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  text-align: center;
}

/* ── App shell with sidebar ─────────────────────────────────── */

.gr-shell {
  display: grid;
  grid-template-columns: var(--gr-sidebar-width) 1fr;
  min-height: 100vh;
  /* Stop the grid from forcing column children to expand. Without this,
     <main>'s wide ag-grid containers blow the layout horizontally. */
  min-width: 0;
}
.gr-shell > * { min-width: 0; }

.gr-sidebar {
  background: var(--gr-sidebar-bg);
  color: var(--gr-sidebar-fg);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  /* Sidebar can be taller than viewport with all groups expanded —
     let it scroll without pushing the main area off-screen. */
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  /* Explicit low z-index so the cookie consent bar (z-index:10000) and
     any future modal/toast can paint above us. position:sticky creates a
     stacking context, so without this the sidebar was intercepting clicks
     on the consent bar's bottom-left overlap region. */
  z-index: 1;
}

.gr-sidebar-brand {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

.gr-sidebar a {
  color: var(--gr-sidebar-fg-muted);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
}

.gr-sidebar a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.gr-sidebar a.is-active {
  background: rgba(79, 124, 255, 0.18);
  color: #fff;
}

.gr-sidebar-group-label {
  font-size: 0.7rem;
  color: var(--gr-sidebar-fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.6rem 0.75rem 0.25rem;
}

.gr-sidebar-spacer {
  flex: 1;
}

.gr-sidebar-meta {
  font-size: 0.75rem;
  color: var(--gr-sidebar-fg-muted);
  padding: 0.5rem 0.75rem;
}

.gr-main {
  padding: 1.5rem 2rem;
  overflow-x: auto;
  min-width: 0;
}

/* ── Chat (two-column: history + live pane) ─────────────────── */

.gr-chat-page {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  height: calc(100vh - 3rem);
  min-width: 0;
}

.gr-chat-sidebar {
  background: #fff;
  border: 1px solid #e4e7ee;
  border-radius: 10px;
  padding: 0.75rem;
  overflow-y: auto;
}

.gr-chat-history-group {
  margin: 0.65rem 0 0.25rem;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.gr-chat-history-group:first-child {
  margin-top: 0.15rem;
}

.gr-chat-conv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.2rem;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.gr-chat-conv:hover { background: #f5f6f8; }
.gr-chat-conv.is-active {
  background: rgba(79, 124, 255, 0.12);
  color: var(--gr-accent);
  font-weight: 500;
}

.gr-chat-tooltip {
  position: fixed;
  transform: translateY(-50%);
  z-index: 2000;
  background: #111827;
  color: #f9fafb;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.35);
  font-size: 0.78rem;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: auto;
}

.gr-chat-conv-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gr-chat-conv-del {
  background: none;
  border: 0;
  color: #9ca3af;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  visibility: hidden;
}
.gr-chat-conv:hover .gr-chat-conv-del { visibility: visible; }
.gr-chat-conv-del:hover { color: #dc2626; }

.gr-chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.gr-chat-header {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e4e7ee;
  margin-bottom: 0.5rem;
}

.gr-chat {
  /* legacy class kept for backwards compatibility with older tests */
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gr-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}

.gr-chat-msg {
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  max-width: 92%;
  line-height: 1.55;
  font-size: 0.95rem;
}

.gr-chat-msg.user {
  background: var(--gr-accent);
  color: #fff;
  align-self: flex-end;
}

.gr-chat-msg.assistant {
  background: #fff;
  border: 1px solid #e4e7ee;
  align-self: flex-start;
  min-width: 0;
}

.gr-chat-input {
  border-top: 1px solid #e4e7ee;
  padding-top: 1rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.gr-chat-input textarea {
  flex: 1;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  resize: none;
  min-height: 2.85rem;
  max-height: 13.75rem;
  line-height: 1.45;
  overflow-y: hidden;
}

.gr-chat-input button {
  align-self: center;
  height: 2.85rem;
  min-height: 2.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Markdown rendering inside assistant bubbles ───────────── */

.gr-md p { margin: 0 0 0.6rem; }
.gr-md p:last-child { margin-bottom: 0; }
.gr-md h1, .gr-md h2, .gr-md h3, .gr-md h4 {
  margin: 0.9rem 0 0.4rem;
  line-height: 1.3;
}
.gr-md h1 { font-size: 1.25rem; }
.gr-md h2 { font-size: 1.1rem; }
.gr-md h3 { font-size: 1rem; }
.gr-md h4 { font-size: 0.95rem; }
.gr-md ul, .gr-md ol { margin: 0 0 0.6rem 1.25rem; padding: 0; }
.gr-md li { margin-bottom: 0.2rem; }
.gr-md blockquote {
  border-left: 3px solid var(--gr-accent);
  background: #f5f8ff;
  padding: 0.5rem 0.85rem;
  margin: 0.5rem 0;
  color: #344054;
}
.gr-md code {
  background: #f1f3f8;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font: 0.85em ui-monospace, SFMono-Regular, Menlo, monospace;
}
.gr-md pre {
  background: #1d2330;
  color: #e5e7eb;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.5;
  margin: 0.5rem 0;
}
.gr-md pre code { background: none; padding: 0; color: inherit; }
.gr-md table {
  border-collapse: collapse;
  margin: 0.5rem 0;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}
.gr-md th, .gr-md td {
  border: 1px solid #e4e7ee;
  padding: 0.45rem 0.7rem;
  text-align: left;
  font-size: 0.9rem;
}
.gr-md th { background: #f9fafb; font-weight: 600; }
.gr-md tr:nth-child(even) td { background: #fafbfd; }
.gr-md a { color: var(--gr-accent); }
.gr-md hr { border: 0; border-top: 1px solid #e4e7ee; margin: 0.75rem 0; }

/* ── Grid header strip ──────────────────────────────────────── */

.gr-page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.gr-page-header h1 {
  font-size: 1.4rem;
  margin: 0 0 0.25rem;
}

.gr-page-header p {
  margin: 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.gr-search {
  min-width: 18rem;
}

/* ── Responsive — viewports under 768px ───────────────────────────── */

@media (max-width: 767px) {
  /* Stack the shell: sidebar above main content, both full-width. The
     sidebar still scrolls if its content is taller than the viewport. */
  .gr-shell {
    grid-template-columns: 1fr;
  }
  .gr-sidebar {
    position: static;
    height: auto;
    max-height: 60vh;
  }
  .gr-main {
    padding: 1rem;
  }

  /* KPI cards: looser minmax so they don't force horizontal scroll. */
  .gr-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  /* Chat: stack history sidebar above the chat pane. */
  .gr-chat-page {
    grid-template-columns: 1fr;
    height: auto;
  }
  .gr-chat-sidebar {
    max-height: 30vh;
  }

  /* Tabs: let them wrap instead of overflowing. */
  .gr-tabs {
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }

  /* Stepper: stack vertically rather than overflow. */
  .gr-stepper {
    flex-direction: column;
  }

  /* Tables: wrap each table in horizontal scroll so headers don't
     push the page off-screen. */
  .gr-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* Search input in page headers — was min-width 18rem which forces
     horizontal scroll on small screens. */
  .gr-search {
    min-width: 0;
    width: 100%;
  }
  .gr-page-header {
    flex-direction: column;
    align-items: stretch;
  }

  /* Hide the icon spacers on auth-bridge nav text — tighter padding. */
  .gr-sidebar a {
    padding: 0.45rem 0.6rem;
    font-size: 0.92rem;
  }
}

/* ── ≤ 480px (small phones) ─────────────────────────────────────── */

@media (max-width: 480px) {
  .gr-auth-card { padding: 1.25rem; max-width: 100%; }
  .gr-main { padding: 0.75rem; }
  .gr-chat-input { flex-direction: column; }
  .gr-chat-input button { padding: 0.75rem !important; }
  h1 { font-size: 1.25rem !important; }
}

/* ── Boot-time loading skeleton ───────────────────────────────────
   Shown inside <div id="root"> while Babel-standalone compiles the
   in-browser JSX. React replaces it with the real tree on mount, so
   the user never sees a blank page even when JS parsing is slow. */

.gr-boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: #f5f6f8;
  color: #6b7280;
}

.gr-boot-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e4e7ee;
  border-top-color: var(--gr-accent);
  border-radius: 50%;
  animation: gr-boot-spin 0.9s linear infinite;
}

.gr-boot-text {
  font: 0.9rem system-ui, sans-serif;
}

@keyframes gr-boot-spin {
  to { transform: rotate(360deg); }
}

/* ── Chat "thinking…" three-dot animation ─────────────────────── */
.gr-chat-dots {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
}
.gr-chat-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gr-accent);
  animation: gr-dot-bounce 1.2s infinite ease-in-out both;
}
.gr-chat-dots span:nth-child(1) { animation-delay: -0.32s; }
.gr-chat-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes gr-dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.0); opacity: 1; }
}

/* Widget wrapper used by chat for inline aggrid/agchart blocks. */
.gr-chat-widget {
  margin: 0.75rem 0;
  border: 1px solid #e4e7ee;
  border-radius: 8px;
  padding: 0.5rem;
  background: #fafbfd;
}
.gr-chat-widget-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.gr-chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.gr-chat-widget-header .gr-chat-widget-label {
  margin-bottom: 0;
}
.gr-chat-widget-actions {
  display: inline-flex;
  gap: 0.35rem;
}
.gr-chat-widget-actions .gr-btn-secondary {
  min-height: 0;
  padding: 0.2rem 0.45rem;
  font-size: 0.74rem;
}
.gr-chat-response-actions {
  margin-top: 0.55rem;
  display: flex;
  justify-content: flex-end;
}
.gr-chat-response-actions .gr-btn-secondary {
  min-height: 0;
  padding: 0.28rem 0.6rem;
  font-size: 0.78rem;
}

/* ── EducationCardStack ───────────────────────────────────────
   Horizontally scrollable stack of "what you can do next" cards,
   used on the onboarding success step and (persistently) on the
   Reports list. See components/EducationCardStack.jsx. */
.gr-edu-stack {
  margin: 1.25rem 0 1.5rem;
}
.gr-edu-stack__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  padding: 0 0.25rem;
}
.gr-edu-stack__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #344054;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.gr-edu-stack__dismiss {
  background: transparent;
  border: 1px solid transparent;
  color: #6b7280;
  font-size: 1.3rem;
  line-height: 1;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.gr-edu-stack__dismiss:hover,
.gr-edu-stack__dismiss:focus-visible {
  background: #f1f3f7;
  color: #1d2330;
  border-color: #d0d5dd;
  outline: none;
}
.gr-edu-stack__scroller {
  display: flex;
  gap: 0.85rem;
  overflow-x: auto;
  padding: 0.25rem 0.25rem 0.85rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.gr-edu-stack__scroller::-webkit-scrollbar {
  height: 8px;
}
.gr-edu-stack__scroller::-webkit-scrollbar-thumb {
  background: #d0d5dd;
  border-radius: 8px;
}
.gr-edu-card {
  flex: 0 0 17rem;
  min-width: 17rem;
  background: #fff;
  border: 1px solid #e4e7ee;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-snap-align: start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.gr-edu-card:hover {
  border-color: var(--gr-accent);
  box-shadow: 0 4px 14px rgba(29, 35, 48, 0.08);
  transform: translateY(-1px);
}
.gr-edu-card__icon {
  font-size: 1.6rem;
  line-height: 1;
}
.gr-edu-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1d2330;
}
.gr-edu-card__body {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #475467;
  flex: 1;
}
.gr-edu-card__action {
  align-self: flex-start;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gr-accent);
  text-decoration: none;
}
.gr-edu-card__action:hover,
.gr-edu-card__action:focus-visible {
  text-decoration: underline;
}

.gr-edu-show-again {
  display: inline-block;
  font-size: 0.8rem;
  color: #6b7280;
  text-decoration: none;
  padding: 0.25rem 0;
}
.gr-edu-show-again:hover,
.gr-edu-show-again:focus-visible {
  color: var(--gr-accent);
  text-decoration: underline;
}

/* ── Settings shell (IA Phase 4.1) ──────────────────────────── */

.gr-settings-tabs {
  min-width: 0;
}
.gr-settings-tablist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.8rem;
}
.gr-settings-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 56px;
  padding: 0.75rem 0.85rem;
  border: 1px solid #e4e7ee;
  border-radius: 10px;
  background: #fff;
  color: #1d2330;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.gr-settings-tab:hover {
  border-color: var(--gr-accent);
  box-shadow: 0 4px 14px rgba(29, 35, 48, 0.08);
  transform: translateY(-1px);
}
.gr-settings-tab::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  min-width: 180px;
  max-width: 300px;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  font-size: 0.76rem;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.14s ease, visibility 0.14s ease;
  z-index: 20;
}
.gr-settings-tab::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #1f2937;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.14s ease, visibility 0.14s ease;
  z-index: 20;
}
.gr-settings-tab:hover::after,
.gr-settings-tab:hover::before,
.gr-settings-tab:focus-visible::after,
.gr-settings-tab:focus-visible::before {
  opacity: 1;
  visibility: visible;
}
.gr-settings-tab-icon {
  width: 1.75rem;
  height: 1.75rem;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #eef3ff;
  flex-shrink: 0;
}
.gr-settings-tab-label {
  line-height: 1.25;
}

.gr-settings-detail {
  background: #fff;
  border: 1px solid #e4e7ee;
  border-radius: 10px;
  padding: 1rem;
}
.gr-settings-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #eef1f6;
}
.gr-settings-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--gr-accent);
  font-size: 0.9rem;
}
.gr-settings-back-link:hover {
  text-decoration: underline;
}
.gr-settings-detail-title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1d2330;
}
.gr-settings-panel { min-width: 0; }
.gr-settings-account {
  width: 100%;
}
.gr-settings-inline-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.gr-settings-inline-fields-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.gr-settings-inline-fields .gr-field {
  margin-bottom: 0;
}
.gr-settings-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
}
.gr-settings-section-copy {
  min-width: 0;
  flex: 1;
}
.gr-settings-profile-defs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
  min-width: 0;
}
.gr-settings-profile-defs dt {
  color: #6b7280;
  font-weight: 700;
}
.gr-settings-profile-defs dd {
  margin: 0;
  min-width: 0;
}
.gr-settings-profile-avatar {
  width: 120px;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  color: #64748b;
  display: inline-grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}
.gr-settings-accordion-card details {
  width: 100%;
}
.gr-settings-accordion-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
}
.gr-settings-accordion-summary::-webkit-details-marker {
  display: none;
}
.gr-settings-accordion-summary::after {
  content: "▾";
  color: #6b7280;
  font-size: 0.95rem;
  line-height: 1;
  margin-top: 0.15rem;
  transition: transform 0.15s ease;
}
.gr-settings-accordion-card details[open] .gr-settings-accordion-summary::after {
  transform: rotate(180deg);
}
.gr-settings-accordion-summary h2 {
  margin: 0;
  font-size: 1.05rem;
}
.gr-settings-accordion-summary p {
  margin: 0.35rem 0 0;
  color: #6b7280;
}
.gr-settings-accordion-content {
  margin-top: 0.9rem;
}
.gr-settings-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}
.gr-btn-primary.gr-btn-inline {
  width: auto;
  padding: 0.6rem 1rem;
}
.gr-byod-upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
  gap: 1rem;
  align-items: start;
}
.gr-byod-mode-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.gr-byod-mode-list label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.gr-byod-stream-create {
  width: 100%;
  margin-bottom: 0.5rem;
}
.gr-byod-stream-create input {
  width: 100%;
}
.gr-users-options-col {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
.gr-users-table-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.8rem;
}
.gr-icon-link {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: #fff;
  color: #344054;
  text-decoration: none;
  cursor: pointer;
}
.gr-icon-link:hover {
  background: #f9fafb;
  border-color: #98a2b3;
}
@media (max-width: 720px) {
  .gr-settings-tablist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gr-settings-inline-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .gr-byod-upload-layout {
    grid-template-columns: 1fr;
  }
  .gr-settings-inline-fields-two {
    grid-template-columns: 1fr;
  }
  .gr-settings-section-header {
    flex-direction: column;
  }
  .gr-settings-profile-avatar {
    width: 104px;
  }
}
@media (max-width: 560px) {
  .gr-settings-inline-fields {
    grid-template-columns: 1fr;
  }
  .gr-settings-profile-avatar {
    width: 92px;
  }
}
@media (max-width: 520px) {
  .gr-settings-tablist { grid-template-columns: 1fr; }
  .gr-settings-tab::after,
  .gr-settings-tab::before {
    display: none;
  }
  .gr-settings-detail-header {
    flex-direction: column;
    align-items: flex-start;
  }
}


/* ── Top header strip (lives inside .gr-main) ───────────────── */

.gr-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  /* Negative margin pulls the strip flush with the .gr-main padding
     so it spans the full content column without a visible left gap. */
  margin: -1.5rem -2rem 1.25rem;
  padding: 0.6rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e4e7ee;
  min-height: 48px;
}
.gr-topbar-spacer { flex: 1; }
.gr-main-content { min-width: 0; }

/* ── Bell icon + dropdown ───────────────────────────────────── */

.gr-bell {
  position: relative;
}
.gr-bell-btn {
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.gr-bell-btn:hover { background: #f5f6f8; border-color: #e4e7ee; }
.gr-bell-icon { font-size: 1.15rem; }
.gr-bell-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #dc2626;
  color: #fff;
  border-radius: 9px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  border: 2px solid #fff;
  box-sizing: content-box;
}

.gr-bell-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 1rem);
  background: #fff;
  border: 1px solid #e4e7ee;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  z-index: 100;
  display: flex;
  flex-direction: column;
  max-height: 480px;
}
.gr-bell-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid #e4e7ee;
}
.gr-bell-dropdown-meta {
  font-size: 0.78rem;
  color: #6b7280;
}
.gr-bell-dropdown-body {
  flex: 1;
  overflow-y: auto;
  min-height: 60px;
}
.gr-bell-empty {
  padding: 1rem;
  color: #6b7280;
  text-align: center;
  font-size: 0.9rem;
}
.gr-bell-error { color: #9b1c1c; }
.gr-bell-row {
  display: block;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid #f0f2f6;
  text-decoration: none;
  color: inherit;
}
.gr-bell-row:hover { background: #f9fafb; }
.gr-bell-row:last-child { border-bottom: 0; }
.gr-bell-row-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
  color: #1d2330;
}
.gr-bell-row-body {
  font-size: 0.82rem;
  color: #4b5563;
  margin-bottom: 0.25rem;
}
.gr-bell-row-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: #6b7280;
}
.gr-bell-dropdown-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.85rem;
  border-top: 1px solid #e4e7ee;
  font-size: 0.85rem;
}
.gr-bell-dropdown-footer a { color: var(--gr-accent); text-decoration: none; }
.gr-bell-dropdown-footer a:hover { text-decoration: underline; }
.gr-bell-link-btn {
  background: transparent;
  border: 0;
  color: var(--gr-accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.gr-bell-link-btn:hover:not(:disabled) { text-decoration: underline; }
.gr-bell-link-btn:disabled { color: #9ca3af; cursor: default; }

/* ── /notifications drilldown page ──────────────────────────── */

.gr-notif-row-focus {
  background: rgba(79, 124, 255, 0.16) !important;
}

/* Cookie consent bar — minimal, bottom of viewport (GIT-981)
 *
 * z-index note: the sidebar uses position: sticky which creates its own
 * stacking context. On first visit the consent bar spans the full viewport
 * width (left:0 → right:0), so its bottom-left corner sits underneath the
 * sidebar's column. Without an explicit isolation on the parent, a fixed
 * child with z-index:9999 could still be painted *below* the sticky
 * sidebar in the .gr-shell grid stacking context — making the
 * Accept/Reject buttons unclickable on landing pages with a sidebar.
 *
 * Fix: pin the sidebar's stacking order to a low explicit value
 * (.gr-sidebar { z-index: 1 }) and keep the consent bar's z-index high.
 * The combination forces the consent bar to win the paint + hit-test
 * even when their stacking contexts overlap.
 */
.gr-consent-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1a1a1a;
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  /* Must outrank .gr-sidebar (z-index: 1) and any modal overlay we add
   * later. Keep this in sync with --gr-z-modal if we ever extract tokens. */
  z-index: 10000;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}
.gr-consent-bar span { flex: 1; }
.gr-consent-bar a { color: #4eb1ff; }
.gr-consent-bar button { padding: 0.4rem 0.9rem; border-radius: 4px; border: 0; cursor: pointer; font-size: 0.85rem; }
.gr-consent-bar .gr-btn-secondary { background: transparent; color: #fff; border: 1px solid #555; }
.gr-consent-bar .gr-btn-primary { background: #4eb1ff; color: #000; font-weight: 500; }

/* ============================================================
 * Mobile chat-only view (GIT-777 / mobile-chat.html).
 * Full-viewport single column: top bar, scrollable messages,
 * sticky input docked to the bottom above the safe-area inset.
 * ============================================================ */
.gr-mobile-body {
  margin: 0;
  background: #f8f9fb;
  height: 100vh;
  height: 100dvh; /* iOS Safari: 100dvh excludes the dynamic toolbar */
  overflow: hidden;
}
.gr-mobile-body #root {
  height: 100%;
}
.gr-mobile-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #f8f9fb;
}
.gr-mobile-topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  padding-top: max(0.5rem, env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.gr-mobile-newbtn {
  background: #4f7cff;
  color: #fff;
  border: 0;
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.gr-mobile-convpicker {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
}
.gr-mobile-desktop-link {
  text-decoration: none;
  color: #6b7280;
  font-size: 1.1rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.gr-mobile-desktop-link:hover { background: #f3f4f6; }

.gr-mobile-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.gr-mobile-messages .gr-chat-msg {
  max-width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
}
.gr-mobile-messages .gr-chat-msg.user {
  background: #4f7cff;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.gr-mobile-messages .gr-chat-msg.assistant {
  background: #fff;
  color: #1f2937;
  align-self: flex-start;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}
.gr-mobile-empty {
  text-align: center;
  color: #6b7280;
  padding: 2rem 1rem;
  margin: auto 0;
}
.gr-mobile-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.gr-mobile-input textarea {
  flex: 1;
  resize: none;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 16px; /* iOS won't zoom on focus when >= 16px */
  font-family: inherit;
  line-height: 1.3;
}
.gr-mobile-send {
  width: 2.75rem;
  flex-shrink: 0;
  font-size: 1.2rem;
  border-radius: 8px;
}
