/* =============================================================================
   TEMPO MONITOR — mobile-first dark theme
   ============================================================================= */

:root {
  --bg: #06080f;
  --bg-2: #0a0d17;
  --surface: #0f1320;
  --surface-2: #161b2c;
  --surface-3: #1e2438;
  --border: rgba(148, 163, 184, 0.08);
  --border-strong: rgba(148, 163, 184, 0.18);
  --border-glow: rgba(96, 165, 250, 0.25);
  --text: #e8edf7;
  --text-2: #a7b0c5;
  --muted: #6b7389;
  --accent: #60a5fa;
  --accent-2: #22d3ee;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --accent-gradient: linear-gradient(135deg, #60a5fa 0%, #22d3ee 100%);
  --accent-gradient-soft: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(34, 211, 238, 0.2));
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --sidebar-w: 288px;
  --mobile-bar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
}

body.booting { visibility: hidden; }

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(800px 500px at 10% 0%, rgba(96, 165, 250, 0.08), transparent 60%),
    radial-gradient(700px 600px at 100% 100%, rgba(34, 211, 238, 0.06), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.svg-defs { position: absolute; width: 0; height: 0; }

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* =============================================================================
   LOGIN SCREEN
   ============================================================================= */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(96, 165, 250, 0.15), transparent 65%),
    radial-gradient(500px 400px at 80% 90%, rgba(34, 211, 238, 0.10), transparent 65%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
}

.logo-mark.large {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 14px;
  margin-bottom: 4px;
  box-shadow: inset 0 0 0 1px var(--border-glow);
}

.logo-mark.large svg { width: 36px; height: 36px; }

.login-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.24em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.btn-block { width: 100%; justify-content: center; margin-top: 8px; }

.login-error {
  padding: 10px 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  color: #fecaca;
  font-size: 13px;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* =============================================================================
   MOBILE TOP BAR
   ============================================================================= */

.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mobile-bar-h);
  padding: 0 12px;
  padding-top: var(--safe-top);
  align-items: center;
  gap: 8px;
  background: rgba(10, 13, 23, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

.mobile-bar[data-visible="true"] { display: flex; }

.mobile-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.mobile-btn:active { background: var(--surface-2); }

.mobile-logo {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.mobile-logo span {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mobile-logo em {
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.24em;
}

/* =============================================================================
   LAYOUT
   ============================================================================= */

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 16px;
  padding-top: calc(24px + var(--safe-top));
  background: linear-gradient(180deg, rgba(15, 19, 32, 0.92), rgba(6, 8, 15, 0.96));
  border-right: 1px solid var(--border);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

.main {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: transparent;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 15, 0.6);
  backdrop-filter: blur(4px);
  z-index: 25;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.backdrop[data-visible="true"] {
  opacity: 1;
  pointer-events: auto;
}

/* =============================================================================
   BRAND
   ============================================================================= */

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--border-glow);
}

.logo-mark svg { width: 24px; height: 24px; }

.logo-text { display: flex; flex-direction: column; line-height: 1; }

.logo-primary {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-secondary {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--muted);
}

.sidebar-close {
  display: none;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
}

.sidebar-close:active { background: var(--surface-2); }

/* =============================================================================
   CONNECTION STATUS
   ============================================================================= */

.conn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.conn[data-status="ok"] .conn-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
  animation: pulse 2s ease-in-out infinite;
}

.conn[data-status="error"] .conn-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.15);
}

.conn[data-status="loading"] .conn-dot {
  background: var(--warn);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.conn-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.conn-state { font-size: 12px; font-weight: 600; color: var(--text); }
.conn-meta {
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =============================================================================
   SEARCH TRIGGER
   ============================================================================= */

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
}

.search-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.search-trigger span { flex: 1; text-align: left; }

.kbd-desktop { display: none; }
@media (min-width: 900px) { .kbd-desktop { display: inline-flex; } }

kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
}

/* =============================================================================
   NAV
   ============================================================================= */

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }

.nav-section-label {
  padding: 12px 12px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  position: relative;
  min-height: 44px;
}

.nav-item:hover { background: var(--surface); color: var(--text); }

.nav-item[aria-current="page"] {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.nav-item[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent-gradient);
  border-radius: 0 3px 3px 0;
}

.nav-item-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--nav-color, var(--accent));
  flex-shrink: 0;
}

.nav-item-icon .icon { width: 14px; height: 14px; }
.nav-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-item-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 2px 8px;
  background: var(--surface-2);
  border-radius: 10px;
  min-width: 24px;
  text-align: center;
}

/* =============================================================================
   SIDEBAR FOOTER / USER / INSTALL
   ============================================================================= */

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.install-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
}

.install-btn:hover {
  background: rgba(96, 165, 250, 0.2);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.user-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--accent-gradient);
  color: #061020;
  font-weight: 700;
  font-size: 13px;
  border-radius: 50%;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta { font-size: 10px; color: var(--muted); letter-spacing: 0.04em; }

.user-logout {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
}

.user-logout:hover { background: var(--surface-2); color: var(--danger); }
.user-logout .icon { width: 16px; height: 16px; }

/* =============================================================================
   CONTENT
   ============================================================================= */

.content {
  padding: 20px 16px 80px;
  max-width: 1400px;
  margin: 0 auto;
  padding-bottom: calc(80px + var(--safe-bottom));
}

.content-header { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }

.content-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}

.content-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, var(--text) 0%, #94a3b8 120%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.content-subtitle { color: var(--text-2); font-size: 13px; margin: 0; line-height: 1.5; }

/* =============================================================================
   KPI TILES
   ============================================================================= */

.section-label {
  margin: 24px 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.kpi-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 14px;
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.kpi-tile::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--kpi-accent, var(--accent));
  opacity: 0.7;
}

.kpi-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--kpi-accent, var(--accent)) 0%, transparent 60%);
  opacity: 0.06;
  pointer-events: none;
}

.kpi-tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow);
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
  color: var(--kpi-accent, var(--text));
  letter-spacing: -0.02em;
}

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi-tile.kpi-critical { border-color: rgba(248, 113, 113, 0.3); }
.kpi-tile.kpi-critical .kpi-value { color: var(--danger); }

.kpi-placeholder,
.kpi-error {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
}

.kpi-error {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

/* =============================================================================
   CATEGORY / QUERY CARDS
   ============================================================================= */

.overview-grid,
.query-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.overview-card,
.query-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.query-card::before,
.overview-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient-soft);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.query-card:hover,
.overview-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow);
}

.query-card:hover::before,
.overview-card:hover::before { opacity: 0.5; }

.overview-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }

.overview-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--cat-bg, var(--accent-soft));
  color: var(--cat-color, var(--accent));
  flex-shrink: 0;
}

.overview-icon .icon { width: 18px; height: 18px; }
.overview-card h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }

.overview-count {
  font-size: 20px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overview-card p { color: var(--text-2); font-size: 12px; margin: 0; }

.query-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.query-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  padding: 2px 8px;
  background: var(--accent-soft);
  border-radius: 6px;
}

.query-params { font-size: 11px; color: var(--muted); font-weight: 500; }
.query-params.has-params { color: var(--warn); }

.query-title { font-size: 14px; font-weight: 600; line-height: 1.4; margin: 0; color: var(--text); }

.query-card-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}

.query-cta { font-size: 12px; font-weight: 600; color: var(--text-2); }
.query-card-foot .icon { width: 14px; height: 14px; color: var(--text-2); }
.query-card:hover .query-cta { color: var(--accent); }

/* =============================================================================
   QUERY DETAIL
   ============================================================================= */

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-heading { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-left: -10px;
  margin-bottom: 4px;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  width: fit-content;
}

.back-link:hover { background: var(--surface); color: var(--text); }
.back-link .icon { width: 14px; height: 14px; transform: rotate(180deg); }

.detail-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }

.detail-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  flex-wrap: wrap;
}

.detail-meta span { padding: 3px 8px; background: var(--surface); border-radius: 6px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
}

.btn:hover { border-color: var(--border-glow); background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #061020;
  box-shadow: 0 4px 14px rgba(96, 165, 250, 0.3);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(96, 165, 250, 0.45); filter: brightness(1.05); }
.btn-primary:disabled { background: var(--surface-2); color: var(--muted); box-shadow: none; }
.btn-ghost { background: transparent; }
.btn .icon { width: 14px; height: 14px; }

/* =============================================================================
   PARAMS / FIELDS
   ============================================================================= */

.params-panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.params-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}

.params-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text); }
.field-hint { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }

.field-input {
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  min-height: 44px;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-input.invalid { border-color: var(--danger); }

/* =============================================================================
   SQL PANEL
   ============================================================================= */

.sql-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.sql-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.sql-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.sql-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 11px;
  font-family: inherit;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 32px;
}

.sql-copy:hover { background: var(--surface-2); color: var(--text); }

.sql-code {
  padding: 14px;
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}

.sql-kw { color: #c084fc; font-weight: 600; }
.sql-str { color: #86efac; }
.sql-num { color: #fbbf24; }
.sql-fn  { color: #22d3ee; }
.sql-com { color: var(--muted); font-style: italic; }

/* =============================================================================
   RESULTS (table + json)
   ============================================================================= */

.results-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.results-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.results-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
  flex-wrap: wrap;
}

.results-summary strong { color: var(--text); font-weight: 700; }

.results-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.view-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.15s ease;
  min-height: 34px;
}

.view-toggle-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.view-toggle-btn .icon { width: 14px; height: 14px; }

.results-actions { display: flex; gap: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-success { background: rgba(52, 211, 153, 0.14); color: var(--success); }
.badge-warn { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* TABLE VIEW */
.table-wrap { overflow: auto; max-height: 65vh; }

.table-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

table.results-table { width: 100%; border-collapse: collapse; font-size: 12px; }

.results-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  z-index: 1;
}

.results-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  vertical-align: top;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-table tbody tr:hover { background: rgba(148, 163, 184, 0.03); }

.results-table .cell-null { color: var(--muted); font-style: italic; }
.results-table .cell-bool-true { color: var(--success); font-weight: 600; }
.results-table .cell-bool-false { color: var(--danger); font-weight: 600; }
.results-table .cell-number { color: var(--warn); }
.results-table .cell-json { color: var(--accent-2); }

/* JSON VIEW */
.json-view {
  padding: 14px;
  max-height: 65vh;
  overflow: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

.json-view::-webkit-scrollbar { width: 10px; height: 10px; }
.json-view::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; }

.json-row {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  overflow: hidden;
}

.json-row > summary {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.json-row > summary::-webkit-details-marker { display: none; }
.json-row > summary::before {
  content: '▸';
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s;
}

.json-row[open] > summary::before {
  transform: rotate(90deg);
}

.json-row > summary:hover { background: var(--surface); }

.json-row-preview {
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.json-body { padding: 4px 12px 12px 12px; }

.json-tree { padding-left: 14px; border-left: 1px dashed var(--border-strong); }

.json-prop {
  display: block;
  padding: 2px 0;
}

.json-key { color: var(--accent-2); margin-right: 6px; }
.json-key::after { content: ':'; color: var(--muted); margin-left: 1px; }

.json-val-string { color: #86efac; }
.json-val-number { color: var(--warn); }
.json-val-bool-true { color: var(--success); font-weight: 600; }
.json-val-bool-false { color: var(--danger); font-weight: 600; }
.json-val-null { color: var(--muted); font-style: italic; }

.json-collapsible {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 0 4px;
  margin-left: -4px;
  border-radius: 4px;
}

.json-collapsible:hover { background: var(--surface); }

.json-collapsible-toggle {
  font-size: 10px;
  color: var(--muted);
  user-select: none;
  display: inline-block;
  width: 10px;
}

.json-collapsible[aria-expanded="true"] .json-collapsible-toggle::before { content: '▾'; }
.json-collapsible[aria-expanded="false"] .json-collapsible-toggle::before { content: '▸'; }

.json-collapsible-summary { color: var(--muted); font-size: 11px; }

.json-nested { display: none; }
.json-collapsible[aria-expanded="true"] + .json-nested { display: block; }

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.error-panel {
  padding: 16px;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius);
  color: #fecaca;
}

.error-panel strong { color: var(--danger); display: block; margin-bottom: 4px; }
.error-panel code { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #fca5a5; }

/* =============================================================================
   MISC
   ============================================================================= */

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.center-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-2);
  text-align: center;
}

.center-state .spinner { width: 28px; height: 28px; border-width: 3px; }

/* =============================================================================
   COMMAND PALETTE
   ============================================================================= */

.palette {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
}

.palette[hidden] { display: none; }

.palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 15, 0.72);
  backdrop-filter: blur(6px);
}

.palette-box {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 80px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.palette-input-wrap .icon { color: var(--muted); width: 18px; height: 18px; }

#palette-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}

#palette-input::placeholder { color: var(--muted); }

.palette-results {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.palette-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
}

.palette-result:hover,
.palette-result[aria-selected="true"] { background: var(--surface-2); }

.palette-result .number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  padding: 2px 6px;
  background: var(--accent-soft);
  border-radius: 4px;
  flex-shrink: 0;
}

.palette-result-text { flex: 1; min-width: 0; }
.palette-result-title { font-size: 13px; font-weight: 500; color: var(--text); }
.palette-result-cat { font-size: 11px; color: var(--muted); margin-top: 2px; }
.palette-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* =============================================================================
   TOASTS
   ============================================================================= */

.toasts {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  right: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
  align-items: center;
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease;
  width: 100%;
  max-width: 420px;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent); }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =============================================================================
   HOME DASHBOARD WIDGETS
   ============================================================================= */

.home-sections { display: flex; flex-direction: column; gap: 20px; }

.home-welcome {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.home-welcome-hi {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-welcome-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, var(--text) 0%, #94a3b8 120%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.home-welcome-title .highlight {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.widget-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
}

.widget-title .icon { width: 14px; height: 14px; color: var(--muted); }

.widget-title-count {
  padding: 1px 8px;
  background: var(--surface-3);
  color: var(--text);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.widget-title-count.pulse { background: rgba(52, 211, 153, 0.15); color: var(--success); }

.widget-title-count.danger { background: var(--danger-soft); color: var(--danger); }

.widget-action {
  background: transparent;
  border: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.widget-action:hover { background: var(--surface-2); color: var(--text); }

.widget-body { padding: 12px 14px; }
.widget-body-tight { padding: 0; }

.widget-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* Live sessions */
.live-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }

.live-session {
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--success);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  font-size: 13px;
}

.live-session:hover {
  border-color: var(--success);
  transform: translateX(2px);
  box-shadow: var(--shadow);
}

.live-session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.live-session-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 60%;
  min-width: 0;
}

.live-session-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  background: var(--surface-3);
  border-radius: 4px;
  color: var(--text-2);
  flex-shrink: 0;
}

.live-session-type.sequential { background: rgba(96, 165, 250, 0.15); color: var(--accent); }
.live-session-type.concurrent { background: rgba(251, 191, 36, 0.15); color: var(--warn); }

.live-session-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.live-session-status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}

.live-session-type { white-space: nowrap; }

@media (max-width: 480px) {
  .live-session-name { flex: 1 1 100%; }
  .live-session-badges { flex: 0 0 auto; }
  .live-session-type,
  .live-session-status { font-size: 9px; padding: 2px 5px; letter-spacing: 0.04em; }
  .live-session-meta { font-size: 10.5px; gap: 10px; }
}

.live-session-status.bidding { background: rgba(52, 211, 153, 0.18); color: var(--success); }
.live-session-status.pending { background: rgba(96, 165, 250, 0.15); color: var(--accent); }
.live-session-status.paused  { background: rgba(251, 146, 60, 0.18); color: #fb923c; }

.live-session[data-status="PENDING"] { border-left-color: var(--accent); }
.live-session[data-status="PENDING"]:hover { border-color: var(--accent); }
.live-session[data-status="PAUSED"] { border-left-color: #fb923c; }
.live-session[data-status="PAUSED"]:hover { border-color: #fb923c; }

.live-session-sub {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
}

.live-session-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
}

.live-session-meta strong { color: var(--text); font-weight: 700; }

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  animation: pulse 1.5s ease-in-out infinite;
  margin-right: 6px;
  flex-shrink: 0;
}

/* Alerts */
.alerts-list { display: flex; flex-direction: column; gap: 8px; }

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: inherit;
  color: var(--text);
}

.alert-item:hover { border-color: var(--danger); transform: translateX(2px); }

.alert-icon {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  background: rgba(248, 113, 113, 0.18);
  border-radius: 8px;
  color: var(--danger);
  flex-shrink: 0;
}

.alert-icon .icon { width: 16px; height: 16px; }

.alert-text { flex: 1; min-width: 0; }
.alert-title { font-size: 13px; font-weight: 600; color: var(--text); }
.alert-desc { font-size: 11px; color: var(--text-2); margin-top: 2px; }

.alert-item.alert-warn { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.28); }
.alert-item.alert-warn:hover { border-color: var(--warn); }
.alert-item.alert-warn .alert-icon { background: rgba(251, 191, 36, 0.18); color: var(--warn); }

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 14px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: all 0.15s;
  text-align: left;
  min-height: 56px;
}

.quick-action:hover {
  border-color: var(--border-glow);
  background: var(--surface);
  transform: translateY(-1px);
}

.quick-action-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--qa-bg, var(--accent-soft));
  color: var(--qa-color, var(--accent));
  flex-shrink: 0;
}

.quick-action-icon .icon { width: 16px; height: 16px; }

.quick-action-text { flex: 1; min-width: 0; }
.quick-action-title { font-weight: 600; font-size: 13px; color: var(--text); }
.quick-action-hint { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* Activity strip */
.activity-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px 14px;
}

.activity-metric {
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-top: 2px solid var(--am-accent, var(--accent));
}

.activity-metric-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  line-height: 1;
}

.activity-metric-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Favorite star */
.fav-btn {
  width: 36px; height: 36px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.fav-btn:hover { border-color: var(--warn); color: var(--warn); }

.fav-btn[aria-pressed="true"] {
  color: var(--warn);
  border-color: var(--warn);
  background: rgba(251, 191, 36, 0.08);
}

.fav-btn[aria-pressed="true"] .icon { fill: var(--warn); }

.fav-btn .icon { width: 16px; height: 16px; }

/* Favorite mini on cards */
.fav-mini {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  z-index: 2;
}

.fav-mini .icon { width: 14px; height: 14px; }
.query-card:hover .fav-mini, .fav-mini[aria-pressed="true"] { opacity: 1; }
.fav-mini:hover { color: var(--warn); }
.fav-mini[aria-pressed="true"] { color: var(--warn); opacity: 1; }
.fav-mini[aria-pressed="true"] .icon { fill: var(--warn); }

/* Sidebar sections */
.nav-section {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 6px;
}

.nav-section-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}

.nav-section-label-row .icon { width: 12px; height: 12px; }

.nav-section-clear {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.nav-section-clear:hover { background: var(--surface); color: var(--text-2); }

.nav-quick-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  min-height: 36px;
}

.nav-quick-item:hover { background: var(--surface); color: var(--text); }

.nav-quick-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  padding: 1px 6px;
  background: var(--accent-soft);
  border-radius: 4px;
  flex-shrink: 0;
}

.nav-quick-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Local filter (search within category/results) */
.local-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.local-filter:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.local-filter .icon { color: var(--muted); flex-shrink: 0; }

.local-filter input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  min-height: 24px;
}

.local-filter input::placeholder { color: var(--muted); }

.local-filter-count {
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}

/* SQL collapsible panel */
.sql-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  flex: 1;
}

.sql-toggle::-webkit-details-marker { display: none; }

.sql-chevron {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.2s;
}

.sql-chevron .icon { width: 14px; height: 14px; }

.sql-panel details[open] .sql-chevron { transform: rotate(90deg); }

/* Row numbers + copyable cells */
.results-table .row-num {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  text-align: right;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-2);
  position: sticky;
  left: 0;
  z-index: 1;
  user-select: none;
}

.results-table thead th.row-num { background: var(--surface-2); z-index: 2; }

.results-table tbody td.cell-copyable { cursor: copy; }
.results-table tbody td.cell-copyable:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.results-table tbody td.cell-object {
  white-space: normal;
  max-width: 640px;
  min-width: 240px;
  padding: 8px 10px;
  background: var(--bg-2);
  vertical-align: top;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
}

.results-table tbody td.cell-object .json-collapsible {
  font-size: 11px;
}

.results-table tbody td.cell-object .json-tree {
  padding-left: 12px;
  border-left: 1px dashed var(--border-strong);
  margin-top: 4px;
}

.results-table tbody td.cell-object .json-prop {
  padding: 1px 0;
}

.cell-detail {
  position: fixed;
  inset: auto 16px 20px 16px;
  max-width: 540px;
  margin-left: auto;
  margin-right: auto;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
  animation: slide-in 0.2s ease;
}

.cell-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.cell-detail-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.cell-detail-close:hover { background: var(--surface-3); color: var(--text); }
.cell-detail-close .icon { width: 14px; height: 14px; }

/* =============================================================================
   CONNECTION PILL + PICKER
   ============================================================================= */

.conn {
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
  text-align: left;
  font-family: inherit;
  width: 100%;
  color: inherit;
  position: relative;
}

.conn:hover {
  border-color: var(--border-glow);
  background: var(--surface-2);
}

.conn[data-status="off"] {
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.05);
}

.conn[data-status="off"] .conn-dot {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.18);
}

.conn-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 10px;
  transition: transform 0.2s;
}

.conn-scope-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.conn-scope-dot.global { background: var(--accent); }
.conn-scope-dot.personal { background: var(--warn); }

.conn-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.conn-picker-group-label {
  padding: 10px 10px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}

.conn-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  text-align: left;
  transition: all 0.15s;
}

.conn-picker-item:hover {
  border-color: var(--border-glow);
  background: var(--surface);
}

.conn-picker-item[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.conn-picker-swatch {
  width: 10px;
  height: 34px;
  border-radius: 3px;
  background: var(--cp-color, var(--accent));
  flex-shrink: 0;
}

.conn-picker-body { flex: 1; min-width: 0; }

.conn-picker-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.conn-picker-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.conn-scope-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.conn-scope-badge.global { background: rgba(96, 165, 250, 0.16); color: var(--accent); }
.conn-scope-badge.personal { background: rgba(251, 191, 36, 0.16); color: var(--warn); }

.conn-picker-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn-picker-check {
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0;
}

.conn-picker-item[aria-pressed="true"] .conn-picker-check { opacity: 1; }

.conn-picker-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.conn-picker-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

/* =============================================================================
   CONNECTION MANAGER (admin/user manages DBs)
   ============================================================================= */

.conn-manager-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.conn-manager-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.conn-manager-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.conn-manager-title .icon { width: 14px; height: 14px; }

.conn-manager-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.conn-row {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
  position: relative;
}

.conn-row:hover { border-color: var(--border-strong); }

.conn-row-swatch {
  width: 4px;
  height: 100%;
  min-height: 48px;
  border-radius: 2px;
  background: var(--cp-color, var(--accent));
}

.conn-row-body { min-width: 0; }

.conn-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.conn-row-name { font-size: 14px; font-weight: 600; }

.conn-row-sub {
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn-row-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.icon-btn:hover { border-color: var(--border-glow); color: var(--text); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.icon-btn .icon { width: 16px; height: 16px; }

.conn-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.conn-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.conn-form-colors {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--sw);
  transition: transform 0.15s;
}

.color-swatch:hover { transform: scale(1.1); }
.color-swatch[aria-pressed="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--sw);
}

.conn-form-scope {
  display: flex;
  gap: 8px;
}

.scope-option {
  flex: 1;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  transition: all 0.15s;
}

.scope-option:hover { border-color: var(--border-glow); }
.scope-option[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.scope-option[aria-pressed="true"][data-scope="global"] {
  border-color: var(--accent);
  color: var(--accent);
}
.scope-option[aria-pressed="true"][data-scope="personal"] {
  border-color: var(--warn);
  background: rgba(251, 191, 36, 0.08);
  color: var(--warn);
}
.scope-option:disabled { opacity: 0.4; cursor: not-allowed; }

.scope-option-title { font-size: 13px; font-weight: 700; }
.scope-option-hint { font-size: 11px; opacity: 0.8; }

.conn-form-test {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

.conn-form-test.ok { background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.3); color: var(--success); }
.conn-form-test.err { background: var(--danger-soft); border: 1px solid rgba(248, 113, 113, 0.3); color: var(--danger); }

/* =============================================================================
   DESTRUCTIVE MODAL — CONNECTION BANNER
   ============================================================================= */

.modal-conn-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.18), rgba(248, 113, 113, 0.04) 80%);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
}

.modal-conn-banner[data-scope="global"] {
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.22), rgba(96, 165, 250, 0.06) 80%);
  border-color: var(--danger);
}

.modal-conn-banner-swatch {
  width: 6px;
  height: 42px;
  border-radius: 3px;
  background: var(--cp-color, var(--danger));
  flex-shrink: 0;
}

.modal-conn-banner-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: rgba(248, 113, 113, 0.18);
  border-radius: 10px;
  color: var(--danger);
  flex-shrink: 0;
}

.modal-conn-banner-body { flex: 1; min-width: 0; }

.modal-conn-banner-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--danger);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.modal-conn-banner-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.modal-conn-banner-sub {
  font-size: 11px;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =============================================================================
   HOME: NO-CONNECTION BANNER
   ============================================================================= */

.no-conn-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.12), rgba(251, 191, 36, 0.02) 80%);
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.no-conn-banner-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(251, 191, 36, 0.15);
  border-radius: 12px;
  color: var(--warn);
  flex-shrink: 0;
}

.no-conn-banner-body { flex: 1; }
.no-conn-banner-title { font-size: 15px; font-weight: 700; color: var(--text); }
.no-conn-banner-desc { font-size: 12px; color: var(--text-2); margin-top: 3px; }

/* Onboarding hero (0 connections) */
.onboarding-hero {
  padding: 40px 28px;
  background:
    radial-gradient(500px 200px at 50% 0%, rgba(96, 165, 250, 0.18), transparent 70%),
    linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.onboarding-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--accent-gradient);
  display: grid;
  place-items: center;
  color: #061020;
  margin-bottom: 8px;
  box-shadow: 0 8px 30px rgba(96, 165, 250, 0.35);
}

.onboarding-icon .icon { width: 32px; height: 32px; stroke-width: 2; }

.onboarding-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  background: linear-gradient(180deg, var(--text) 0%, #94a3b8 130%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.onboarding-desc {
  font-size: 13px;
  color: var(--text-2);
  max-width: 520px;
  line-height: 1.6;
  margin: 0;
}

.onboarding-hero .btn { margin-top: 8px; }

/* Picker actions (edit/delete per connection) */
.conn-picker-actions {
  display: flex;
  gap: 4px;
  margin-left: 4px;
  flex-shrink: 0;
}

.conn-picker-actions .icon-btn {
  width: 30px;
  height: 30px;
}

.conn-picker-actions .icon-btn .icon { width: 14px; height: 14px; }

/* Activity event con connection chip */
.activity-event-conn {
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
}

.activity-event-conn.global { background: rgba(96, 165, 250, 0.14); color: var(--accent); }
.activity-event-conn.personal { background: rgba(251, 191, 36, 0.14); color: var(--warn); }

/* =============================================================================
   ACTIVITY FEED
   ============================================================================= */

.activity-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.activity-live::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
  animation: live-pulse 1.5s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
}

.activity-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.activity-chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.activity-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  color: var(--text-2);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.activity-chip:hover { border-color: var(--border-glow); color: var(--text); }

.activity-chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.activity-chip[data-kind="destructive"][aria-pressed="true"] {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.activity-chip[data-kind="auth"][aria-pressed="true"] {
  background: rgba(34, 211, 238, 0.12);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.activity-chip .icon { width: 12px; height: 12px; }

.activity-select {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  outline: none;
  min-height: 36px;
}

.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-event {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  transition: border-color 0.15s;
  align-items: center;
}

.activity-trash {
  width: 30px;
  height: 30px;
  opacity: 0;
  transition: opacity 0.15s;
}

.activity-trash .icon { width: 14px; height: 14px; }

.activity-event:hover .activity-trash { opacity: 1; }

.activity-event:hover { border-color: var(--border-strong); }

.activity-event-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #061020;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.activity-event-body { min-width: 0; }
.activity-event-main {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-event-main .user {
  font-weight: 700;
  color: var(--accent-2);
  margin-right: 4px;
}
.activity-event-main .verb { color: var(--text-2); }

.activity-event-details {
  margin-top: 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
}

.activity-event-tag {
  padding: 1px 6px;
  background: var(--surface-3);
  border-radius: 4px;
}

.activity-event-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.activity-event[data-severity="warn"] {
  border-color: rgba(251, 191, 36, 0.3);
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.04), var(--surface) 20%);
}
.activity-event[data-severity="warn"] .activity-event-avatar {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.activity-event[data-severity="danger"] {
  border-color: rgba(248, 113, 113, 0.4);
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.08), var(--surface) 30%);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.2);
}
.activity-event[data-severity="danger"] .activity-event-avatar {
  background: linear-gradient(135deg, #f87171, #dc2626);
  color: #fff;
}

.activity-event[data-type="auth"] .activity-event-avatar {
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  color: #fff;
}

.activity-event[data-type="destructive"] .activity-event-main .verb {
  color: var(--danger);
  font-weight: 600;
}

.activity-new {
  animation: flash-in 0.5s ease;
}
@keyframes flash-in {
  0%   { background: rgba(52, 211, 153, 0.18); transform: translateY(-4px); opacity: 0; }
  100% { background: var(--surface); transform: translateY(0); opacity: 1; }
}

/* =============================================================================
   ADMIN PANEL
   ============================================================================= */

.admin-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(248, 113, 113, 0.12), rgba(248, 113, 113, 0.02) 80%);
  border: 1px solid rgba(248, 113, 113, 0.32);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.admin-warning .icon { color: var(--danger); width: 22px; height: 22px; flex-shrink: 0; }
.admin-warning-text { flex: 1; }
.admin-warning-title { font-size: 13px; font-weight: 700; color: var(--danger); letter-spacing: 0.02em; }
.admin-warning-desc { font-size: 12px; color: var(--text-2); margin-top: 3px; }

.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.admin-card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.admin-card-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  flex-shrink: 0;
}

.admin-card-title { font-size: 16px; font-weight: 600; margin: 0; flex: 1; }
.admin-card-desc { color: var(--text-2); font-size: 12px; margin: 0 0 8px; }

.admin-card-preview {
  padding: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-2);
}

.admin-preview-head {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 12px;
}

.admin-preview-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.admin-preview-row strong { color: var(--text); }
.admin-preview-row.warn strong { color: var(--warn); }
.admin-preview-row.danger strong { color: var(--danger); }

.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.btn-danger {
  background: linear-gradient(135deg, #f87171, #dc2626);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(248, 113, 113, 0.3);
}
.btn-danger:hover { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(248, 113, 113, 0.45); }

/* =============================================================================
   MODAL
   ============================================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(6, 8, 15, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}

.modal-box {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-head-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  flex-shrink: 0;
}

.modal-head-text { flex: 1; min-width: 0; }

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.modal-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-2);
}

.modal-close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close .icon { width: 16px; height: 16px; }

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-box-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}

.modal-box-text strong {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.modal-impact {
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-2);
}

.modal-impact-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.modal-impact-row strong { color: var(--text); }
.modal-impact-row.danger strong { color: var(--danger); }
.modal-impact-row.warn strong { color: var(--warn); }

.modal-actions {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}

.modal-actions .btn { flex: 1; justify-content: center; }

.modal-final-warn {
  padding: 10px 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 12px;
  line-height: 1.5;
}

/* =============================================================================
   RESPONSIVE — tablet
   ============================================================================= */

@media (min-width: 600px) {
  .content { padding: 28px 24px 80px; }
  .content-title { font-size: 26px; }
  .home-welcome-title { font-size: 26px; }
  .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .activity-filters { flex-direction: row; align-items: center; justify-content: space-between; }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .kpi-value { font-size: 28px; }
  .kpi-tile { min-height: 88px; padding: 12px; }
  .live-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  .activity-strip { grid-template-columns: repeat(4, 1fr); }
  .query-grid, .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .params-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-header { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .toasts { left: auto; right: 20px; align-items: flex-end; }
  .toast { width: auto; min-width: 240px; }
}

/* =============================================================================
   RESPONSIVE — desktop
   ============================================================================= */

@media (min-width: 900px) {
  .content { padding: 32px 40px 80px; }
  .content-title { font-size: 28px; }
  .home-welcome-title { font-size: 28px; }
  .detail-title { font-size: 24px; }
  .kpi-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
  .kpi-tile { min-height: 92px; padding: 14px; }
  .kpi-value { font-size: 26px; }
  .live-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .query-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .overview-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .params-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .query-title { font-size: 15px; }
  .sql-code { font-size: 12.5px; padding: 16px; }
  .results-header { flex-direction: row; align-items: center; justify-content: space-between; }
  .results-controls { flex: 1; justify-content: flex-end; }
  .home-sections { gap: 24px; }
}

@media (min-width: 1200px) {
  .home-dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
  }
}

/* =============================================================================
   RESPONSIVE — mobile (sidebar as drawer)
   ============================================================================= */

@media (max-width: 899px) {
  .app {
    grid-template-columns: 1fr;
    padding-top: var(--mobile-bar-h);
  }

  .mobile-bar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--border);
  }

  .sidebar[data-open="true"] { transform: translateX(0); }

  .sidebar-close { display: grid; }

  .nav-item[aria-current="page"]::before { display: none; }
  .nav-item[aria-current="page"] { border-color: var(--accent); }

  .results-table tbody td { max-width: 220px; }
  .detail-title { font-size: 20px; }

  .palette {
    padding: 0;
    align-items: stretch;
  }
  .palette-box {
    max-width: none;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
}
