:root {
  --bg: #000000;
  --panel: #0a0a0a;
  --panel-2: #141414;
  --border: #2a2a2a;
  --text: #e2e8f0;
  --muted: #888888;
  --accent: #ce004f;
  --user: #ce004f;
  --error: #dc2626;
  --mode-accent: var(--accent);
}
#view-chat[data-mode="slack"] { --mode-accent: #e01e5a; }
#view-chat[data-mode="sql"] { --mode-accent: #22c55e; }
#view-chat[data-mode="bitbucket"] { --mode-accent: #2684ff; }
#view-chat[data-mode="atlassian"] { --mode-accent: #0052cc; }
#view-chat[data-mode="sentry"] { --mode-accent: #7553ff; }
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  font:
    14px/1.5 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#top-bar {
  padding: 12px 20px;
  height: 64px;
  flex-shrink: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
#top-bar .brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
#top-bar .app-title {
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  align-self: flex-start;
  cursor: pointer;
  transition:
    text-shadow 160ms ease,
    transform 160ms ease;
}
#top-bar .app-title:hover {
  text-shadow: 0 0 14px rgba(206, 0, 79, 0.55);
}
#top-bar .app-title:active {
  transform: translateY(1px);
}
#top-bar .app-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Glitch / multi-font cyberpunk title effect */
#top-bar .app-title:not([data-glitch-init="1"]),
#login-screen .login-card h1:not([data-glitch-init="1"]) {
  visibility: hidden;
}
.glitch-host {
  display: inline-flex;
  align-items: center;
  height: 1em;
  line-height: 1;
  overflow: visible;
}
.glitch-char {
  display: inline-block;
  position: relative;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-align: center;
  vertical-align: top;
  overflow: visible;
  transition: font-family 80ms linear;
  will-change: transform, text-shadow;
}
.font-orbitron {
  font-family: "Orbitron", system-ui, sans-serif;
  font-weight: 900;
}
.font-audiowide {
  font-family: "Audiowide", system-ui, sans-serif;
  font-weight: 400;
}
.font-major-mono {
  font-family: "Major Mono Display", monospace;
  font-weight: 400;
  text-transform: lowercase;
}
.font-iceland {
  font-family: "Iceland", system-ui, sans-serif;
  font-weight: 400;
}
.font-vt323 {
  font-family: "VT323", monospace;
  font-weight: 400;
}
.font-press-start {
  font-family: "Press Start 2P", monospace;
  font-weight: 400;
}
.font-russo {
  font-family: "Russo One", system-ui, sans-serif;
  font-weight: 400;
}
.font-syncopate {
  font-family: "Syncopate", system-ui, sans-serif;
  font-weight: 700;
}
.font-wallpoet {
  font-family: "Wallpoet", system-ui, sans-serif;
  font-weight: 400;
}
.font-faster {
  font-family: "Faster One", system-ui, sans-serif;
  font-weight: 400;
}
.font-monoton {
  font-family: "Monoton", system-ui, sans-serif;
  font-weight: 400;
}
.font-black-ops {
  font-family: "Black Ops One", system-ui, sans-serif;
  font-weight: 400;
}
.font-bungee {
  font-family: "Bungee", system-ui, sans-serif;
  font-weight: 400;
}
.font-rubik-glitch {
  font-family: "Rubik Glitch", system-ui, sans-serif;
  font-weight: 400;
}

@keyframes glitch-flicker {
  0% {
    transform: translate(0, 0);
    text-shadow: none;
    opacity: 1;
  }
  15% {
    transform: translate(-2px, 1px);
    text-shadow:
      2px 0 #ff2bd6,
      -2px 0 #00fff9;
    opacity: 0.85;
  }
  30% {
    transform: translate(2px, -1px);
    text-shadow:
      -2px 0 #ff2bd6,
      2px 0 #00fff9;
    opacity: 1;
  }
  45% {
    transform: translate(-1px, -2px) skewX(-4deg);
    text-shadow:
      1px 0 #ff2bd6,
      -1px 0 #00fff9;
    opacity: 0.9;
  }
  60% {
    transform: translate(1px, 1px) skewX(3deg);
    text-shadow: none;
    opacity: 1;
  }
  75% {
    transform: translate(0, -1px);
    text-shadow: 1px 0 #00fff9;
    opacity: 0.95;
  }
  100% {
    transform: translate(0, 0);
    text-shadow: none;
    opacity: 1;
  }
}
.glitch-char.glitching {
  animation: glitch-flicker 260ms steps(7, end);
}
@media (prefers-reduced-motion: reduce) {
  .glitch-char.glitching {
    animation: none;
  }
  .glitch-char {
    transition: none;
  }
}
#top-bar .app-subtitle {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.3px;
}
#top-bar nav {
  display: flex;
  gap: 2px;
  margin-left: 32px;
}
#top-bar nav button {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition:
    color 0.15s,
    background 0.15s;
}
#top-bar nav button:hover {
  color: var(--text);
  background: var(--panel-2);
}
#top-bar nav button.active {
  color: var(--accent);
  background: var(--panel-2);
  font-weight: 600;
}

/* View panels */
.view-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.view-panel.active {
  display: flex;
}

/* Schema / Rules / Glossary panels share styling */
.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.panel-content h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px;
}
.panel-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.panel-toolbar h2 {
  margin: 0;
}
.panel-toolbar button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.panel-toolbar button:hover {
  filter: brightness(1.1);
}
.panel-toolbar .spacer {
  flex: 1;
}
.panel-toolbar .status-text {
  font-size: 12px;
  color: var(--muted);
}

.item-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.item-card .item-body {
  flex: 1;
  min-width: 0;
}
.item-card .item-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  word-break: break-word;
}
.item-card .item-desc {
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
}
.item-card .item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}
.item-card .item-meta span {
  margin-right: 12px;
}
.item-card .item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.item-card .item-actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.item-card .item-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.item-card .item-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.item-card .item-actions button.primary:hover {
  filter: brightness(1.08);
  color: #fff;
}
.item-card .item-actions button.delete:hover {
  border-color: var(--error);
  color: var(--error);
}
.item-card .item-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.item-triggers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.item-triggers span {
  background: rgba(206, 0, 79, 0.12);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}
/* Inline pill that marks the scope of a rule / glossary term (Global,
 * or DB: <name>). Sits next to ``.item-name``; muted so the term
 * itself stays the primary signal in the row. */
.scope-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  vertical-align: middle;
}
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 14px;
}

/* Schema view */
.schema-table-group {
  margin-bottom: 20px;
}
.schema-table-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.schema-cols {
  font-size: 12px;
}
.schema-cols .schema-col {
  display: flex;
  gap: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}
.schema-cols .schema-col:hover {
  background: var(--panel-2);
}
.schema-cols .col-name {
  font-weight: 500;
  min-width: 200px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.schema-cols .col-type {
  color: var(--muted);
  min-width: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.schema-cols .col-nullable {
  color: var(--muted);
  font-size: 11px;
}
.schema-filter {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  width: 260px;
  outline: none;
}
.schema-filter:focus {
  border-color: var(--accent);
}

/* Form modal for add/edit */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
}
.form-group textarea {
  resize: vertical;
  min-height: 80px;
}
.form-help {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.form-required-mark {
  color: var(--error);
  margin-left: 2px;
  font-weight: 600;
}
.form-error {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
}
.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error select {
  border-color: var(--error);
}
.form-group.has-error input:focus,
.form-group.has-error textarea:focus,
.form-group.has-error select:focus {
  border-color: var(--error);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}
/* Inline checkbox + label combo used by the showFormModal ``checkbox``
 * field type. The standalone block-level ``<label>`` above is hidden;
 * this wrapper sits in its place and keeps the input + caption on the
 * same line. */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.form-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
}
#app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Sidebar */
#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
#sidebar .sb-header {
  padding: 0 14px;
  min-height: 52px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
#sidebar .sb-header h2 {
  font-size: 14px;
  margin: 0;
  flex: 1;
  font-weight: 600;
}
#sidebar button.icon {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
#sidebar button.icon:hover {
  filter: brightness(1.1);
}
#sessions {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.session-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 2px;
}
.session-item:hover {
  background: var(--panel-2);
}
.session-item.active {
  background: var(--panel-2);
  border: 1px solid var(--accent);
}
.session-item .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-item .icon-btn {
  opacity: 0;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
}
.session-item:hover .icon-btn {
  opacity: 1;
}
.session-item .icon-btn.confirm {
  opacity: 1;
  color: var(--accent);
}
.session-item .icon-btn.confirm:hover {
  background: var(--accent);
  color: white;
}
.session-item .icon-btn.delete:hover {
  background: var(--error);
  color: white;
}
.session-item .title {
  user-select: none;
}
.session-item.active .title {
  cursor: text;
}
.session-item .pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse 1.2s infinite ease-in-out;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}
.session-item .rename-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
  outline: none;
}
.empty-list {
  color: var(--muted);
  font-size: 12px;
  padding: 12px;
  text-align: center;
}

/* Main column */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
header {
  padding: 0 20px;
  min-height: 52px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
}
header h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}
header .spacer {
  flex: 1;
}
header button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
header button:hover {
  color: var(--text);
  border-color: var(--muted);
}

#messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  min-width: 0;
}
.msg.user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.bubble {
  padding: 10px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
/* User bubbles preserve raw whitespace (typed input).
   Assistant bubbles render markdown so we don't want pre-wrap on the container. */
.msg.user .bubble {
  white-space: pre-wrap;
}

.bubble.md > *:first-child {
  margin-top: 0;
}
.bubble.md > *:last-child {
  margin-bottom: 0;
}
.bubble.md p {
  margin: 6px 0;
}
.bubble.md ul,
.bubble.md ol {
  margin: 6px 0;
  padding-left: 22px;
}
.bubble.md li {
  margin: 2px 0;
}
.bubble.md h1,
.bubble.md h2,
.bubble.md h3,
.bubble.md h4 {
  margin: 10px 0 6px;
  font-weight: 600;
  line-height: 1.25;
}
.bubble.md h1 {
  font-size: 18px;
}
.bubble.md h2 {
  font-size: 16px;
}
.bubble.md h3 {
  font-size: 14px;
}
.bubble.md h4 {
  font-size: 13px;
  color: var(--muted);
}
.bubble.md code {
  background: rgba(255, 159, 196, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}
.bubble.md pre {
  background: #1a1a1a;
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  max-width: 100%;
  margin: 8px 0;
}
.bubble.md pre code {
  background: transparent;
  padding: 0;
  font-size: 12px;
  color: #cbd5e1;
}
.bubble.md blockquote {
  border-left: 3px solid var(--border);
  margin: 6px 0;
  padding: 2px 10px;
  color: var(--muted);
}
.bubble.md table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}
.bubble.md th,
.bubble.md td {
  border: 1px solid var(--border);
  padding: 4px 8px;
}
.bubble.md a {
  color: #ff9fc4;
}
.bubble.md hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.msg.user .bubble {
  background: var(--mode-accent);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg.assistant .bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.error .bubble {
  background: var(--error);
  color: white;
}

/* Slack references (collapsible, same pattern as details.sql) */
details.slack-references {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
details.slack-references > summary {
  padding: 6px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  user-select: none;
}
details.slack-references > summary:hover {
  color: var(--text);
}
.slack-ref {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.slack-ref-meta {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 3px;
}
.slack-ref-text {
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.4;
}

.meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  transition: opacity 0.15s;
}
.msg:hover .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
}
.msg.user .msg-actions {
  flex-direction: row-reverse;
}
/* Stack bubble content vertically so the time can sit on its own line at the
   bottom-right; this also ensures the bubble grows wide enough to contain the
   time for short messages (no overflow, no clipping). */
.bubble {
  display: flex;
  flex-direction: column;
}
.bubble-time {
  align-self: flex-end;
  margin-top: 4px;
  font-size: 10px;
  line-height: 1;
  opacity: 0.65;
  user-select: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.msg.user .bubble-time {
  color: rgba(255, 255, 255, 0.75);
}
.msg.assistant .bubble-time {
  color: var(--muted);
}
.msg-action-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.msg-action-btn:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel-2);
}
.msg-action-btn.icon-only {
  padding: 3px 5px;
}
.action-icon {
  width: 13px;
  height: 13px;
  display: block;
}
.data-action.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.data-action .action-icon {
  width: 12px;
  height: 12px;
}
.msg-action-btn.thumb {
  font-size: 13px;
  padding: 1px 5px;
  filter: grayscale(0.8);
}
.msg-action-btn.thumb:hover {
  filter: grayscale(0);
}
.msg-action-btn.thumb.active {
  filter: grayscale(0);
  border-color: var(--accent);
  background: rgba(206, 0, 79, 0.12);
}
.msg-action-btn.flash {
  color: var(--accent);
  border-color: var(--accent);
}

details.sql,
details.data {
  margin-top: 8px;
  width: 100%;
  max-width: 800px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
details.sql summary,
details.data summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
details.sql summary,
details.data summary {
  display: flex;
  align-items: center;
  gap: 12px;
}
details.sql summary .summary-text,
details.data summary .summary-text {
  flex: 1;
}
.data-action {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
}
.data-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.connect-cta-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.connect-cta-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.connect-cta-btn:hover {
  background: #a8003f;
  border-color: #a8003f;
}
.connect-cta-btn:disabled,
.connect-cta-btn.connected {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--muted);
  cursor: default;
}
.connect-cta-btn:disabled:hover,
.connect-cta-btn.connected:hover {
  background: var(--panel-2);
  border-color: var(--border);
}
.truncation-note {
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 159, 196, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  background: var(--accent);
  color: white;
}
th .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--accent);
  min-width: 10px;
}
th.sortable:hover .sort-arrow {
  color: white;
}
th.num .col-name {
  font-variant-numeric: tabular-nums;
}
details.thinking {
  margin-top: 8px;
  width: 100%;
  max-width: 800px;
  background: transparent;
  border-left: 2px solid var(--border);
  padding: 2px 10px;
}
details.thinking summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  user-select: none;
  font-style: italic;
  list-style: none;
}
details.thinking summary::-webkit-details-marker {
  display: none;
}
details.thinking summary::before {
  content: "\25B8 ";
  display: inline-block;
  transition: transform 0.15s;
}
details.thinking[open] summary::before {
  content: "\25BE ";
}
.thinking-step {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.thinking-step .step-label {
  color: var(--accent);
  font-weight: 600;
  margin-right: 4px;
}
.thinking-step .step-thought {
  color: var(--text);
  opacity: 0.75;
}
.thinking-step pre {
  margin: 4px 0 0;
  padding: 6px 8px;
  background: rgba(255, 159, 196, 0.06);
  border-radius: 4px;
  font-size: 11px;
  color: #cbd5e1;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
pre.sql-code {
  margin: 8px 0 0;
  padding: 10px;
  background: #1a1a1a;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  color: #cbd5e1;
}

/* Mode controls — Scope dropdown.
 *
 * The agent uses every available tool by default. Picking SQL / Slack /
 * Bitbucket from the dropdown is an explicit scope override; picking
 * "All sources" clears the scope back to the default. */
.mode-controls {
  position: relative;
  display: inline-flex;
  align-items: center;
  user-select: none;
}
.mode-scope {
  position: relative;
}
.mode-scope-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}
.mode-scope-trigger:hover {
  color: var(--text);
  border-color: var(--text);
}
.mode-scope-caret {
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform 0.2s;
}
.mode-scope-trigger[aria-expanded="true"] .mode-scope-caret {
  transform: rotate(180deg);
}
/* Active scope: trigger borrows the scope's accent color. */
.mode-scope-trigger.active {
  color: var(--text);
  border-color: var(--text);
}
.mode-scope-trigger.active[data-scope="slack"] {
  color: #e01e5a;
  border-color: #e01e5a;
  background: #e01e5a14;
}
.mode-scope-trigger.active[data-scope="bitbucket"] {
  color: #2684ff;
  border-color: #2684ff;
  background: #2684ff14;
}
.mode-scope-trigger.active[data-scope="atlassian"] {
  color: #0052cc;
  border-color: #0052cc;
  background: #0052cc1f;
}
.mode-scope-trigger.active[data-scope="sentry"] {
  color: #7553ff;
  border-color: #7553ff;
  background: #7553ff1f;
}

.mode-scope-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mode-scope-menu[hidden] {
  display: none;
}
.mode-scope-menu [role="menuitem"] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.mode-scope-menu [role="menuitem"] svg {
  flex-shrink: 0;
  opacity: 0.85;
}
.mode-scope-menu [role="menuitem"]:hover {
  background: var(--panel-2);
}
.mode-scope-menu [role="menuitem"].active {
  background: var(--panel-2);
}
.mode-scope-menu [role="menuitem"].active::after {
  content: "✓";
  margin-left: auto;
  opacity: 0.7;
}
.mode-scope-divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}
/* Dynamic per-DB scope items, inserted below the static "SQL" button.
 * Indent them slightly so the visual hierarchy reads as "SQL → these
 * specific DBs are queryable". The kind label (postgres / mongodb +
 * object count) is muted so the DB name remains the primary signal. */
.mode-scope-db-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 2px solid var(--border);
  margin: 0 6px;
  padding-left: 6px;
}
.mode-scope-db-item {
  /* Inherits .mode-scope-menu [role="menuitem"] styles via attribute
   * selector; this rule only adds the per-DB-specific tweaks. */
  font-size: 12px;
}
.mode-scope-db-item .mode-scope-db-kind {
  margin-left: 4px;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.6;
}

/* ===== Slack mode visual theme ===== */
#view-chat[data-mode="slack"] #main {
  background: #1a1025;
}
#view-chat[data-mode="slack"] #messages {
  background: linear-gradient(180deg, #1a1025 0%, #110b1a 100%);
}
#view-chat[data-mode="slack"] #main header {
  background: #1e1230;
  border-color: #3a2255;
}
#view-chat[data-mode="slack"] #main header h1 {
  color: #e8a0c0;
}
#view-chat[data-mode="slack"] #composer {
  background: #1e1230;
  border-color: #3a2255;
}
#view-chat[data-mode="slack"] #composer textarea {
  background: #130d1e;
  border-color: #3a2255;
}
#view-chat[data-mode="slack"] #composer textarea:focus {
  border-color: #e01e5a;
}
#view-chat[data-mode="slack"] #sidebar {
  background: #150e20;
  border-color: #3a2255;
}
#view-chat[data-mode="slack"] #sidebar .sb-header {
  border-color: #3a2255;
}
#view-chat[data-mode="slack"] #sidebar button.icon {
  background: #e01e5a;
}
#view-chat[data-mode="slack"] .session-item.active {
  border-color: #e01e5a66;
  background: #2a1540;
}
#view-chat[data-mode="slack"] .session-item:hover {
  background: #221335;
}
#view-chat[data-mode="slack"] .context-usage-fill {
  background: #e01e5a;
}

/* ===== SQL mode visual theme ===== */
#view-chat[data-mode="sql"] #main {
  background: #101a14;
}
#view-chat[data-mode="sql"] #messages {
  background: linear-gradient(180deg, #101a14 0%, #0a1410 100%);
}
#view-chat[data-mode="sql"] #main header {
  background: #142218;
  border-color: #1f3a2a;
}
#view-chat[data-mode="sql"] #main header h1 {
  color: #a0e8c0;
}
#view-chat[data-mode="sql"] #composer {
  background: #142218;
  border-color: #1f3a2a;
}
#view-chat[data-mode="sql"] #composer textarea {
  background: #0c1812;
  border-color: #1f3a2a;
}
#view-chat[data-mode="sql"] #composer textarea:focus {
  border-color: #22c55e;
}
#view-chat[data-mode="sql"] #sidebar {
  background: #0e1a12;
  border-color: #1f3a2a;
}
#view-chat[data-mode="sql"] #sidebar .sb-header {
  border-color: #1f3a2a;
}
#view-chat[data-mode="sql"] #sidebar button.icon {
  background: #22c55e;
}
#view-chat[data-mode="sql"] .session-item.active {
  border-color: #22c55e66;
  background: #15401f;
}
#view-chat[data-mode="sql"] .session-item:hover {
  background: #132e1a;
}
#view-chat[data-mode="sql"] .context-usage-fill {
  background: #22c55e;
}

/* ===== Bitbucket mode visual theme ===== */
#view-chat[data-mode="bitbucket"] #main {
  background: #0a1428;
}
#view-chat[data-mode="bitbucket"] #messages {
  background: linear-gradient(180deg, #0a1428 0%, #060e1f 100%);
}
#view-chat[data-mode="bitbucket"] #main header {
  background: #0e1832;
  border-color: #1a2c52;
}
#view-chat[data-mode="bitbucket"] #main header h1 {
  color: #a0c0e8;
}
#view-chat[data-mode="bitbucket"] #composer {
  background: #0e1832;
  border-color: #1a2c52;
}
#view-chat[data-mode="bitbucket"] #composer textarea {
  background: #080d22;
  border-color: #1a2c52;
}
#view-chat[data-mode="bitbucket"] #composer textarea:focus {
  border-color: #2684ff;
}
#view-chat[data-mode="bitbucket"] #sidebar {
  background: #0c1228;
  border-color: #1a2c52;
}
#view-chat[data-mode="bitbucket"] #sidebar .sb-header {
  border-color: #1a2c52;
}
#view-chat[data-mode="bitbucket"] #sidebar button.icon {
  background: #2684ff;
}
#view-chat[data-mode="bitbucket"] .session-item.active {
  border-color: #2684ff66;
  background: #142950;
}
#view-chat[data-mode="bitbucket"] .session-item:hover {
  background: #11183a;
}
#view-chat[data-mode="bitbucket"] .context-usage-fill {
  background: #2684ff;
}

/* ===== Atlassian mode visual theme ===== */
#view-chat[data-mode="atlassian"] #main {
  background: #0a1024;
}
#view-chat[data-mode="atlassian"] #messages {
  background: linear-gradient(180deg, #0a1024 0%, #060a1c 100%);
}
#view-chat[data-mode="atlassian"] #main header {
  background: #0e1430;
  border-color: #1a234d;
}
#view-chat[data-mode="atlassian"] #main header h1 {
  color: #a8bce8;
}
#view-chat[data-mode="atlassian"] #composer {
  background: #0e1430;
  border-color: #1a234d;
}
#view-chat[data-mode="atlassian"] #composer textarea {
  background: #080b22;
  border-color: #1a234d;
}
#view-chat[data-mode="atlassian"] #composer textarea:focus {
  border-color: #0052cc;
}
#view-chat[data-mode="atlassian"] #sidebar {
  background: #0c1028;
  border-color: #1a234d;
}
#view-chat[data-mode="atlassian"] #sidebar .sb-header {
  border-color: #1a234d;
}
#view-chat[data-mode="atlassian"] #sidebar button.icon {
  background: #0052cc;
}
#view-chat[data-mode="atlassian"] .session-item.active {
  border-color: #0052cc66;
  background: #122150;
}
#view-chat[data-mode="atlassian"] .session-item:hover {
  background: #10173a;
}
#view-chat[data-mode="atlassian"] .context-usage-fill {
  background: #0052cc;
}

#view-chat[data-mode="sentry"] #main {
  background: #150f2b;
}
#view-chat[data-mode="sentry"] #messages {
  background: linear-gradient(180deg, #150f2b 0%, #0d0820 100%);
}
#view-chat[data-mode="sentry"] #main header {
  background: #1c1438;
  border-color: #2d2256;
}
#view-chat[data-mode="sentry"] #main header h1 {
  color: #c9bdef;
}
#view-chat[data-mode="sentry"] #composer {
  background: #1c1438;
  border-color: #2d2256;
}
#view-chat[data-mode="sentry"] #composer textarea {
  background: #110b26;
  border-color: #2d2256;
}
#view-chat[data-mode="sentry"] #composer textarea:focus {
  border-color: #7553ff;
}
#view-chat[data-mode="sentry"] #sidebar {
  background: #170f2e;
  border-color: #2d2256;
}
#view-chat[data-mode="sentry"] #sidebar .sb-header {
  border-color: #2d2256;
}
#view-chat[data-mode="sentry"] #sidebar button.icon {
  background: #7553ff;
}
#view-chat[data-mode="sentry"] .session-item.active {
  border-color: #7553ff66;
  background: #271b53;
}
#view-chat[data-mode="sentry"] .session-item:hover {
  background: #1e1640;
}
#view-chat[data-mode="sentry"] .context-usage-fill {
  background: #7553ff;
}

.cache-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
  white-space: nowrap;
}
.cache-toggle:hover {
  color: var(--text);
  border-color: var(--text);
}
.cache-toggle.active {
  color: #22c55e;
  border-color: #22c55e44;
  background: #22c55e0d;
}
.cache-toggle.active:hover {
  border-color: #22c55e88;
}
.cache-toggle .cache-toggle-icon {
  flex-shrink: 0;
  display: block;
}
.cache-toggle .cache-toggle-label {
  font-weight: 500;
}

.cache-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  opacity: 0.7;
}

.table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 100%;
  max-height: 400px;
  overflow-y: auto;
}
table {
  border-collapse: collapse;
  font-size: 12px;
  width: 100%;
}
th,
td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  background: var(--panel-2);
  position: sticky;
  top: 0;
  font-weight: 600;
  color: var(--text);
}
tr:hover td {
  background: rgba(255, 159, 196, 0.08);
}
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.null {
  color: var(--muted);
  font-style: italic;
}

/* Context usage indicator (above composer) */
.context-usage {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 20px;
  justify-content: flex-end;
  opacity: 0.45;
  transition: opacity 0.3s ease;
}
.context-usage:hover {
  opacity: 0.85;
}
.context-usage-bar {
  height: 2px;
  background: var(--panel-2);
  border-radius: 1px;
  overflow: hidden;
  width: 80px;
}
.context-usage-fill {
  height: 100%;
  border-radius: 1px;
  background: var(--muted);
  transition:
    width 0.3s ease,
    background-color 0.3s ease;
  width: 0%;
}
.context-usage-fill.warn {
  background: #e6a700;
}
.context-usage-fill.critical {
  background: var(--error, #e53935);
}
.context-usage-label {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

#composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
#composer .composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#composer.dragover {
  background: rgba(255, 159, 196, 0.06);
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
}
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 14, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none;
  animation: drop-overlay-fade 120ms ease-out;
}
.drop-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 36px;
  border: 2px dashed var(--accent, #ff5577);
  border-radius: 14px;
  background: rgba(20, 20, 26, 0.92);
  color: var(--fg, #eee);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: drop-overlay-pop 160ms ease-out;
}
.drop-overlay-icon {
  color: var(--accent, #ff5577);
}
.drop-overlay-title {
  font-size: 16px;
  font-weight: 600;
}
.drop-overlay-sub {
  font-size: 12px;
  color: var(--muted, #999);
}
@keyframes drop-overlay-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes drop-overlay-pop {
  from { transform: scale(0.96); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}
.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 2px 6px 0;
}
.composer-attachment {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  animation: composer-attachment-in 140ms ease-out;
}
@keyframes composer-attachment-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
.composer-attachment .thumb {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  cursor: zoom-in;
  display: block;
  background: transparent;
  border: 0;
  padding: 0;
}
.composer-attachment .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 120ms ease-out;
}
.composer-attachment .thumb:hover img {
  transform: scale(1.05);
}
.composer-attachment .remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--panel);
  background: rgba(20, 20, 24, 0.92);
  color: white;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 120ms ease-out, transform 120ms ease-out, background 120ms;
}
.composer-attachment:hover .remove,
.composer-attachment:focus-within .remove,
.composer-attachment .remove:focus {
  opacity: 1;
  transform: scale(1);
}
.composer-attachment .remove:hover {
  background: var(--mode-accent);
}
.composer-icon-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease-out, transform 120ms ease-out;
}
.composer-icon-btn:hover {
  color: var(--mode-accent);
}
.composer-icon-btn:active {
  transform: scale(0.92);
}
.composer-icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.msg.user .bubble-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.msg.user .bubble-images img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 6px;
  display: block;
  cursor: zoom-in;
  transition: transform 120ms ease-out;
}
.msg.user .bubble-images img:hover {
  transform: scale(1.02);
}
.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: image-preview-fade 120ms ease-out;
  padding: 32px;
}
@keyframes image-preview-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.image-preview-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
#composer textarea {
  flex: 1;
  resize: none;
  height: 44px;
  max-height: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
}
#composer textarea:focus {
  border-color: var(--accent);
}
#composer #send {
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--mode-accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
#composer #send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#composer #send.stop {
  background: var(--error);
  padding: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#composer #send.stop::after {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 2px;
}

.live-thinking {
  width: 100%;
  max-width: 800px;
  border-left: 2px solid var(--accent);
  padding: 4px 12px;
  background: rgba(255, 159, 196, 0.04);
  border-radius: 0 6px 6px 0;
}
.live-thinking .live-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  padding: 3px 0;
  color: var(--muted);
}
.live-thinking .live-row .live-icon {
  width: 12px;
  flex-shrink: 0;
  color: var(--accent);
  display: inline-block;
}
.live-thinking .live-row .live-label {
  flex: 1;
}
.live-thinking .live-row .live-time {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  opacity: 0.7;
}
.live-thinking .live-row.active .live-label {
  color: var(--text);
}
.live-thinking .live-row.active .live-icon {
  animation: spin 1s linear infinite;
}
.live-thinking .live-row.done .live-icon {
  color: #4ade80;
  animation: none;
}
.live-thinking .live-thought {
  margin: 2px 0 6px 20px;
  font-size: 11px;
  color: var(--text);
  opacity: 0.7;
  font-style: italic;
}
.live-thinking.finished {
  opacity: 0.6;
  border-left-color: var(--border);
  margin-bottom: 8px;
}

/* Typing indicator row */
.live-thinking .typing-indicator {
  color: var(--text);
  gap: 6px;
}
.live-thinking .typing-indicator .live-icon {
  animation: none;
}
.live-thinking .typing-indicator .typing {
  margin-left: 2px;
}
.live-thinking .typing-indicator .typing span {
  background: var(--accent);
}

/* Fade-in for new rows */
.live-thinking .fade-in {
  animation: fadeSlideIn 0.25s ease-out;
}
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shimmer on active panel */
.live-thinking:not(.finished) {
  background: linear-gradient(
    90deg,
    rgba(255, 159, 196, 0.04) 0%,
    rgba(255, 159, 196, 0.1) 50%,
    rgba(255, 159, 196, 0.04) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2.5s ease-in-out infinite;
}
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Composer elapsed timer */
.composer-timer {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  padding: 0 8px;
  white-space: nowrap;
  opacity: 0.8;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Clarification options */
.clarify-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.clarify-options button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.clarify-options button:hover {
  border-color: var(--accent);
  background: rgba(255, 159, 196, 0.12);
  color: white;
}
.clarify-input-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.clarify-input-row input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.clarify-input-row input:focus {
  border-color: var(--accent);
}
.clarify-input-row button {
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.clarify-input-row button:hover {
  filter: brightness(1.1);
}

/* Learn proposals — "Should I remember this for next time?" */
.learn-proposals {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: rgba(255, 159, 196, 0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.learn-proposals-header {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.learn-proposal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.learn-proposal-summary {
  flex: 1 1 240px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.learn-proposal-text {
  word-break: break-word;
}
.learn-proposal-actions {
  display: flex;
  gap: 6px;
}
.learn-proposal-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  transition: filter 0.15s, border-color 0.15s, background 0.15s;
}
.learn-proposal-btn.confirm {
  background: var(--accent);
  color: white;
  border-color: transparent;
}
.learn-proposal-btn.confirm:hover:not(:disabled) {
  filter: brightness(1.1);
}
.learn-proposal-btn.dismiss:hover:not(:disabled) {
  border-color: var(--accent);
}
.learn-proposal-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.learn-proposal-status {
  font-size: 12px;
  color: var(--muted);
  flex-basis: 100%;
}
.learn-proposal-status:empty {
  display: none;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

/* Custom modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: modalFadeIn 0.15s ease;
}
@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-width: 340px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.15s ease;
  /* Cap height so tall forms (the provider editor) don't overflow the
   * viewport. ``.modal-content`` below scrolls; title + actions stay
   * pinned via the flex layout. */
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
/* Field/content region scrolls; title sits above, actions stay below.
 * showFormModal wraps every field group in this container. */
.modal-content {
  overflow-y: auto;
  flex: 1 1 auto;
  /* Compensate for the inner scrollbar so focus rings on text inputs
   * don't get clipped by the right edge. */
  padding-right: 4px;
  margin-right: -4px;
  min-height: 0;
}
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}
.modal-message {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 20px;
  line-height: 1.5;
  /* Preserve newlines authored in the message string so multi-section
   * dialogs can use bullets/lists without injecting HTML. Long lines
   * still wrap naturally. */
  white-space: pre-line;
}
.modal-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.15s;
}
.modal-input:focus {
  border-color: var(--accent);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  /* Keep the buttons visible at the bottom of the modal when the form
   * content scrolls (provider editor and similar tall forms). */
  flex-shrink: 0;
  margin-top: 16px;
}
/* Inline status row used by showFormModal custom-action handlers
 * (e.g. "Test connection" in the Databases tab). Sits between the
 * form content and the action buttons. Hidden until a handler writes
 * to it. */
.modal-inline-status {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.modal-inline-status.is-ok {
  background: rgba(40, 167, 69, 0.12);
  border-color: rgba(40, 167, 69, 0.45);
  color: var(--text);
}
.modal-inline-status.is-error {
  background: rgba(220, 53, 69, 0.12);
  border-color: rgba(220, 53, 69, 0.45);
  color: var(--text);
}
.modal-btn[disabled],
.modal-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.modal-btn {
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  transition:
    background 0.15s,
    border-color 0.15s;
}
.modal-btn:hover {
  border-color: var(--muted);
  background: var(--border);
}
.modal-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.modal-btn.primary:hover {
  background: #a8003f;
  border-color: #a8003f;
}
.modal-btn.danger {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}
.modal-btn.danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* ----- Modal decorative icons (used by showModal({ icon: 'success' })) -----
 * Two-stage animation:
 *   1. The circle scales in with a slight overshoot (spring easing).
 *   2. The checkmark glyph draws itself in via stroke-dashoffset.
 * Centered above the title; we also center the title/message text on
 * iconified modals so the visual hierarchy reads top-down. */
.modal-box.has-icon .modal-title,
.modal-box.has-icon .modal-message {
  text-align: center;
}
.modal-box.has-icon .modal-actions {
  justify-content: center;
}
.modal-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.modal-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0);
  animation: modalIconPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s forwards;
}
@keyframes modalIconPop {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
/* Stroke-draw animation for the glyph inside the circle. The dasharray
 * is intentionally generous (~40) — covers the longest path we use
 * (the checkmark is ~25 units). */
.modal-icon-stroke {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: modalIconDraw 0.35s ease-out 0.35s forwards;
}
@keyframes modalIconDraw {
  to {
    stroke-dashoffset: 0;
  }
}
/* Success — Slack-ish green; for "connected" / completed positive actions. */
.modal-icon-success .modal-icon-circle {
  background: rgba(46, 182, 125, 0.15);
  border: 2px solid #2eb67d;
  color: #2eb67d;
}
/* Info — muted neutral; for "disconnected" / completed but non-celebratory. */
.modal-icon-info .modal-icon-circle {
  background: rgba(148, 163, 184, 0.12);
  border: 2px solid var(--muted);
  color: var(--muted);
}

/* Import preview */
.import-preview {
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.import-turn {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9em;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.import-turn--user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  max-width: 80%;
}
.import-turn--assistant {
  background: var(--panel);
  border: 1px solid var(--border);
  align-self: flex-start;
  max-width: 80%;
}

/* Share button in chat header */
.share-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.share-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Login screen */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}
#login-screen.hidden {
  display: none;
}
#login-screen .login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
#login-screen .login-card h1 {
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}
#login-screen .login-card p {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 14px;
}
#login-screen .login-card .login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 12px;
}
#login-screen .login-card .login-divider::before,
#login-screen .login-card .login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
#login-screen .login-apikey-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}
#login-screen .login-apikey-btn:hover {
  background: var(--border);
}
#google-signin-container {
  display: flex;
  justify-content: center;
}
#login-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

/* Download toast — fixed bottom-left */
.download-toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface, #1e1e2e);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--fg, #ccc);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  animation: dl-slide-in 0.3s ease;
}
@keyframes dl-slide-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.download-toast .dl-icon {
  color: var(--accent);
  flex-shrink: 0;
  animation: dl-bounce 1.2s ease infinite;
}
@keyframes dl-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(2px);
  }
}
.download-toast .dl-progress-ring {
  flex-shrink: 0;
}
.download-toast .dl-progress-ring.spin svg {
  animation: dl-spin 1s linear infinite;
}
@keyframes dl-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
.download-toast .dl-status {
  white-space: nowrap;
}
.download-toast.done .dl-icon {
  color: #4caf50;
  animation: none;
}
.download-toast.error .dl-icon {
  color: #ef5350;
  animation: none;
}

/* Toast container — bottom-right stack for transient notices */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 48px));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  background: var(--surface, #1e1e2e);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, #ff5577);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--fg, #ddd);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  animation: toast-slide-in 180ms ease-out;
}
.toast.leaving {
  animation: toast-slide-out 180ms ease-in forwards;
}
.toast-error { border-left-color: #ef5350; }
.toast-info { border-left-color: #4ea3ff; }
.toast-success { border-left-color: #4caf50; }
.toast-text {
  flex: 1;
  word-wrap: break-word;
}
.toast-close {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--muted, #888);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  margin-top: -1px;
}
.toast-close:hover { color: var(--fg, #ddd); }
@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-slide-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* User avatar / menu in top bar */
.user-menu {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.user-menu .user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color 0.15s;
}
.user-menu .user-avatar:hover {
  border-color: var(--accent);
}
.user-menu .user-name {
  font-size: 12px;
  color: var(--muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Same visual affordance as the avatar — the whole user-menu area is a
   * dropdown trigger, so the name needs to look clickable too (matters
   * when the Google profile picture fails to load and the avatar is
   * hidden). */
  cursor: pointer;
}
.user-menu .user-name:hover {
  color: var(--text);
}
.user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
}
.user-dropdown.open {
  display: block;
}
.user-dropdown button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 8px 16px;
  text-align: left;
  cursor: pointer;
}
.user-dropdown button:hover {
  background: var(--panel-2);
}

/* Hamburger toggle (hidden on desktop) */
.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.menu-toggle:hover {
  border-color: var(--muted);
}

/* Sidebar backdrop (mobile only) */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 499;
  display: none;
}
.sidebar-backdrop.open {
  display: block;
}

/* ===================== Dashboard view ===================== */
#view-dashboard {
  min-height: 0;
}
#dashboard-sidebar {
  width: 240px;
  min-width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#dashboard-sidebar .sb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  min-height: 52px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}
#dashboard-sidebar .sb-header h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#dashboard-sidebar .sb-header button.icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
}
#dashboard-sidebar .sb-header button.icon:hover {
  color: var(--text);
  border-color: var(--muted);
}
#dashboard-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.dashboard-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  transition:
    background 0.12s,
    color 0.12s;
}
.dashboard-item:hover {
  background: var(--panel-2);
  color: var(--text);
}
.dashboard-item.active {
  background: var(--panel-2);
  color: var(--text);
}
.dashboard-item .d-name {
  font-weight: 600;
  font-size: 13px;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dashboard-item .d-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: center;
}
.dashboard-item .d-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
}
.dashboard-item .d-badge.muted {
  background: var(--border);
  color: var(--muted);
}

#dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
#dashboard-main header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  min-height: 52px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
#dashboard-main header h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
#dashboard-main header .meta {
  font-size: 11px;
  color: var(--muted);
}
#dashboard-main header .spacer {
  flex: 1;
}
#dashboard-actions {
  display: flex;
  gap: 6px;
}
#dashboard-actions button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}
#dashboard-actions button:hover {
  color: var(--text);
  border-color: var(--muted);
}
#dashboard-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}
#dashboard-actions button.danger {
  color: var(--error);
}

#dashboard-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.dashboard-chart-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  min-height: 360px;
  display: flex;
  flex-direction: column;
}
.dashboard-chart-wrap canvas {
  max-height: 420px;
}
.dashboard-stat {
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  padding: 40px 0;
}
.dashboard-stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}
.dashboard-cache-info {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dashboard-sql-details {
  margin-top: 14px;
}
.dashboard-sql-details pre {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12px;
  margin: 6px 0 0;
}
.dashboard-chart-type-select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  margin-left: auto;
}

/* Pivot table */
.pivot-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.pivot-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.pivot-field label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.pivot-field select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.pivot-field select:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.pivot-dim-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.pivot-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 6px 2px 10px;
  font-size: 12px;
  color: var(--text);
}
.pivot-chip-label {
  font-weight: 600;
}
.pivot-chip-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1;
}
.pivot-chip-btn:hover:not(:disabled) {
  color: var(--text);
  background: var(--panel-2);
}
.pivot-chip-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.pivot-chip-remove {
  color: var(--error, #f87171);
}
.pivot-chip-remove:hover:not(:disabled) {
  color: #fff;
  background: var(--error, #ef4444);
}
select.pivot-add {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
}
select.pivot-add:hover {
  color: var(--text);
  border-color: var(--text);
}
.pivot-table-wrap {
  overflow-x: auto;
}
.pivot-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
.pivot-table th,
.pivot-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  white-space: nowrap;
}
.pivot-table thead th {
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.pivot-table .pivot-corner {
  background: var(--panel);
  color: var(--muted);
  font-style: italic;
}
.pivot-table .pivot-row-label {
  background: var(--panel-2);
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.pivot-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pivot-table tfoot th,
.pivot-table tfoot td,
.pivot-table .pivot-total {
  background: var(--panel);
  font-weight: 700;
  color: var(--accent);
}
.pivot-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* Dashboard chat drawer */
#dashboard-chat {
  width: 320px;
  min-width: 300px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    width 0.25s ease,
    min-width 0.25s ease,
    max-height 0.25s ease;
}
#dashboard-chat.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
  overflow: hidden;
}
#dashboard-chat .sb-header {
  display: flex;
  align-items: center;
  padding: 0 14px;
  min-height: 52px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}
#dashboard-chat .sb-header h2 {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chat-collapse-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.chat-collapse-btn:hover {
  color: var(--text);
  background: var(--panel-2);
}
.chat-toggle-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-right: none;
  width: 20px;
  height: 48px;
  border-radius: 6px 0 0 6px;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.chat-toggle-btn:hover {
  color: var(--text);
  background: var(--border);
}
.chat-toggle-btn.visible {
  display: flex;
}
#view-dashboard {
  position: relative;
}
#dashboard-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dash-msg {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 95%;
  line-height: 1.4;
  word-wrap: break-word;
}
.dash-msg.user {
  background: var(--user);
  color: white;
  align-self: flex-end;
}
.dash-msg.assistant {
  background: var(--panel-2);
  color: var(--text);
  align-self: flex-start;
}
.dash-msg.assistant .dm-sql {
  display: block;
  margin-top: 6px;
  padding: 6px 8px;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  color: var(--muted);
  max-height: 160px;
  overflow-y: auto;
}
.dash-msg.assistant .dm-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.dash-msg.assistant .dm-actions button {
  background: var(--accent);
  color: white;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.dash-msg.assistant .dm-actions button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.dash-msg.assistant .dm-actions button.secondary:hover {
  color: var(--text);
  border-color: var(--muted);
}
.dash-msg.error {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: var(--error);
  align-self: flex-start;
}
.dash-msg.thinking {
  background: var(--panel-2);
  color: var(--muted);
  font-style: italic;
  align-self: flex-start;
}
.dash-msg.assistant.timeline-only {
  background: transparent;
  padding: 0;
  max-width: 100%;
  width: 100%;
}
.dash-msg .clarify-options {
  margin-top: 8px;
}
.dash-msg .clarify-options button {
  font-size: 12px;
  padding: 4px 10px;
}
.dash-msg .clarify-input-row {
  margin-top: 6px;
}
.dash-msg .clarify-input-row input {
  font-size: 12px;
}
#dashboard-chat-form {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
#dashboard-chat-form textarea {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 16px;
  resize: none;
  font-family: inherit;
}
#dashboard-chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
#dashboard-chat-send {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#dashboard-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===================== Mobile ===================== */
@media (max-width: 768px) {
  /* Top bar compaction */
  #top-bar {
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px 0;
    height: auto;
    position: relative;
  }
  #top-bar .app-subtitle {
    display: none;
  }
  #top-bar nav {
    order: 1;
    width: 100%;
    margin-left: 0;
    gap: 0;
    justify-content: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #top-bar nav::-webkit-scrollbar {
    display: none;
  }
  #top-bar nav button {
    padding: 5px 10px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  #top-bar .user-name {
    display: none;
  }
  #top-bar .app-title {
    font-size: 18px;
  }
  #top-bar .brand {
    margin: 0 auto;
    align-items: center;
    height: 1em;
    line-height: 1;
  }
  #top-bar .user-menu {
    position: absolute;
    top: 8px;
    right: 10px;
    margin-left: 0;
  }

  /* Show hamburger */
  .menu-toggle {
    display: block;
  }

  /* Sidebar becomes a slide-in drawer */
  #view-chat {
    flex-direction: column !important;
  }
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 500;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.5);
  }
  #sidebar.open {
    transform: translateX(0);
  }

  .download-toast {
    left: 24px;
  }

  /* Main chat area */
  #main header {
    padding: 10px 12px;
    gap: 8px;
  }
  #main header h1 {
    font-size: 14px;
  }
  #main header .meta {
    display: none;
  }
  .mode-scope-trigger {
    padding: 4px 8px;
    font-size: 11px;
  }
  .mode-scope-trigger svg:not(.mode-scope-caret) {
    display: none;
  }
  .cache-toggle {
    padding: 4px 8px;
    gap: 0;
  }
  .cache-toggle .cache-toggle-label {
    display: none;
  }

  #messages {
    padding: 12px;
    gap: 12px;
  }
  .msg {
    max-width: 100%;
  }

  #composer {
    padding: 10px 12px;
  }
  #composer textarea {
    padding: 8px 10px;
  }

  /* Other panels */
  .panel-content {
    padding: 16px 12px;
    overflow-x: hidden;
  }
  .panel-toolbar {
    flex-wrap: wrap;
  }
  .panel-toolbar h2 {
    font-size: 16px;
  }
  .schema-filter {
    width: 100%;
  }
  #schema-namespace {
    width: 100% !important;
  }

  /* Schema columns: drop fixed min-widths, allow wrapping */
  .schema-cols .schema-col {
    flex-wrap: wrap;
    gap: 4px 12px;
  }
  .schema-cols .col-name,
  .schema-cols .col-type {
    min-width: 0;
  }
  .schema-table-group h3 {
    word-break: break-word;
  }

  /* Cards stack on narrow screens */
  .item-card {
    flex-direction: column;
    gap: 8px;
  }
  .item-card .item-actions {
    align-self: flex-end;
  }

  /* Modals */
  .modal-box {
    min-width: 0;
    width: 92%;
    max-width: 92% !important;
    padding: 18px;
  }
  .modal-input,
  .form-group input,
  .form-group textarea {
    font-size: 16px !important;
  }

  /* Inline detail panels grow to full width */
  details.sql,
  details.data,
  .live-thinking,
  details.thinking,
  details.slack-references {
    max-width: 100%;
  }

  /* Slack references: prevent long channel/user/URL strings from overflowing */
  .slack-ref {
    padding: 8px 10px;
  }
  .slack-ref-meta {
    word-break: break-word;
  }
  .slack-ref-text {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  /* Login */
  #login-screen .login-card {
    padding: 32px 24px;
  }

  /* Dashboard view stacks vertically on mobile */
  #view-dashboard {
    flex-direction: column !important;
  }
  #dashboard-sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 160px;
  }
  #dashboard-chat {
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 300px;
    transition: max-height 0.25s ease;
  }
  #dashboard-chat.collapsed {
    width: 100%;
    max-height: 0;
    border-top: none;
  }
  .chat-toggle-btn {
    right: 50%;
    transform: translateX(50%);
    top: auto;
    bottom: 0;
    width: 48px;
    height: 20px;
    border-radius: 6px 6px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
  }
  .chat-toggle-btn span {
    display: inline-block;
    transform: rotate(+90deg);
  }
}

/* ===================== Stats view ===================== */
.stats-panel {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.stats-hero {
  position: relative;
  background:
    radial-gradient(
      120% 200% at 0% 0%,
      rgba(206, 0, 79, 0.28) 0%,
      transparent 55%
    ),
    radial-gradient(
      120% 200% at 100% 100%,
      rgba(54, 197, 240, 0.18) 0%,
      transparent 55%
    ),
    linear-gradient(135deg, #120410 0%, #0a0a0a 60%, #04101a 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  margin-bottom: 24px;
  overflow: hidden;
  isolation: isolate;
}
.stats-hero-glow {
  position: absolute;
  inset: -40%;
  background: conic-gradient(
    from 0deg,
    rgba(206, 0, 79, 0.18),
    transparent 25%,
    rgba(54, 197, 240, 0.12) 50%,
    transparent 75%,
    rgba(206, 0, 79, 0.18)
  );
  filter: blur(60px);
  animation: stats-spin 22s linear infinite;
  z-index: 0;
  opacity: 0.65;
  pointer-events: none;
}
@keyframes stats-spin {
  to {
    transform: rotate(360deg);
  }
}
.stats-hero-inner {
  position: relative;
  z-index: 1;
}
.stats-hero-label {
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.stats-hero-number {
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 88px;
  line-height: 1;
  font-weight: 900;
  background: linear-gradient(135deg, #ff3b86 0%, #ce004f 45%, #ff7a00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(206, 0, 79, 0.35);
  letter-spacing: 1px;
}
.stats-hero-sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stats-card {
  position: relative;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px 16px;
  overflow: hidden;
  transition:
    transform 160ms ease,
    border-color 160ms ease;
}
.stats-card:hover {
  transform: translateY(-2px);
  border-color: rgba(206, 0, 79, 0.5);
}
.stats-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--card-tint, rgba(206, 0, 79, 0.18)) 0%,
    transparent 60%
  );
  opacity: 0.55;
  pointer-events: none;
}
.stats-card > * {
  position: relative;
  z-index: 1;
}
.stats-card-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--icon-bg, rgba(206, 0, 79, 0.18));
  color: var(--icon-fg, #ff3b86);
  font-size: 18px;
  margin-bottom: 12px;
}
.stats-card-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.stats-card-value {
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: 0.5px;
}
.stats-card-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.stats-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
.stats-chart-card,
.stats-feedback-card,
.stats-top-card {
  padding: 20px 22px;
}
.stats-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.stats-card-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.stats-card-sub {
  color: var(--muted);
  font-size: 12px;
}
.stats-chart-wrap {
  position: relative;
  width: 100%;
  height: 240px;
}

.stats-feedback-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
  margin-bottom: 12px;
}
.stats-feedback-up {
  background: linear-gradient(90deg, #36c5f0, #2eb67d);
  transition: flex-basis 600ms ease;
}
.stats-feedback-down {
  background: linear-gradient(90deg, #ce004f, #dc2626);
  transition: flex-basis 600ms ease;
}
.stats-feedback-legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.stats-feedback-legend b {
  color: var(--text);
}
.stats-up-dot {
  color: #2eb67d;
}
.stats-down-dot {
  color: #ff3b86;
}

.stats-top-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stats-top-row {
  display: grid;
  grid-template-columns: 28px 1fr 80px 60px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.stats-top-rank {
  font-family: "Orbitron", system-ui, sans-serif;
  font-weight: 700;
  color: var(--accent);
  font-size: 14px;
}
.stats-top-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-top-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}
.stats-top-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--pct, 0%);
  background: linear-gradient(90deg, var(--accent), #ff7a00);
  transition: width 600ms ease;
}
.stats-top-count {
  text-align: right;
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
}

@media (max-width: 760px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-row {
    grid-template-columns: 1fr;
  }
  .stats-hero {
    padding: 24px 22px;
  }
  .stats-hero-number {
    font-size: 56px;
  }
  .stats-top-row {
    grid-template-columns: 28px 1fr 60px;
  }
  .stats-top-row .stats-top-bar {
    display: none;
  }
}

/* Admin view — segmented-control tab nav.
   Scoped under `.admin-subnav` so the selectors hit specificity (0,2,0),
   beating the global `.panel-toolbar button` (0,1,1) that would otherwise
   force a filled-accent style with white text. */
.admin-subnav {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.admin-subnav .admin-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease,
              border-color 120ms ease, box-shadow 120ms ease;
}
.admin-subnav .admin-tab:hover {
  filter: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.admin-subnav .admin-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25),
              0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}
.admin-subnav .admin-tab.active:hover {
  filter: brightness(1.05);
  color: #fff;
}
.admin-subnav .admin-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(206, 0, 79, 0.45);
}
.admin-tab-panel {
  margin-top: 12px;
}
.admin-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.admin-add-row input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
}
.admin-add-row button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.admin-add-row button:hover {
  filter: brightness(1.1);
}
.item-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  vertical-align: middle;
  font-weight: 500;
}
.item-badge.ok {
  background: rgba(76, 175, 80, 0.18);
  color: #7ed68a;
}
.item-badge.warn {
  background: rgba(255, 152, 0, 0.18);
  color: #ffb74d;
}
.admin-prompt-preview {
  position: relative;
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid var(--accent);
  border-radius: 2px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  max-height: 140px;
  overflow: hidden;
}
.admin-prompt-preview::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32px;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 10, 0) 0%,
    var(--panel) 100%
  );
  pointer-events: none;
}
/* Markdown editor — Write/Preview tabs inside the form modal. */
.md-editor {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}
.md-editor-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 6px 0;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.md-editor-tabs .md-tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 6px 6px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease,
              border-color 120ms ease;
}
.md-editor-tabs .md-tab:hover {
  color: var(--text);
}
.md-editor-tabs .md-tab.active {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
  position: relative;
  z-index: 1;
  margin-bottom: -1px;
}
.md-editor-tabs .md-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.md-editor textarea.md-editor-textarea {
  width: 100%;
  border: none;
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  min-height: 200px;
}
.md-editor textarea.md-editor-textarea:focus {
  border: none;
  box-shadow: inset 0 0 0 2px rgba(206, 0, 79, 0.35);
}
.md-tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(206, 0, 79, 0.18);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.md-editor-diff {
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  padding: 8px 0;
}
.md-editor-diff .md-editor-empty {
  color: var(--muted);
  font-style: italic;
  padding: 8px 14px;
}
.md-diff-line {
  display: flex;
  gap: 6px;
  padding: 1px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.md-diff-line .md-diff-marker {
  flex-shrink: 0;
  width: 12px;
  text-align: center;
  color: var(--muted);
  user-select: none;
}
.md-diff-line .md-diff-text {
  flex: 1;
  min-width: 0;
}
.md-diff-same {
  color: var(--muted);
}
.md-diff-add {
  background: rgba(76, 175, 80, 0.12);
  color: #b8e6bf;
}
.md-diff-add .md-diff-marker {
  color: #7ed68a;
}
.md-diff-del {
  background: rgba(220, 38, 38, 0.14);
  color: #f3b0b0;
}
.md-diff-del .md-diff-text {
  text-decoration: line-through;
  text-decoration-color: rgba(220, 38, 38, 0.5);
}
.md-diff-del .md-diff-marker {
  color: #f08585;
}

/* Admin — card list spacing */
.admin-card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-card-list .item-card {
  margin-bottom: 0;
}

/* Admin — channel card refinements */
.admin-channel-card {
  transition: border-color 120ms ease, background 120ms ease;
}
.admin-channel-card:hover {
  border-color: rgba(206, 0, 79, 0.35);
}
.admin-channel-card.is-configured {
  background: linear-gradient(
    180deg,
    rgba(206, 0, 79, 0.04) 0%,
    var(--panel) 100%
  );
}
.admin-hint {
  margin-top: 6px;
  font-style: italic;
}
.admin-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.admin-meta-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10.5px;
  color: var(--muted);
  opacity: 0.7;
}

/* Admin — service-account bindings inside a channel card */
.admin-bindings {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.admin-bindings-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.admin-bindings-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-binding {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.admin-binding-tool {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(206, 0, 79, 0.14);
  color: var(--accent);
  min-width: 76px;
  text-align: center;
}
.admin-binding-email {
  color: var(--text);
  word-break: break-all;
  min-width: 0;
}

/* Admin — section grouping in users tab */
.admin-section {
  margin-bottom: 24px;
}
.admin-section:last-child {
  margin-bottom: 0;
}
.admin-section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.admin-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
}
.admin-section-count {
  font-size: 11px;
  color: var(--muted);
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}
.admin-section-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Admin — framed "Grant admin" card */
.admin-add-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}
.admin-add-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.admin-add-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.admin-add-card .admin-add-row {
  margin-bottom: 0;
}

/* Admin — empty state polish */
.admin-empty {
  padding: 56px 20px;
}
.admin-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.admin-empty-desc {
  font-size: 13px;
  color: var(--muted);
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.5;
}
