/* ==========================================================================
   DataQuery Pro - Modern Dark UI Design System
   ========================================================================== */

:root {
  --bg-app: #080C15;
  --bg-surface: #0E1526;
  --bg-card: #131C31;
  --bg-card-hover: #17233D;
  --bg-input: #0A0F1D;
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-active: rgba(6, 182, 212, 0.5);

  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --text-subtle: #64748B;

  --accent-cyan: #06B6D4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-blue: #3B82F6;
  --accent-emerald: #10B981;
  --accent-amber: #F59E0B;
  --accent-rose: #F43F5E;
  --accent-violet: #8B5CF6;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.2);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: #25334D;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #3B4D6E;
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.app-header {
  background: rgba(14, 21, 38, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #06B6D4, #3B82F6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-tag {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.connection-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
}

.status-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  position: relative;
}

.status-indicator.online {
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
}

.status-indicator.online::after {
  content: '';
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 50%;
  border: 1px solid var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

.connection-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.connection-info strong {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #E2E8F0;
}

.db-user {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.mode-badge {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.latency-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-cyan);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ==========================================================================
   Navigation Tabs
   ========================================================================== */
.app-tabs {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 2rem;
}

.tabs-wrapper {
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.85rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
}

.nav-tab.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.05);
}

.tab-badge {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.nav-tab.active .tab-badge {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
}

/* ==========================================================================
   Buttons & Form Controls
   ========================================================================== */
.btn {
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #06B6D4, #0284C7);
  color: #fff;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.5);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
}

.btn-outline {
  background: transparent;
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.4);
}

.btn-outline:hover {
  background: rgba(6, 182, 212, 0.1);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
}

.btn-xs {
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-cyan);
  cursor: pointer;
  font-size: 0.78rem;
}
.btn-link:hover {
  text-decoration: underline;
}

.search-input, .form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-input:focus, .form-input:focus, .form-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan-glow);
}

/* ==========================================================================
   App Content Views
   ========================================================================== */
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  display: none;
  flex: 1;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Dashboard View
   ========================================================================== */
.dashboard-container {
  padding: 2rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.hero-banner {
  background: linear-gradient(135deg, rgba(14, 21, 38, 0.95), rgba(19, 28, 49, 0.95));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.hero-content h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.hero-content .highlight {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
}

.hero-content p {
  color: var(--text-muted);
  max-width: 650px;
  font-size: 0.9rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1.25rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-card.cyan .metric-icon { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.metric-card.emerald .metric-icon { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.metric-card.violet .metric-icon { background: rgba(139, 92, 246, 0.15); color: var(--accent-violet); }
.metric-card.amber .metric-icon { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.metric-card.blue .metric-icon { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.metric-card.rose .metric-icon { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.metric-desc {
  font-size: 0.74rem;
  color: var(--text-subtle);
  margin-top: 0.25rem;
}

/* Dashboard Columns */
.dash-columns {
  display: flex;
  gap: 1.5rem;
}

.flex-2 { flex: 2; }
.flex-1 { flex: 1.2; }

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
}

.panel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-title-group h3 {
  font-size: 1rem;
  font-weight: 700;
}

.card-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.recent-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--transition-fast);
}

.recent-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.recent-main strong {
  display: block;
  font-size: 0.84rem;
  color: #fff;
}

.recent-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.recent-amount {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-emerald);
}

/* ==========================================================================
   Table Explorer Layout
   ========================================================================== */
.explorer-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 110px);
  overflow: hidden;
}

.explorer-sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h3 {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar-search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.sidebar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.82rem;
  width: 100%;
}

.tables-nav-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem 0;
}

.table-nav-item {
  padding: 0.6rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.84rem;
  color: var(--text-muted);
  border-left: 3px solid transparent;
}

.table-nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.table-nav-item.active {
  background: rgba(6, 182, 212, 0.08);
  color: var(--accent-cyan);
  font-weight: 600;
  border-left-color: var(--accent-cyan);
}

.table-nav-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

.table-nav-item.active .table-nav-count {
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
}

/* Explorer Main Area */
.explorer-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  overflow: hidden;
}

.table-toolbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex: 1;
}

.table-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.table-title-wrap h2 {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #fff;
}

.global-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 420px;
}

.global-search-wrap svg {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

.global-search-wrap input {
  padding-left: 2.2rem;
  padding-right: 2rem;
  width: 100%;
}

.clear-search-btn {
  position: absolute;
  right: 0.6rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Filters Drawer */
.filters-panel {
  background: #0B1120;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 1.5rem;
  max-height: 180px;
  overflow-y: auto;
}

.filters-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.filters-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.65rem;
}

.col-filter-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.col-filter-item label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-filter-item input {
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */
.table-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg-app);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.data-table th {
  background: #111A2E;
  color: #E2E8F0;
  font-weight: 600;
  padding: 0.65rem 0.95rem;
  border-bottom: 2px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
  transition: color var(--transition-fast);
}

.data-table th.sortable:hover {
  color: var(--accent-cyan);
}

.sort-icon {
  margin-left: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-subtle);
}

.sort-icon.active {
  color: var(--accent-cyan);
}

.data-table td {
  padding: 0.55rem 0.95rem;
  border-bottom: 1px solid var(--border-subtle);
  color: #CBD5E1;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(6, 182, 212, 0.06);
  cursor: pointer;
}

.data-table td.cell-num {
  font-family: var(--font-mono);
  text-align: right;
  color: #93C5FD;
}

.data-table td.cell-null {
  color: var(--text-subtle);
  font-style: italic;
}

.data-table td.cell-date {
  font-family: var(--font-mono);
  color: #A7F3D0;
}

/* Pagination Bar */
.table-pagination-bar {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 0.65rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pagination-info strong {
  color: #fff;
  font-family: var(--font-mono);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-current {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.page-current input {
  width: 48px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-family: var(--font-mono);
  text-align: center;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
}

.pagination-page-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.select-sm {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

/* ==========================================================================
   Visual Query Builder
   ========================================================================== */
.builder-container {
  padding: 2rem;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}

.builder-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: var(--shadow-md);
}

.builder-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1.25rem;
}

.builder-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.builder-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.builder-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.builder-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.builder-section.full-width {
  grid-column: span 2;
}

.builder-section.half-width {
  grid-column: span 1;
}

.step-num {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
  font-size: 0.7rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.4rem;
}

.section-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.builder-cols-checklist {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  max-height: 140px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.45rem;
}

.col-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

.col-checkbox-label:hover {
  color: #fff;
}

.conditions-list {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.condition-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cond-logic-select {
  width: 85px;
}

.cond-col-select {
  flex: 1.2;
}

.cond-op-select {
  width: 140px;
}

.cond-val-input {
  flex: 2;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.builder-preview-box {
  background: #060911;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.sql-preview-code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--accent-cyan);
  white-space: pre-wrap;
  word-break: break-all;
}

.builder-results-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.results-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   SQL Console View
   ========================================================================== */
.console-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 110px);
  overflow: hidden;
}

.console-sidebar {
  width: 320px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.console-sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
}

.c-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.75rem 0.5rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.c-tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.05);
}

.console-presets-list, .console-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.preset-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  transform: translateX(2px);
}

.preset-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.25rem;
}

.preset-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.console-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

.editor-panel {
  display: flex;
  flex-direction: column;
  background: #080D19;
  border-bottom: 1px solid var(--border-subtle);
  height: 220px;
}

.editor-header {
  padding: 0.65rem 1.25rem;
  background: #0D1426;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-tip {
  font-size: 0.72rem;
  color: var(--text-subtle);
  margin-right: 0.5rem;
}

.editor-tip kbd {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-family: var(--font-mono);
}

.editor-body {
  flex: 1;
  padding: 0.5rem 1.25rem;
}

.editor-body textarea {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: #F8FAFC;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
}

.console-output-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.output-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.6rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.output-status {
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

.console-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 3rem;
  text-align: center;
  color: var(--text-subtle);
}

.placeholder-icon {
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* ==========================================================================
   Schema & Data Dictionary
   ========================================================================== */
.schema-container {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.schema-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.schema-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.schema-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.schema-relations-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.rel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.rel-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.rel-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chip-from { color: #38BDF8; }
.chip-arrow { color: var(--text-subtle); }
.chip-to { color: #A7F3D0; }

.schema-tables-accordion {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1.25rem;
}

.schema-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color var(--transition-fast);
}

.schema-table-card:hover {
  border-color: var(--border-strong);
}

.st-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.st-name {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.st-cols-table {
  width: 100%;
  font-size: 0.74rem;
  border-collapse: collapse;
}

.st-cols-table th {
  color: var(--text-muted);
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
}

.st-cols-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.pk-badge {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
}

.type-pill {
  font-family: var(--font-mono);
  color: #38BDF8;
}

/* ==========================================================================
   Record Detail Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 2rem;
}

.modal-card {
  background: #0E1526;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 780px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-title-group h3 {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.record-field-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-key {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-val {
  font-size: 0.85rem;
  color: #fff;
  word-break: break-word;
  white-space: pre-wrap;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   Loading Overlay & Feedback
   ========================================================================== */
.loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(8, 12, 21, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 20;
  font-size: 0.85rem;
  color: var(--accent-cyan);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(6, 182, 212, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: #111A2E;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  display: none;
  flex-direction: column;
  z-index: 50;
  padding: 0.35rem 0;
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-item {
  background: none;
  border: none;
  color: var(--text-main);
  padding: 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.dropdown-item:hover {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 999;
}

.toast {
  background: #131C31;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  animation: toastIn 0.25s ease;
  min-width: 260px;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }
.toast.info { border-left: 4px solid var(--accent-cyan); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Utilities */
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}
.badge-accent {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}
.badge-subtle {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

/* ==========================================================================
   Sync & Replication View Styles
   ========================================================================== */
.btn-emerald {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
  font-weight: 700;
}
.btn-emerald:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.5);
}

.btn-lg {
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
}

.sync-container {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.sync-hero-card {
  background: linear-gradient(135deg, rgba(14, 21, 38, 0.98), rgba(20, 32, 58, 0.98));
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.12);
}

.sync-hero-info h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.sync-hero-info p {
  color: var(--text-muted);
  max-width: 620px;
  font-size: 0.88rem;
}

.sync-badge {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.65rem;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.sync-actions-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-end;
}

.sync-progress-card {
  background: #0E1526;
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: fadeIn 0.3s ease;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.progress-title {
  font-size: 0.9rem;
  color: #fff;
  font-family: var(--font-sans);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10B981, #06B6D4);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-family: var(--font-mono);
}

.topology-grid {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  justify-content: space-between;
}

.topology-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.topology-card.dest {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(135deg, var(--bg-card), rgba(16, 185, 129, 0.05));
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-role {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
}

.top-db-name {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.top-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.top-details strong {
  color: #CBD5E1;
}

.topology-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--accent-emerald);
  gap: 0.25rem;
}

.sync-mode-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   Portal & Operational Hub Styles
   ========================================================================== */
.portal-container {
  padding: 3rem 2rem 5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  align-items: center;
}

.portal-hero {
  text-align: center;
  max-width: 760px;
}

.portal-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.85rem;
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.portal-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  color: #fff;
}

.portal-hero p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Two-column Pill Grid matching user screenshot */
.portal-pills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem 1.85rem;
  width: 100%;
  max-width: 980px;
}

.portal-pill-btn {
  border: none;
  border-radius: 26px;
  padding: 1.35rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.portal-pill-btn:hover {
  transform: translateY(-3px) scale(1.015);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  filter: brightness(1.08);
}

.portal-pill-btn:active {
  transform: translateY(0) scale(0.99);
}

.pill-title {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #FFFFFF;
}

.pill-sub {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.88;
}

/* Specific Pill Colors from Screenshot */
.pill-magenta {
  background: linear-gradient(135deg, #B82375, #9E1961);
}
.pill-magenta .pill-sub { color: #FCE7F3; }

.pill-yellow {
  background: linear-gradient(135deg, #F5B800, #E0A500);
}
.pill-yellow .pill-title { color: #111827; }
.pill-yellow .pill-sub { color: #2D3748; }

.pill-green {
  background: linear-gradient(135deg, #247535, #1B5D2A);
}
.pill-green .pill-sub { color: #D1FAE5; }

.pill-charcoal {
  background: linear-gradient(135deg, #4B4B4B, #383838);
}
.pill-charcoal .pill-sub { color: #D1D5DB; }

.pill-maroon {
  background: linear-gradient(135deg, #680505, #500404);
}
.pill-maroon .pill-sub { color: #FEE2E2; }

.pill-blue-gold {
  background: linear-gradient(135deg, #004B99, #00366F);
  border: 2px solid #F5B800;
  box-shadow: 0 0 16px rgba(245, 184, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.4);
}
.pill-blue-gold .pill-sub { color: #FEF08A; }

.pill-cyan {
  background: linear-gradient(135deg, #00A8CC, #008AA8);
}
.pill-cyan .pill-sub { color: #E0F2FE; }

.pill-orange {
  background: linear-gradient(135deg, #E67E22, #D35400);
}
.pill-orange .pill-sub { color: #FFEDD5; }

.pill-purple {
  background: linear-gradient(135deg, #4C22A3, #3B1A80);
}
.pill-purple .pill-sub { color: #EDE9FE; }

.pill-teal-suite {
  background: linear-gradient(135deg, #0D9488, #047857);
  grid-column: span 2;
  border: 2px solid rgba(6, 182, 212, 0.5);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.25), 0 6px 18px rgba(0,0,0,0.4);
}
.pill-teal-suite .pill-sub { color: #CCFBF1; }

/* Operational Module Views */
.module-view-container {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.module-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.75rem;
}

.module-title-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.module-badge-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: var(--shadow-sm);
}

.module-title-area h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.module-title-area p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.module-tabs-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 768px) {
  .portal-pills-grid {
    grid-template-columns: 1fr;
  }
  .pill-teal-suite {
    grid-column: span 1;
  }
}
