/**
 * IntelliDB Enterprise — Design System 2026
 * Dark Premium · Bento Grid · Brand: #153244 · Accent: #D39E57
 * Fonts: DM Sans (UI) + DM Mono (code)
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Brand */
  --brand-primary:    #153244;
  --brand-primary-rgb: 21, 50, 68;
  --brand-mid:        #1a3f56;
  --brand-light:      #1e4d68;
  --brand-hover:      #204f6b;

  /* Accent — 10% rule */
  --accent:           #D39E57;
  --accent-rgb:       211, 158, 87;
  --accent-dim:       rgba(211, 158, 87, 0.15);
  --accent-glow:      rgba(211, 158, 87, 0.25);
  --accent-dark:      #b8893f;
  --accent-light:     #e0b578;

  /* Backgrounds */
  --bg-base:          #0B1929;
  --bg-surface:       #0f2032;
  --bg-elevated:      #132840;
  --bg-card:          #112035;
  --bg-card-hover:    #152540;
  --bg-input:         #0d1f30;
  --bg-overlay:       rgba(7, 14, 22, 0.85);

  /* Text */
  --text-1:           #f0f6fc;
  --text-2:           #b0c4d8;
  --text-3:           #6e8fa8;
  --text-4:           #3d5e74;
  --text-inverse:     #0B1929;

  /* Borders */
  --border:           rgba(255, 255, 255, 0.07);
  --border-mid:       rgba(255, 255, 255, 0.12);
  --border-strong:    rgba(255, 255, 255, 0.2);
  --border-accent:    rgba(211, 158, 87, 0.3);

  /* Semantic */
  --success:          #34d399;
  --success-bg:       rgba(52, 211, 153, 0.1);
  --success-border:   rgba(52, 211, 153, 0.25);
  --warning:          #fbbf24;
  --warning-bg:       rgba(251, 191, 36, 0.1);
  --warning-border:   rgba(251, 191, 36, 0.25);
  --danger:           #f87171;
  --danger-bg:        rgba(248, 113, 113, 0.1);
  --danger-border:    rgba(248, 113, 113, 0.25);
  --info:             #60a5fa;
  --info-bg:          rgba(96, 165, 250, 0.1);
  --info-border:      rgba(96, 165, 250, 0.25);

  /* Vantage polish (Plan 3 Phase 4) */
  --metric-empty-bg:  rgba(255, 255, 255, 0.03);

  /* Sidebar */
  --sidebar-bg:       #0d1e2d;
  --sidebar-bg-hover: rgba(255,255,255,0.04);
  --sidebar-active:   rgba(211, 158, 87, 0.12);
  --sidebar-active-border: #D39E57;
  --sidebar-text:     #6e8fa8;
  --sidebar-text-active: #f0f6fc;
  --sidebar-width:    252px;
  --header-h:         56px;

  /* Spacing — 4px grid */
  --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px;  --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* Radius */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* Fonts */
  --font-ui:   'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'JetBrains Mono', ui-monospace, monospace;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.2);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.5), 0 4px 12px rgba(0,0,0,0.3);
  --shadow-xl:  0 24px 64px rgba(0,0,0,0.6), 0 8px 24px rgba(0,0,0,0.4);
  --shadow-accent: 0 4px 24px rgba(211, 158, 87, 0.2);

  /* Transitions */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:  120ms;
  --t-base:  200ms;
  --t-slow:  350ms;
}

/* Compatibility aliases for dashboard.css naming convention */
:root {
  /* Spacing aliases */
  --space-1: var(--sp-1);
  --space-2: var(--sp-2);
  --space-3: var(--sp-3);
  --space-4: var(--sp-4);
  --space-5: var(--sp-5);
  --space-6: var(--sp-6);
  --space-8: var(--sp-8);

  /* Text color aliases */
  --text-primary: var(--text-1);
  --text-secondary: var(--text-2);
  --text-tertiary: var(--text-3);
  --text-muted: var(--text-4);

  /* Background aliases */
  --bg-secondary: var(--bg-surface);
  --bg-tertiary: var(--bg-elevated);

  /* Border aliases */
  --border-light: var(--border);
  --border-medium: var(--border-mid);

  /* Radius aliases */
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-xl);
  --radius-full: var(--r-full);

  /* Transition aliases */
  --transition-fast: var(--t-fast) var(--ease-out);
  --transition-base: var(--t-base) var(--ease-out);
  --transition-slow: var(--t-slow) var(--ease-out);

  /* Font weight aliases */
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Font size aliases */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;

  /* Semantic color shade aliases (used by dashboard insight icons) */
  --success-100: rgba(52, 211, 153, 0.1);
  --success-500: #34d399;
  --success-600: #22c55e;
  --warning-100: rgba(251, 191, 36, 0.1);
  --warning-500: #fbbf24;
  --warning-600: #f59e0b;
  --danger-100: rgba(248, 113, 113, 0.1);
  --danger-500: #f87171;
  --danger-600: #ef4444;

  /* Primary color shades (used by quick action buttons) */
  --primary-600: #0d9488;
  --primary-700: #0f766e;
  --primary-800: #115e59;

  /* Accent shade aliases */
  --accent-500: var(--accent);
  --accent-600: var(--accent-dark);
  --accent-700: #a07530;
}

/* Light mode override */
[data-theme="light"] {
  --bg-base:          #f0f4f8;
  --bg-surface:       #e8edf3;
  --bg-elevated:      #ffffff;
  --bg-card:          #ffffff;
  --bg-card-hover:    #f8fafc;
  --bg-input:         #ffffff;
  --bg-overlay:       rgba(15, 23, 42, 0.7);

  --text-1:           #0f172a;
  --text-2:           #334155;
  --text-3:           #64748b;
  --text-4:           #94a3b8;
  --text-inverse:     #ffffff;

  --border:           rgba(0, 0, 0, 0.08);
  --border-mid:       rgba(0, 0, 0, 0.12);
  --border-strong:    rgba(0, 0, 0, 0.2);

  --sidebar-bg:       #153244;
  --sidebar-bg-hover: rgba(255,255,255,0.06);
  --sidebar-active:   rgba(211, 158, 87, 0.15);
  --sidebar-text:     rgba(255,255,255,0.55);
  --sidebar-text-active: #ffffff;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.08);

  --bg-secondary: var(--bg-surface);
  --bg-tertiary: var(--bg-elevated);
  --text-primary: var(--text-1);
  --text-secondary: var(--text-2);
  --text-tertiary: var(--text-3);
  --text-muted: var(--text-4);
  --border-light: var(--border);
  --border-medium: var(--border-mid);
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: rgba(211, 158, 87, 0.25); color: var(--text-1); }

/* ============================================
   SCROLLBAR — IntelliDB Branded
   ============================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(11, 25, 41, 0.4); border-radius: 6px; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(211, 158, 87, 0.3) 0%, rgba(211, 158, 87, 0.15) 100%);
  border-radius: 6px;
  border: 1px solid rgba(211, 158, 87, 0.1);
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(211, 158, 87, 0.5) 0%, rgba(211, 158, 87, 0.3) 100%);
  border-color: rgba(211, 158, 87, 0.2);
}
::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, rgba(211, 158, 87, 0.65) 0%, rgba(211, 158, 87, 0.4) 100%);
}
::-webkit-scrollbar-corner { background: transparent; }

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(211, 158, 87, 0.25) transparent;
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app-container {
  display: flex;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
  z-index: 20;
  transition: width 200ms var(--ease-out), min-width 200ms var(--ease-out);
}

/* Subtle top-edge highlight for depth */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(211, 158, 87, 0.2) 50%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Ambient brand glow on right edge */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: -1px;
  width: 1px; height: 100%;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(211, 158, 87, 0.15) 30%,
    rgba(211, 158, 87, 0.15) 70%,
    transparent 100%
  );
  pointer-events: none;
}

.sidebar-header {
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

/* Soft gradient fade below header */
.sidebar-header::after {
  content: '';
  position: absolute;
  bottom: -12px; left: 0; right: 0;
  height: 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.08), transparent);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* Handles both .brand-logo and .brand-icon */
.brand-logo,
.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, #153244 0%, #1a3f56 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
}

.brand-logo img,
.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* logo.png is 500x500 with an indexed palette - downscaling that to
     ~32px makes Firefox's nearest-neighbour resampler render an aliased
     mess. Force the high-quality bicubic path with image-rendering, and
     promote the element to its own GPU layer so the compositor uses
     mipmap-style sampling (cleaner edges across all browsers). */
  image-rendering: auto;
  image-rendering: -webkit-optimize-contrast;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* When the sidebar is collapsed to icon-only, the brand frame should
   center-align the logo with the nav-icons below it, and not show
   the gradient frame (it visually competes with the bare nav icons). */
body.compact-sidebar .sidebar-header { padding: var(--sp-3) 0; justify-content: center; }
body.compact-sidebar .brand { justify-content: center; gap: 0; }
body.compact-sidebar .brand-icon,
body.compact-sidebar .brand-logo {
  width: 32px; height: 32px;
  background: transparent;
  box-shadow: none;
  border: none;
}

.brand-logo-fallback {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 9px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* Navigation sections */
.nav-section {
  padding: var(--sp-1) 0 0;
}

.nav-section:first-child {
  padding-top: var(--sp-3);
}

/* Handles both .nav-section-label and .nav-section-title */
.nav-section-label,
.nav-section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5) var(--sp-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
}

/* Decorative line after section title */
.nav-section-label::after,
.nav-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-right: var(--sp-4);
}

.nav-menu {
  list-style: none;
  padding: 0 var(--sp-3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  color: var(--sidebar-text);
  transition: all var(--t-fast) var(--ease-out);
  position: relative;
  margin-bottom: 1px;
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: var(--text-2);
  border-color: rgba(255,255,255,0.04);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 500;
  border-color: rgba(211, 158, 87, 0.15);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.03);
}

/* Active accent stripe */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  max-height: 20px;
  background: var(--sidebar-active-border);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  box-shadow: 0 0 8px rgba(211, 158, 87, 0.3);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.nav-item:hover .nav-icon {
  opacity: 0.85;
}
.nav-item.active .nav-icon {
  opacity: 1;
  color: var(--accent);
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-full);
  line-height: 1.3;
  background: rgba(211,158,87,0.12);
  color: var(--accent);
  border: 1px solid rgba(211,158,87,0.15);
}
.nav-badge.alert {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
  border-color: rgba(248,113,113,0.2);
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Soft gradient fade above footer */
.sidebar-footer::before {
  content: '';
  position: absolute;
  top: -12px; left: 0; right: 0;
  height: 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.06), transparent);
  pointer-events: none;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

/* ============================================
   HEADER
   ============================================ */
.top-header {
  height: var(--header-h);
  min-height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  flex-shrink: 0;
  z-index: 10;
  min-width: 0;
  gap: var(--sp-3);
}

/* min-width:0 lets the left side shrink so a long .connection-pill does
   not push header-right (zoom pill, theme, notifications, profile) off
   the right edge. NO overflow:hidden here - that hid the zoom pill on
   narrow viewports. The .connection-pill itself ellipsizes via its own
   max-width + overflow rule. */
.header-left { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; flex: 1 1 auto; }
.header-right { display: flex; align-items: center; gap: var(--sp-3); flex: 0 0 auto; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
}

.breadcrumb-item { color: var(--text-3); }
.breadcrumb-sep { color: var(--text-4); font-size: 11px; }
.breadcrumb-current { color: var(--text-1); font-weight: 500; }

.connection-pill {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--t-fast);
  /* Hard cap on width so a five-segment pill (db . host . version .
     user . tier) can't grow to overlap header-right (refresh /
     notifications / zoom / theme / profile).
     Width = viewport - (sidebar + ~470 reserved for header-right).
     Clamps to a 140px floor and 460px ceiling so the pill never
     starves to nothing nor balloons on a 4K display. */
  min-width: 0;
  max-width: clamp(140px, calc(100vw - var(--sidebar-width) - 470px), 460px);
  overflow: hidden;
}
.connection-pill > * { min-width: 0; }
.connection-pill-body {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.connection-pill-body > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
}
/* Status dot and version badge are short fixed pills - keep them at their natural width. */
.connection-pill-body > .connection-status-dot,
.connection-pill-body > .connection-pill-badge { flex: 0 0 auto; }

.connection-pill:hover { border-color: var(--border-mid); }

.conn-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.6);
}

.conn-dot.disconnected { background: var(--text-4); box-shadow: none; }

.header-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-3);
  transition: all var(--t-fast);
}

.header-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-1);
  border-color: var(--border-mid);
}

/* Zoom pill control */
.zoom-pill {
  display: inline-flex;
  align-items: stretch;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  height: 34px;
  flex-shrink: 0;
}
.zoom-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--t-fast);
  padding: 0;
}
.zoom-pill-btn:hover { background: var(--bg-elevated); color: var(--text-1); }
.zoom-pill-btn:active { background: var(--accent-dim); color: var(--accent); }
.zoom-pill-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 44px;
  padding: 0 4px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.zoom-pill-value:hover { background: var(--accent-dim); }

.header-btn-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  display: none;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand-mid), var(--brand-light));
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--t-fast);
}

.user-avatar:hover { border-color: var(--accent); }

/* ============================================
   CONTENT AREA & VIEWS
   ============================================ */
.content-area {
  flex: 1;
  overflow-y: auto;
  /* overflow-x: auto so users on narrow viewports (e.g. small Ubuntu VM
     windows ~1024px) can side-scroll into content that won't wrap further
     - data tables, wide query plans, the SQL editor monaco region.
     The sidebar is always pinned at the left edge thanks to flex+shrink,
     so this only scrolls the content column. */
  overflow-x: auto;
  background: var(--bg-base);
}

.view-container {
  display: none;
  padding: var(--sp-6);
  min-height: 100%;
  animation: viewFadeIn var(--t-base) var(--ease-out);
}

.view-container.active { display: block; }

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   PAGE HEADERS
   ============================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
  gap: var(--sp-4);
}

.page-title-group {}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-top: var(--sp-1);
  line-height: 1.4;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out);
}

.card:hover { border-color: var(--border-mid); box-shadow: 0 2px 12px rgba(0,0,0,0.08); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.card-body {
  padding: var(--sp-5);
}

.card-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Card variants */
.card-accent {
  background: linear-gradient(135deg,
    rgba(var(--brand-primary-rgb), 0.6) 0%,
    rgba(var(--brand-primary-rgb), 0.3) 100%);
  border-color: rgba(211, 158, 87, 0.2);
}

.card-stat {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* ============================================
   METRIC CARDS (KPI)
   ============================================ */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  transition: border-color var(--t-fast), transform var(--t-fast);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  border-color: var(--border-mid);
  transform: translateY(-1px);
}

.metric-card-featured {
  background: linear-gradient(135deg,
    rgba(21, 50, 68, 0.9) 0%,
    rgba(30, 77, 104, 0.7) 100%);
  border-color: rgba(211, 158, 87, 0.25);
}

.metric-card-featured::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: radial-gradient(circle at top right,
    rgba(211, 158, 87, 0.15) 0%,
    transparent 70%
  );
  pointer-events: none;
}

.metric-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-card-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.metric-card-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}

.metric-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.03em;
  line-height: 1;
}

.metric-card-featured .metric-card-value {
  color: var(--accent);
}

.metric-card-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
  color: var(--text-3);
}

.metric-card-progress {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--r-full);
  overflow: hidden;
}

.metric-card-bar {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width 0.5s var(--ease-out);
}

.metric-card-bar.success { background: var(--success); }
.metric-card-bar.warning { background: var(--warning); }
.metric-card-bar.danger  { background: var(--danger); }

/* ============================================
   BENTO GRID
   ============================================ */
.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}

.bento-2 { grid-column: span 2; }
.bento-3 { grid-column: span 3; }
.bento-4 { grid-column: span 4; }
.bento-row-2 { grid-row: span 2; }

/* Bento responsiveness lives in the body.vw-* block below
   (driven by app.js _updateResponsiveClasses) so it stays consistent
   with the rest of the JS-tier responsive system. */
@media (max-width: 768px) {
  .bento-2, .bento-3, .bento-4 { grid-column: span 1; }
}

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }

/* ============================================
   STATUS BANNER
   ============================================ */
.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-lg);
  border: 1px solid var(--success-border);
  background: var(--success-bg);
  margin-bottom: var(--sp-6);
  gap: var(--sp-4);
}

.status-banner.warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

.status-banner.danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.status-banner-left { display: flex; align-items: center; gap: var(--sp-3); }

.status-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--success);
  flex-shrink: 0;
}

.status-banner.warning .status-icon { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.status-banner.danger  .status-icon { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }

.status-text {}
.status-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.status-desc  { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.status-banner-actions { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 7px 14px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
  min-height: 32px;
}

/* Both the :disabled attribute AND a `disabled` CSS class must read as disabled.
   Several modules (roles-grants, etc.) mark buttons inert with class="disabled"
   + an onclick of void(0); without this selector those buttons looked fully
   enabled (opacity 1, pointer cursor) and users reported "the buttons don't work". */
.btn:disabled,
.btn.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-sm  { padding: 5px 10px; font-size: 12px; min-height: 28px; }
.btn-lg  { padding: 10px 20px; font-size: 14px; min-height: 40px; }

.btn:active { transform: scale(0.97); }

/* Primary */
.btn-primary {
  background: var(--accent);
  color: #0B1929;
  font-weight: 600;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-2);
  border-color: var(--border-mid);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-1);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-3);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-1);
}

/* Danger */
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
  transform: translateY(-1px);
}

/* Success */
.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
.btn-success:hover {
  background: rgba(52, 211, 153, 0.2);
  transform: translateY(-1px);
}

/* Icon only */
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-3);
  border-radius: var(--r-md);
}
.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-mid);
  color: var(--text-1);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--r-full);
  border: 1px solid;
  white-space: nowrap;
  line-height: 1.5;
}

.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.badge-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }
.badge-neutral {
  background: rgba(255,255,255,0.05);
  color: var(--text-3);
  border-color: var(--border);
}
.badge-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--border-accent);
}

.badge-dot::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* Live badge */
.badge-live {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
.badge-live::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
  margin-right: 3px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.8); }
}

/* ============================================
   FORMS
   ============================================ */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.01em;
}

.form-input,
.form-select,
.form-textarea {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-1);
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  padding: 8px 12px;
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  min-height: 36px;
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-4); }

.form-input:hover,
.form-select:hover { border-color: var(--border-strong); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(211, 158, 87, 0.12);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236e8fa8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-input.error { border-color: var(--danger); }
.form-error { font-size: 11px; color: var(--danger); margin-top: var(--sp-1); }

/* Search box */
.search-box {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  padding: 6px 10px;
  transition: border-color var(--t-fast);
}

.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--text-4); flex-shrink: 0; }
.search-box input {
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-1);
  width: 160px;
}
.search-box input::placeholder { color: var(--text-4); }

/* ============================================
   TABLES
   ============================================ */
.table-container {
  overflow-x: auto;
  border-radius: var(--r-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead tr {
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,0.02); color: var(--text-1); }

.null-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-4);
  background: rgba(255,255,255,0.04);
  padding: 1px 5px;
  border-radius: var(--r-sm);
}

/* ============================================
   KPI ROWS
   ============================================ */
.kpi-list { display: flex; flex-direction: column; gap: 1px; }

.kpi-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-1);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-4);
}

.kpi-item:last-child { border-bottom: none; }

.kpi-left { display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: 12px; color: var(--text-3); }
.kpi-value { font-size: 18px; font-weight: 600; color: var(--text-1); letter-spacing: -0.02em; }
.kpi-trend { font-size: 11px; color: var(--text-4); white-space: nowrap; }

.kpi-value.good    { color: var(--success); }
.kpi-value.warn    { color: var(--warning); }
.kpi-value.bad     { color: var(--danger); }

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width 0.5s var(--ease-out);
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }
.progress-bar.info    { background: var(--info); }

/* ============================================
   NOTIFICATIONS / TOASTS
   ============================================ */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  font-size: 13px;
  color: var(--text-1);
  z-index: 9999;
  max-width: 360px;
  animation: toastIn var(--t-base) var(--ease-out);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px) translateY(4px); }
  to   { opacity: 1; transform: translateX(0) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}

/* Legacy .notification-toast alias */
.notification-toast { position: fixed; bottom: var(--sp-6); right: var(--sp-6); display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); background: var(--bg-elevated); border: 1px solid var(--border-mid); border-radius: var(--r-lg); box-shadow: var(--shadow-xl); font-size: 13px; color: var(--text-1); z-index: 9999; max-width: 360px; animation: toastIn var(--t-base) var(--ease-out); }
.notification-toast.success { border-left: 3px solid var(--success); }
.notification-toast.error   { border-left: 3px solid var(--danger); }
.notification-toast.warning { border-left: 3px solid var(--warning); }
.notification-toast.info    { border-left: 3px solid var(--info); }

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-6);
  animation: fadeIn var(--t-base) var(--ease-out);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal,
.modal-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 64px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn var(--t-base) var(--ease-spring);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 15px; font-weight: 600; color: var(--text-1); letter-spacing: -0.01em; }

.modal-body { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }

.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
}

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: var(--sp-6);
  animation: fadeIn 150ms var(--ease-out);
}
.confirm-dialog {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 400px;
  animation: modalIn 200ms var(--ease-spring);
  overflow: hidden;
}
.confirm-body {
  padding: var(--sp-6);
}
.confirm-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: var(--sp-2);
}
.confirm-message {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
}
.confirm-message code {
  display: block;
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  max-height: 80px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}
.confirm-actions .btn { min-width: 80px; justify-content: center; }
.confirm-danger .confirm-title { color: var(--danger); }

/* ============================================
   DROPDOWNS — shadcn-inspired popover style
   ============================================ */
.dropdown {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,0.35), 0 4px 16px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.04);
  z-index: 500;
  min-width: 200px;
  overflow: hidden;
  animation: dropdownIn 180ms var(--ease-out);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-header {
  padding: var(--sp-3) var(--sp-4);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dropdown-section {
  padding: var(--sp-1) 0;
}

.dropdown-section-label {
  padding: var(--sp-2) var(--sp-4) var(--sp-1);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-4);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 8px var(--sp-4);
  margin: 0 var(--sp-1);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast);
  position: relative;
}

.dropdown-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-1);
}
.dropdown-item:active {
  background: rgba(255,255,255,0.07);
}
.dropdown-item svg { color: var(--text-3); flex-shrink: 0; transition: color var(--t-fast); }
.dropdown-item:hover svg { color: var(--text-2); }
.dropdown-item .dropdown-item-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-4);
  font-family: var(--font-mono);
}

.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger svg { color: var(--danger); opacity: 0.7; }
.dropdown-item-danger:hover { background: rgba(248,113,113,0.08); color: var(--danger); }
.dropdown-item-danger:hover svg { color: var(--danger); opacity: 1; }

.dropdown-divider { height: 1px; background: var(--border); margin: var(--sp-1) var(--sp-2); }

.dropdown-footer {
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
  border-top: 1px solid var(--border);
  text-align: center;
}
.dropdown-footer-btn {
  font-size: 12px;
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.dropdown-footer-btn:hover {
  color: var(--accent);
  background: rgba(211,158,87,0.08);
}

/* Notification-specific dropdown styles */
.notif-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
  cursor: default;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: rgba(255,255,255,0.02); }

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.notif-icon.success { background: rgba(52,211,153,0.12); color: var(--success); }
.notif-icon.warning { background: rgba(251,191,36,0.12); color: var(--warning); }
.notif-icon.danger  { background: rgba(248,113,113,0.12); color: var(--danger); }
.notif-icon.info    { background: rgba(96,165,250,0.12); color: var(--info); }

.notif-body { flex: 1; min-width: 0; }
.notif-title-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.notif-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.notif-time { font-size: 11px; color: var(--text-4); white-space: nowrap; font-family: var(--font-mono); }
.notif-message { font-size: 12px; color: var(--text-3); line-height: 1.5; margin-top: 2px; }
.notif-item.notif-unread { border-left: 3px solid var(--accent); background: rgba(211,158,87,0.04); }

/* User profile dropdown styles */
.profile-header {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-light));
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
}
.profile-info { min-width: 0; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.profile-email { font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-role {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: rgba(211,158,87,0.1);
  color: var(--accent);
  border: 1px solid rgba(211,158,87,0.15);
}

/* ============================================
   SPINNERS / LOADING
   ============================================ */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
  gap: var(--sp-4);
}

.empty-state-icon {
  width: 48px; height: 48px;
  color: var(--text-4);
  opacity: 0.5;
}

.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text-2); }
.empty-state-desc  { font-size: 13px; color: var(--text-3); max-width: 280px; line-height: 1.5; }

/* ============================================
   TABS
   ============================================ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); }

.tab {
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  user-select: none;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-ui);
}

.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text-1); font-weight: 500; border-bottom-color: var(--accent); }

/* ============================================
   INSIGHT CARDS
   ============================================ */
.insight-card {
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.insight-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.insight-icon.success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.insight-icon.warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.insight-icon.danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border); }

.insight-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.insight-desc  { font-size: 12px; color: var(--text-3); margin-top: var(--sp-1); line-height: 1.5; }

/* ============================================
   RESOURCE / SYSTEM METRICS
   ============================================ */
.resource-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.resource-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.resource-label { font-size: 12px; color: var(--text-3); }
.resource-value { font-size: 12px; font-weight: 600; color: var(--text-1); }

/* ============================================
   QUICK ACTION BUTTONS
   ============================================ */
.quick-actions { display: flex; flex-direction: column; gap: var(--sp-2); }

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-ui);
  transition: all var(--t-fast) var(--ease-out);
  width: 100%;
}

.quick-action-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-mid);
  transform: translateX(2px);
}

.quick-action-btn.primary { border-color: var(--border-accent); }
.quick-action-btn.primary:hover { background: var(--accent-dim); }

.quick-action-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-3);
  flex-shrink: 0;
}

.quick-action-btn.primary .quick-action-icon { color: var(--accent); border-color: var(--border-accent); background: var(--accent-dim); }

.quick-action-info { flex: 1; }
.quick-action-title { font-size: 13px; font-weight: 500; color: var(--text-1); }
.quick-action-desc  { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* ============================================
   VANTAGE METRIC CARDS
   ============================================ */
.vantage-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
}

.vantage-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  transition: border-color var(--t-fast);
  /* min-width:0 + min-content protection so grid 1fr columns can actually
     shrink. Without this, long metric values force the grid to overflow. */
  min-width: 0;
}

.vantage-card:hover { border-color: var(--border-mid); }

.vantage-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.vantage-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.01em;
}

.vantage-card-icon { color: var(--text-4); }

.vantage-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
}

.vantage-metric-row:last-child { border-bottom: none; }

.vantage-metric-name { font-size: 12px; color: var(--text-3); }
.vantage-metric-val  {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

/* Legacy aliases for vantage-metric-card */
.vantage-metric-card { background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); transition: border-color var(--t-fast); }
.vantage-metric-card:hover { border-color: var(--border-mid); }
.vantage-metric-card[data-status="success"] { border-left-color: var(--success); }
.vantage-metric-card[data-status="warning"] { border-left-color: var(--warning); }
.vantage-metric-card[data-status="danger"]  { border-left-color: var(--danger); }
.vantage-metric-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border); }
.vantage-metric-header h4 { font-size: 12px; font-weight: 600; color: var(--text-2); }
.vantage-metric-list { display: flex; flex-direction: column; }
.vantage-metric-item { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); gap: var(--sp-3); }
.vantage-metric-item:last-child { border-bottom: none; }
.vantage-metric-name { font-size: 11px; color: var(--text-3); }
.vantage-metric-value { font-size: 11px; font-weight: 600; color: var(--text-1); font-variant-numeric: tabular-nums; }
.vantage-metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); margin-top: var(--sp-4); }
.vantage-metric-card { min-width: 0; }

/* ============================================
   SQL EDITOR
   ============================================ */
.sql-editor-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--sp-4);
  height: calc(100vh - var(--header-h) - 140px);
  min-height: 400px;
}

.sql-sidebar { display: flex; flex-direction: column; gap: var(--sp-4); overflow-y: auto; }
.sql-main    { display: flex; flex-direction: column; gap: var(--sp-3); overflow: hidden; }

.sql-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 var(--sp-5);
}

.sql-tab {
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-ui);
  transition: color var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}

.sql-tab:hover { color: var(--text-2); }
.sql-tab.active { color: var(--text-1); font-weight: 500; border-bottom-color: var(--accent); }

.sql-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.sql-toolbar-left  { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.sql-toolbar-right { display: flex; align-items: center; gap: var(--sp-2); }

.code-editor-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: var(--bg-base);
}

.line-numbers {
  display: flex;
  flex-direction: column;
  padding: var(--sp-4) var(--sp-3);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  color: var(--text-4);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  user-select: none;
  min-width: 40px;
  text-align: right;
  overflow: hidden;
}

.line-numbers span { display: block; }

.code-editor {
  flex: 1;
  background: var(--bg-base);
  border: none;
  outline: none;
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: var(--sp-4);
  resize: none;
  width: 100%;
  height: 100%;
  min-height: 200px;
  caret-color: var(--accent);
}

.sql-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-5);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.status-item { display: flex; align-items: center; gap: var(--sp-2); }
.status-label { color: var(--text-4); }
.status-value { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ============================================
   SAVED QUERIES / SCHEMA TREE
   ============================================ */
.saved-query-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
  font-size: 12px;
  color: var(--text-2);
}

.saved-query-item:hover { background: var(--bg-elevated); color: var(--text-1); }
.saved-query-item svg { color: var(--text-4); flex-shrink: 0; }

.saved-query-info { flex: 1; min-width: 0; }
.saved-query-name { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-query-db   { display: block; font-size: 10px; color: var(--text-4); }

.schema-node { }

.schema-folder {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.schema-folder:hover { background: var(--bg-elevated); }

.schema-children { padding-left: var(--sp-5); overflow: hidden; max-height: 0; transition: max-height 0.3s var(--ease-out); }
.schema-children.expanded { max-height: 1000px; }

.schema-table {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-3);
  transition: background var(--t-fast), color var(--t-fast);
}

.schema-table:hover { background: var(--bg-elevated); color: var(--text-1); }

/* ============================================
   CONNECTIONS VIEW
   ============================================ */
.connection-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--r-lg);
  transition: all var(--t-fast);
  gap: var(--sp-4);
}

.connection-card.connected { border-left-color: var(--success); }
.connection-card.disconnected { border-left-color: var(--text-4); }
.connection-card:hover { border-color: var(--border-mid); }

.connection-info { display: flex; align-items: center; gap: var(--sp-3); flex: 1; }
.connection-db-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  flex-shrink: 0;
  font-size: 20px;
}

.connection-details { flex: 1; min-width: 0; }
.connection-name { font-size: 14px; font-weight: 600; color: var(--text-1); }
.connection-addr { font-size: 12px; color: var(--text-3); font-family: var(--font-mono); margin-top: 2px; }

.connection-actions { display: flex; flex-direction: column; gap: var(--sp-2); flex-shrink: 0; }

/* ============================================
   CATEGORY CARDS (Vantage overview)
   ============================================ */
.category-card {
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--t-fast);
}

.category-card:hover { transform: translateY(-2px); border-color: var(--border-mid); }
.category-card.featured { border-color: var(--border-accent); background: var(--accent-dim); }
.category-card.success  { border-color: var(--success-border); background: var(--success-bg); }
.category-card.warning  { border-color: var(--warning-border); background: var(--warning-bg); }
.category-card.purple   { border-color: var(--info-border); background: var(--info-bg); }

.category-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.category-desc  { font-size: 12px; color: var(--text-3); margin-top: var(--sp-1); line-height: 1.4; }

/* ============================================
   HEALTH SUMMARY
   ============================================ */
.health-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-4) 0;
  flex-wrap: wrap;
}

.health-indicator {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 12px;
}

/* Metrics control bar */
.metrics-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  gap: var(--sp-4);
  flex-wrap: wrap;
}

/* ============================================
   CORTEX / AI CHAT
   ============================================ */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--header-h) - 120px);
  gap: var(--sp-4);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.chat-message {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}

.chat-message.user { flex-direction: row-reverse; }

.chat-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.chat-avatar.ai {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--border-accent);
}

.chat-avatar.user {
  background: var(--bg-elevated);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.chat-bubble {
  max-width: 70%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  font-size: 13px;
  line-height: 1.6;
}

.chat-message.user .chat-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  color: var(--text-1);
  border-radius: var(--r-lg) var(--r-sm) var(--r-lg) var(--r-lg);
}

.chat-message.ai .chat-bubble {
  background: var(--brand-primary);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-1);
  border-radius: var(--r-sm) var(--r-lg) var(--r-lg) var(--r-lg);
}

.chat-message.ai .chat-bubble pre {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin-top: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
}

.chat-input-area {
  padding: var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--sp-3);
  background: var(--bg-elevated);
}

.chat-input {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-1);
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  resize: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color var(--t-fast);
}

.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-4); }

/* ============================================
   COLOR UTILITIES
   ============================================ */
.text-1 { color: var(--text-1); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-accent  { color: var(--accent); }
.text-info    { color: var(--info); }

/* Background utilities */
.bg-card     { background: var(--bg-card); }
.bg-elevated { background: var(--bg-elevated); }
.bg-surface  { background: var(--bg-surface); }

/* Border utility */
.border-accent { border-color: var(--border-accent); }

/* ============================================
   LAYOUT UTILITIES
   ============================================ */
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.flex-1 { flex: 1; min-width: 0; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full { width: 100%; }
.min-w-0 { min-width: 0; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* Margin/padding */
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.p-4  { padding: var(--sp-4); }
.p-5  { padding: var(--sp-5); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.py-3 { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* Text */
.text-sm  { font-size: 12px; }
.text-xs  { font-size: 11px; }
.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-4);
}

.mb-0 { margin-bottom: 0; }

/* Grid aliases */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); gap: var(--sp-4); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }

/* ============================================
   CHART CONTAINER
   ============================================ */
.chart-container {
  width: 100%;
  height: 220px;
}

/* ============================================
   QUERY RESULTS
   ============================================ */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.results-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.results-table td {
  padding: 7px 12px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}

.results-table tbody tr:last-child td { border-bottom: none; }
.results-table tbody tr:hover td { background: rgba(255,255,255,0.02); color: var(--text-1); }

.empty-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12);
  gap: var(--sp-3);
  color: var(--text-3);
  text-align: center;
}

.empty-results-icon { width: 40px; height: 40px; opacity: 0.4; }
.empty-results-title { font-size: 14px; font-weight: 600; color: var(--text-2); }
.empty-results-description { font-size: 12px; }

.query-error {
  padding: var(--sp-4);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* History table */
.history-row { cursor: pointer; }
.history-query {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}

/* ============================================
   SCAN VIEW
   ============================================ */
.scan-progress-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
}

.scan-progress-ring svg { position: absolute; top: 0; left: 0; transform: rotate(-90deg); }
.scan-progress-ring circle { fill: none; stroke-linecap: round; }
.scan-progress-ring .bg   { stroke: rgba(255,255,255,0.06); }
.scan-progress-ring .bar  { stroke: var(--accent); transition: stroke-dashoffset 0.5s var(--ease-out); }
.scan-progress-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.scan-percent { font-size: 24px; font-weight: 700; color: var(--text-1); letter-spacing: -0.03em; }
.scan-label   { font-size: 10px; color: var(--text-3); margin-top: 1px; }

.issue-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.issue-item:last-child { border-bottom: none; }

.issue-severity {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.issue-severity.critical { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.issue-severity.warning  { background: var(--warning); }
.issue-severity.info     { background: var(--info); }

.issue-title { font-size: 13px; font-weight: 500; color: var(--text-1); }
.issue-desc  { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ============================================
   RESPONSIVE
   ============================================
   Layout tiers (sidebar collapse, grid density, content max-width)
   are driven from app.js _updateResponsiveClasses via body.vw-* and
   body.compact-* classes - see the block further down. The @media
   blocks below stay because they handle:
     - <900: page-header column-stack + page-actions wrap (real mobile)
     - <768: sql-editor single-pane (true phone) */
@media (max-width: 900px) {
  .bento-2, .bento-3, .bento-4 { grid-column: span 1; }
  .page-header { flex-direction: column; gap: var(--sp-3); align-items: flex-start; }
  .page-actions { width: 100%; flex-wrap: wrap; }
}

/* Sidebar collapse - driven by JS-toggled body classes from
   _updateResponsiveClasses() in app.js. Keyed off the RAW browser
   viewport so the in-app zoom (transform:scale) acts as a pure
   readability scaler - zooming in/out does NOT collapse the sidebar
   or change content density. Sidebar only collapses when the actual
   browser window is narrow.
   Selectors target real markup classes:
     .brand-text         - the "IntelliDB / Enterprise" wordmark
     .nav-section-title  - "Core / Intelligence / Admin / Dev"
     .sb-edition-pill    - the "Enterprise Version" footer pill
     .nav-item > span:not(.nav-icon):not(.nav-badge) - the label span */
body.compact-sidebar { --sidebar-width: 64px; }
body.compact-sidebar .sidebar-header .brand-text,
body.compact-sidebar .nav-section-title,
body.compact-sidebar .sb-edition-pill,
body.compact-sidebar .sidebar-plan-footer,
body.compact-sidebar .nav-item > span:not(.nav-icon):not(.nav-badge),
body.compact-sidebar .nav-item .nav-badge { display: none; }
body.compact-sidebar .nav-item { justify-content: center; }
body.compact-sidebar .view-container { padding: var(--sp-4); }

/* At sub-1100 viewports the connection-pill drops the host/user
   segments and the dot-separators - the db name + version badge are
   the load-bearing identity. Removes the multi-segment ellipsis
   contention that was making the pill clip into the ENTERPRISE
   badge in header-right. */
/* Progressive segment-hiding lives at the end of additions.css
   so its rules load AFTER the .connection-pill-badge base
   declaration there and win the specificity tie. Don't duplicate
   them here; they would be inert because of source order. */

/* Tighter header at <900 - hide the breadcrumb too. */
body.compact-header { --sidebar-width: 56px; }
body.compact-header .breadcrumb { display: none; }
body.compact-header .connection-pill { max-width: 220px; }

/* True mobile widths get the tightest layout. */
@media (max-width: 768px) {
  .sql-editor-layout { grid-template-columns: 1fr; grid-template-rows: 160px 1fr; }
  .breadcrumb { display: none; }
}

/* Resolution-tier density. Driven by JS classes (vw-narrow /
   vw-medium / vw-wide / vw-ultra) on body, set in app.js based on
   raw window.innerWidth. The classes are mutually exclusive: exactly
   one applies at any time. */
body.vw-narrow .vantage-metrics-grid,
body.vw-narrow .vantage-grid,
body.vw-narrow .grid-2,
body.vw-narrow .grid-3,
body.vw-narrow .grid-4,
body.vw-narrow .bento { grid-template-columns: 1fr; }

body.vw-medium .vantage-metrics-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.vw-medium .vantage-grid         { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.vw-medium .bento                { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.vw-medium .grid-3,
body.vw-medium .grid-4               { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* 1080p / 1440p territory - 5-col Vantage looks great here. */
body.vw-wide .vantage-metrics-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
body.vw-wide .vantage-grid         { grid-template-columns: repeat(5, minmax(0, 1fr)); }
body.vw-wide .bento                { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.vw-wide .view-container       { max-width: 1800px; margin-inline: auto; }

/* 4K / ultrawide - cap content width for readability and bump density. */
body.vw-ultra .vantage-metrics-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
body.vw-ultra .vantage-grid         { grid-template-columns: repeat(6, minmax(0, 1fr)); }
body.vw-ultra .bento                { grid-template-columns: repeat(6, minmax(0, 1fr)); }
body.vw-ultra .view-container       { max-width: 2200px; margin-inline: auto; }
body.vw-ultra .top-header           { padding-inline: clamp(var(--sp-6), 5vw, 80px); }

/* ============================================
   LICENSE BANNER + LOCKDOWN (Plan 4 Phase 2)
   ============================================ */
.license-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 10px 16px;
  background: rgba(59, 130, 246, 0.1);
  border-bottom: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 500;
}
.license-banner[hidden] { display: none; }
.license-banner--info {
  background: rgba(59, 130, 246, 0.12);
  border-bottom-color: rgba(59, 130, 246, 0.3);
}
.license-banner--warning {
  background: rgba(251, 191, 36, 0.15);
  border-bottom-color: rgba(251, 191, 36, 0.4);
  color: var(--warning-600, var(--warning));
}
.license-banner-dismiss {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  opacity: 0.7;
}
.license-banner-dismiss:hover { opacity: 1; }

.license-lockdown {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.license-lockdown-card {
  max-width: 520px;
  padding: var(--sp-6);
  background: var(--bg-card);
  border: 1px solid var(--danger);
  border-radius: var(--r-lg);
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.license-lockdown-card h1 {
  color: var(--danger);
  margin-top: 0;
  margin-bottom: var(--sp-3);
}
.license-lockdown-card p { margin: var(--sp-3) 0; color: var(--text-2); }
.license-lockdown-node {
  background: rgba(255, 255, 255, 0.04);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.license-lockdown-node code {
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  color: var(--text-1);
}
.license-lockdown-copy {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
}
.license-lockdown-contact {
  display: inline-block;
  margin-top: var(--sp-4);
  padding: 10px 20px;
  background: var(--danger);
  color: #fff;
  border-radius: var(--r-md);
  text-decoration: none;
  font-weight: 600;
}
/* When the lockdown overlay is visible, dim + freeze the underlying app. */
.license-locked .view-container,
.license-locked .top-header,
.license-locked .sidebar {
  pointer-events: none;
  opacity: 0.3;
  filter: blur(1px);
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
