/* ── Design tokens ── */
:root {
  --bg:             #F4F6F9;
  --surface:        #FFFFFF;
  --sidebar-bg:     #2a2927;
  --sidebar-border: #3a3835;

  --navy:           #2a2927;
  --navy-light:     #3a3835;

  --text-primary:   #2a2927;
  --text-secondary: #5A6578;
  --text-tertiary:  #9AA3B2;

  --accent-up:      #059669;
  --accent-down:    #DC2626;
  --accent-neutral: #5A6578;

  --border:         #E8EBF0;
  --border-hover:   #D1D8E3;

  --row-hover:      #F8FAFC;
  --row-active:     #EFF6FF;
  --row-active-border: #BFDBFE;

  --sparkline:      #2563EB;

  --font-ui:        'Outfit', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;

  --shadow-sm:  0 1px 3px rgba(13, 27, 46, 0.06), 0 1px 2px rgba(13, 27, 46, 0.04);
  --shadow-md:  0 4px 12px rgba(13, 27, 46, 0.08), 0 2px 4px rgba(13, 27, 46, 0.04);
  --shadow-lg:  0 16px 48px rgba(13, 27, 46, 0.12), 0 4px 12px rgba(13, 27, 46, 0.06);
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app-shell--embedded {
  height: 100vh;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 168px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 8px;
}

.signals-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 8px;
}

.nav-view-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
  margin-left: 2px;
  padding-left: 12px;
  border-left: 2px solid rgba(255, 255, 255, 0.14);
}

.signal-btn--sub {
  padding: 8px 10px;
  font-size: 12px;
  border-color: rgba(255, 255, 255, 0.08);
}

.signal-btn--sub .signal-btn-dot {
  width: 6px;
  height: 6px;
}

.sidebar-caption--sub {
  margin-top: 6px;
  margin-bottom: 0;
}

.signal-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.signal-btn:hover:not(.active) {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
}

.signal-btn.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: #FFFFFF;
}

.signal-btn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  flex-shrink: 0;
}

.signal-btn.active .signal-btn-dot {
  background: #FFFFFF;
  border-color: #FFFFFF;
}

.sidebar-caption {
  margin-top: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  line-height: 1.5;
}

/* ── Main area ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.time-filter {
  display: flex;
  gap: 4px;
}

.time-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.time-btn:hover:not(.active) {
  border-color: var(--border-hover);
  background: var(--row-hover);
  color: var(--text-primary);
}

.time-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #FFFFFF;
}

/* ── Search bar ── */
.search-wrap {
  flex: 1;
  position: relative;
  max-width: 480px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  border-color: #93C5FD;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.top-bar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.updated-label {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.refresh-btn:hover:not(:disabled) {
  border-color: var(--border-hover);
  background: var(--row-hover);
  color: var(--text-primary);
}

.refresh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Content layout ── */
.content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.list-panel {
  flex: 0 1 40%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.detail-panel {
  width: 60%;
  min-width: 560px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── List header ── */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.list-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-icon {
  font-size: 18px;
}

.list-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* ── Ranked list ── */
.ranked-list {
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
}

.ranked-list::-webkit-scrollbar {
  width: 6px;
}

.ranked-list::-webkit-scrollbar-track {
  background: transparent;
}

.ranked-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Show row ── */
.show-row {
  display: flex;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s ease;
  gap: 12px;
}

.show-row:hover {
  background: var(--row-hover);
}

.show-row.active {
  background: var(--row-active);
  border-left: 3px solid var(--sparkline);
  padding-left: 21px;
}

.show-rank {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  width: 26px;
  flex-shrink: 0;
  text-align: right;
}

.show-info {
  flex: 1;
  min-width: 0;
}

.show-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.show-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.show-sparkline {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.show-rate {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
  min-width: 100px;
}

.rate-up   { color: var(--accent-up); }
.rate-down { color: var(--accent-down); }
.rate-neutral { color: var(--text-secondary); }

/* ── Event detail panel ── */
.event-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
}

.detail-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.detail-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-event-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.detail-performer {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.detail-venue {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.close-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}

.close-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--row-hover);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 170px));
  gap: 10px;
  justify-content: start;
}

.kpi-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748B;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 1.15;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-value.rate-up   { color: var(--accent-up); }
.kpi-value.rate-down { color: var(--accent-down); }

/* ── Detail charts ── */
.detail-period-bar {
  display: flex;
  gap: 4px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.period-btn {
  padding: 4px 12px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: transparent;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.period-btn:hover:not(.active) {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.period-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #FFFFFF;
}

.detail-charts {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-charts::-webkit-scrollbar {
  width: 4px;
}

.detail-charts::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.history-coverage-note {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.chart-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}

/* ── Loading & empty states ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--text-tertiary);
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.error-banner {
  padding: 10px 24px;
  background: #FEF2F2;
  border-bottom: 1px solid #FECACA;
  color: var(--accent-down);
  font-size: 13px;
  flex-shrink: 0;
}

/* ── Detail loading ── */
.detail-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 10px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ── Recharts overrides ── */
.recharts-cartesian-axis-tick-value {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--text-tertiary);
}

.recharts-tooltip-wrapper {
  outline: none;
}

.chart-tooltip {
  background: var(--navy);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: var(--shadow-md);
}

.chart-tooltip-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 4px;
}

.chart-tooltip-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
}

/* ═══════════════════════════════════════════════════════════
   ── Chat FAB ──
   ═══════════════════════════════════════════════════════════ */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 1000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--navy);
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(13, 27, 46, 0.32), 0 1px 4px rgba(13, 27, 46, 0.16);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.chat-fab:hover {
  background: var(--navy-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(13, 27, 46, 0.36), 0 2px 6px rgba(13, 27, 46, 0.18);
}

.chat-fab:active {
  transform: translateY(0);
}

.chat-fab--open {
  background: #334155;
}

/* ═══════════════════════════════════════════════════════════
   ── Chat backdrop ──
   ═══════════════════════════════════════════════════════════ */
.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(13, 27, 46, 0.18);
  backdrop-filter: blur(1px);
  animation: fadeIn 0.22s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   ── Chat panel ──
   ═══════════════════════════════════════════════════════════ */
.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 620px;
  z-index: 1002;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: -4px 0 32px rgba(13, 27, 46, 0.14), -1px 0 0 var(--border);
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.chat-panel--open {
  transform: translateX(0);
}

/* ── Chat header ── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: var(--navy);
  color: #FFFFFF;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.9);
}

.chat-header-title {
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: 0.01em;
}

.chat-header-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 1px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-close-btn,
.chat-clear-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-close-btn:hover,
.chat-clear-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
}

/* ── Chat messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── Empty state ── */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 24px 20px;
  gap: 10px;
  color: var(--text-secondary);
}

.chat-empty-icon {
  color: var(--navy);
  margin-bottom: 4px;
}

.chat-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-empty-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 280px;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
}

.chat-suggestion {
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
  line-height: 1.4;
}

.chat-suggestion:hover:not(:disabled) {
  border-color: var(--navy);
  background: #EFF6FF;
  transform: translateY(-1px);
}

.chat-suggestion:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Message rows ── */
.chat-message {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-message--user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--navy);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

/* ── Bubbles ── */
.chat-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
}

.chat-bubble--assistant {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.chat-bubble--user {
  background: var(--navy);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

/* ── Markdown prose inside assistant bubble ── */
.chat-bubble--assistant p {
  margin: 0 0 6px;
  line-height: 1.6;
}
.chat-bubble--assistant p:last-child { margin-bottom: 0; }

.chat-bubble--assistant h1,
.chat-bubble--assistant h2,
.chat-bubble--assistant h3 {
  font-size: 13.5px;
  font-weight: 700;
  margin: 10px 0 4px;
  color: var(--text-primary);
}

.chat-bubble--assistant ul,
.chat-bubble--assistant ol {
  margin: 4px 0 6px;
  padding-left: 18px;
}
.chat-bubble--assistant li { margin-bottom: 3px; }

.chat-bubble--assistant strong { font-weight: 700; }
.chat-bubble--assistant em    { font-style: italic; }

.chat-inline-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: rgba(147, 197, 253, 0.12);
  border: 1px solid rgba(147, 197, 253, 0.2);
  border-radius: 3px;
  padding: 1px 4px;
}

/* ── Typing dots ── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typingBounce 1.2s ease infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1;   }
}

/* ── Input area ── */
.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  resize: none;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

.chat-input::placeholder { color: var(--text-tertiary); }

.chat-input:focus {
  border-color: #93C5FD;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: none;
  background: var(--navy);
  color: #FFFFFF;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--navy-light);
  transform: translateY(-1px);
}

.chat-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* ── SQL code block inside chat bubble ── */
.chat-code-block {
  background: #2a2927;
  color: #93C5FD;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 6px 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid rgba(147, 197, 253, 0.15);
}

.chat-code-block code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  padding: 0;
}

/* ═══════════════════════════════════════════════════════════
   ── All Events page ──
   ═══════════════════════════════════════════════════════════ */

/* The list panel can grow wider since table needs room */
.all-events-list-panel {
  flex: 1 1 0;
  min-width: 0;
}

/* ── Filter panel ── */
.filter-panel {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filter-panel-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 10px 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-align: left;
  transition: background 0.12s ease;
}

.filter-panel-toggle:hover {
  background: var(--row-hover);
}

.filter-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.filter-panel-title {
  flex: 1;
}

.filter-chevron {
  transition: transform 0.18s ease;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.filter-chevron.open {
  transform: rotate(180deg);
}

.filter-panel-body {
  padding: 10px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-top: 1px solid var(--border);
}

.saved-filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto 1fr;
  gap: 8px;
  align-items: start;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.saved-filter-default-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 22px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.saved-filter-default-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent, #2563eb);
}

.saved-filter-default-label {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 700;
}

.saved-filter-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.saved-filter-label {
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.saved-filter-name-wrap {
  position: relative;
  display: block;
}

.filter-input.saved-filter-name-input {
  width: 100%;
  min-width: 0;
  padding-right: 34px;
  background: var(--surface);
  font-weight: 700;
}

.filter-input.saved-filter-name-input::placeholder {
  color: var(--text-tertiary);
  font-style: italic;
  font-weight: 600;
  opacity: 1;
}

.saved-filter-menu-toggle {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 26px;
  height: 26px;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.saved-filter-menu-toggle:hover {
  background: var(--row-hover);
  color: var(--text-primary);
}

.saved-filter-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.saved-filter-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
}

.saved-filter-menu button:last-child {
  border-bottom: none;
}

.saved-filter-menu button:hover,
.saved-filter-menu button.is-active {
  background: var(--row-hover);
  color: var(--text-primary);
}

.saved-filter-menu-empty {
  display: block;
  padding: 8px 10px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.saved-filter-help {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
}

.saved-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 19px;
}

.tooltip-wrap {
  position: relative;
  display: inline-flex;
}

.tooltip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  width: 240px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: #FFFFFF;
  box-shadow: var(--shadow-md);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: normal;
}

.tooltip-wrap:hover .tooltip,
.tooltip-wrap:focus-within .tooltip {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-wrap.is-disabled:hover .tooltip,
.tooltip-wrap.is-disabled:focus-within .tooltip {
  opacity: 0;
  transform: translateY(4px);
}

.filter-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.filter-table-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.filter-table-column + .filter-table-column {
  border-left: 1px solid var(--border);
}

.filter-table-heading {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--row-hover);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.filter-table-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  min-height: 70px;
  padding: 10px;
  overflow: visible;
}

.filter-table-footer {
  padding: 0 10px 10px;
}

.filter-table-empty {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.filter-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.filter-section-label--gap {
  margin-top: 10px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-table .filter-row {
  flex-wrap: wrap;
  align-items: flex-start;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}

.filter-table .filter-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.filter-select {
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  min-width: 120px;
  transition: border-color 0.12s ease;
}

.filter-table .filter-select {
  flex: 1 1 145px;
  min-width: 0;
}

.filter-select:focus {
  border-color: #93C5FD;
}

.filter-op {
  font-size: 13px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.filter-input {
  height: 30px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.filter-input:focus {
  border-color: #93C5FD;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.filter-input--num {
  width: 80px;
}

.filter-table .filter-input--num,
.filter-table .filter-input--date {
  flex: 1 1 96px;
  min-width: 0;
  width: auto;
}

.filter-input--date {
  width: 128px;
  min-width: 0;
}

.filter-input--text {
  flex: 1;
  min-width: 0;
}

.filter-table .filter-input--text {
  flex-basis: 160px;
}

.searchable-select {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  flex-basis: 160px;
}

.searchable-select-input {
  flex: 1;
  min-width: 0;
  padding-right: 30px;
}

.searchable-select-toggle {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 24px;
  height: 26px;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}

.searchable-select-toggle:hover:not(:disabled) {
  background: var(--row-hover);
  color: var(--text-primary);
}

.searchable-select-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.searchable-select.is-disabled .searchable-select-input {
  color: var(--text-tertiary);
}

.searchable-select.is-open {
  z-index: 20;
}

.searchable-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 12;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.searchable-select-menu--fixed {
  position: fixed;
  z-index: 2000;
  right: auto;
}

.searchable-select-menu button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
}

.searchable-select-menu button:last-child {
  border-bottom: none;
}

.searchable-select-menu button:hover,
.searchable-select-menu button.is-active {
  background: var(--row-hover);
  color: var(--text-primary);
}

.searchable-select-empty {
  display: block;
  padding: 8px 10px;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.filter-remove {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1.5px solid #FECACA;
  background: transparent;
  color: var(--accent-down);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease;
}

.filter-remove:hover {
  background: #FEF2F2;
}

.filter-add-btn,
.filter-save-btn,
.filter-secondary-btn,
.filter-danger-btn {
  height: 30px;
  align-self: flex-start;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}

.filter-add-btn,
.filter-secondary-btn {
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--text-secondary);
}

.filter-save-btn {
  border: 1.5px solid var(--navy);
  background: var(--navy);
  color: #FFFFFF;
}

.filter-save-btn:disabled {
  border-color: var(--border);
  background: var(--border);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.filter-danger-btn {
  border: 1.5px solid #FECACA;
  background: transparent;
  color: var(--accent-down);
}

.filter-add-btn:hover,
.filter-secondary-btn:hover {
  border-color: var(--navy);
  color: var(--navy);
  background: var(--row-hover);
}

.filter-save-btn:not(:disabled):hover {
  background: var(--navy-light);
}

.filter-danger-btn:hover {
  background: #FEF2F2;
}

/* Table scroll container */
.events-table-wrap {
  flex: 1;
  overflow: auto;
  overflow-x: auto;
  background: var(--surface);
}

.events-table-wrap::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.events-table-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Table itself */
.events-table {
  width: 100%;
  min-width: 1480px;
  border-collapse: collapse;
  font-size: 12.5px;
  white-space: nowrap;
}

.events-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.events-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.12s ease;
}

.events-table th:hover {
  color: var(--text-primary);
}

.events-table th.active {
  color: var(--text-primary);
}

.events-table th.num,
.events-table td.num {
  text-align: right;
  max-width: 96px;
  padding-left: 8px;
  padding-right: 8px;
}

.events-table th.col-marketplace,
.events-table td.col-marketplace {
  padding-right: 6px;
}

.events-table th.col-trans-24h,
.events-table td.col-trans-24h {
  padding-left: 4px;
}

.sort-indicator {
  font-size: 10px;
  margin-left: 3px;
  opacity: 0.7;
}

.events-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s ease;
}

.events-table tbody tr:hover {
  background: var(--row-hover);
}

.events-table tbody tr.active {
  background: var(--row-active);
  box-shadow: inset 3px 0 0 var(--sparkline);
}

.events-table td {
  padding: 10px 14px;
  color: var(--text-primary);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.events-table td:first-child {
  font-weight: 600;
}

.events-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 96px 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.events-pagination-meta,
.events-pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.events-pagination-controls {
  margin-left: auto;
}

.events-page-size-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.events-page-size-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 4px 8px;
}

.events-pagination-range,
.events-pagination-page {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.events-page-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 0.75rem;
  padding: 6px 12px;
  cursor: pointer;
}

.events-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.events-page-btn:not(:disabled):hover {
  border-color: var(--text-secondary);
}

/* ── Inline trend chart ── */
.chat-chart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 4px 6px 4px;
  margin: 6px 0 8px;
  width: 100%;
  min-width: 0;      /* prevent recharts from blowing out the bubble */
  overflow: hidden;
}

/* ── Sidebar user + sign-out ── */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}

.sidebar-user {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.35;
  word-break: break-word;
}

/* ── Sign-out button ── */
.signout-btn {
  margin-top: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 6px 10px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: color 0.15s, border-color 0.15s;
}

.signout-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

/* ── Login screen ── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 10px;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin: 0 0 28px;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-btn:hover {
  opacity: 0.88;
}

.login-btn--microsoft {
  background: #2b2b2b;
  color: #fff;
}

.login-btn--microsoft:hover {
  opacity: 0.92;
}

.login-btn-ms-logo {
  flex-shrink: 0;
}
