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

:root {
  --bg-base:       #090e1a;
  --bg-surface:    #0f172a;
  --bg-elevated:   #1e293b;
  --bg-hover:      #1a2744;
  --border:        #1e3a5f;
  --border-light:  #243c5f;
  --accent:        #3b82f6;
  --accent-glow:   rgba(59,130,246,0.18);
  --accent-dim:    #2563eb;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --error:         #ef4444;
  --text-primary:  #e2e8f0;
  --text-secondary:#94a3b8;
  --text-muted:    #475569;
  --mono:          'JetBrains Mono', 'Fira Code', monospace;
  --sans:          'Inter', system-ui, sans-serif;
  --radius:        8px;
  --radius-lg:     12px;
  --sidebar-w:     280px;
  --header-h:      58px;
  --transition:    0.18s ease;
}

body.light-mode {
  --bg-base:       #f8fafc;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f1f5f9;
  --bg-hover:      #e2e8f0;
  --border:        #cbd5e1;
  --border-light:  #e2e8f0;
  --text-primary:  #0f172a;
  --text-secondary:#475569;
  --text-muted:    #94a3b8;
  --accent-glow:   rgba(59,130,246,0.1);
}

.theme-toggle svg {
  transition: transform 0.3s ease;
}

body.light-mode .sun-icon { display: none; }
body:not(.light-mode) .moon-icon { display: none; }

.hidden { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--sans);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 13.5px;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ── Header ──────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

body:not(.light-mode) .header {
  background: linear-gradient(90deg, #0a1628 0%, #0f1e3a 100%);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.header-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--accent-glow);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.header-subtitle {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15,23,42,0.6);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  margin-left: auto;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
  animation: pulse-idle 2s infinite;
}

.status-dot.connected { background: var(--success); animation: pulse-green 2s infinite; }
.status-dot.error     { background: var(--error);   animation: none; }

@keyframes pulse-idle  { 0%,100%{opacity:1} 50%{opacity:0.4} }
@keyframes pulse-green { 0%,100%{box-shadow:0 0 0 0 rgba(34,197,94,0.4)} 50%{box-shadow:0 0 0 5px rgba(34,197,94,0)} }

.status-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.status-detail {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
}

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

.btn-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.btn-icon.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.db-selector {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.db-selector:hover, .db-selector:focus { border-color: var(--accent); }

/* ── Layout ──────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: 180px;
  max-width: 480px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.sidebar-search {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition);
}
.sidebar-search::placeholder { color: var(--text-muted); }
.sidebar-search:focus { border-color: var(--accent); }

/* Sidebar Nav */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-item svg { opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.tree-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Schema node */
.schema-node { margin-bottom: 2px; }

.schema-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  border-radius: var(--radius);
  margin: 0 6px;
  transition: all var(--transition);
  user-select: none;
}
.schema-header:hover { background: var(--bg-hover); color: var(--text-primary); }
.schema-header .schema-icon { font-size: 13px; transition: transform var(--transition); }
.schema-header.open .schema-icon { transform: rotate(90deg); }
.schema-count {
  margin-left: auto;
  font-size: 10px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 10px;
  font-family: var(--mono);
}

.schema-tables { display: none; }
.schema-tables.open { display: block; }

.table-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 28px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--mono);
  border-radius: var(--radius);
  margin: 1px 6px;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.table-item.active { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(59,130,246,0.3); }
.table-item .tbl-icon { font-size: 12px; flex-shrink: 0; }
.table-item .tbl-type { font-size: 9px; background: var(--bg-elevated); padding: 1px 4px; border-radius: 4px; color: var(--text-muted); margin-left: auto; flex-shrink: 0; }

/* ── Resize Handle ───────────────────────────────────────────── */
.resize-handle {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background var(--transition);
}
.resize-handle:hover, .resize-handle.dragging { background: var(--accent); }

/* ── Main Panel ──────────────────────────────────────────────── */
.main-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

/* ── Welcome ─────────────────────────────────────────────────── */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 40px;
}
.welcome-icon { opacity: 0.4; }
.welcome-title { font-size: 22px; font-weight: 600; color: var(--text-primary); }
.welcome-desc { color: var(--text-secondary); line-height: 1.7; font-size: 13px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary:hover { background: var(--accent-dim); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,0.4); }

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-sm:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Table View ──────────────────────────────────────────────── */
.table-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-toolbar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: 16px;
}
.table-title-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}
.table-breadcrumb {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-secondary);
}
.table-breadcrumb .bc-schema { color: var(--text-muted); }
.table-breadcrumb .bc-sep { color: var(--text-muted); margin: 0 4px; }
.table-breadcrumb .bc-table { color: var(--accent); font-weight: 600; }

.table-meta { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }
.table-actions { display: flex; gap: 6px; }

.grid-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}

.data-grid-container {
  min-height: 100%;
}

.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-family: var(--mono);
}

.data-grid thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-grid th {
  background: var(--bg-elevated);
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  cursor: default;
}
.data-grid th:last-child { border-right: none; }

.data-grid td {
  border-bottom: 1px solid rgba(30,58,95,0.5);
  border-right: 1px solid rgba(30,58,95,0.3);
  padding: 7px 12px;
  color: var(--text-primary);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-grid td:last-child { border-right: none; }

.data-grid tbody tr { transition: background var(--transition); }
.data-grid tbody tr:hover { background: var(--bg-hover); }
.data-grid tbody tr:nth-child(even) { background: rgba(15,23,42,0.5); }
.data-grid tbody tr:nth-child(even):hover { background: var(--bg-hover); }

.data-grid .null-val { color: var(--text-muted); font-style: italic; }
.data-grid .num-val  { color: #67e8f9; }
.data-grid .bool-val { color: #a3e635; }
.data-grid .row-num  { color: var(--text-muted); font-size: 10.5px; user-select: none; width: 40px; text-align: right; padding-right: 8px; }

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}
.page-info { font-size: 12px; color: var(--text-muted); font-family: var(--mono); flex: 1; text-align: center; }

/* ── Query View ──────────────────────────────────────────────── */
.query-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.query-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.query-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.8px; }
.query-actions { display: flex; gap: 8px; }

.query-editor-wrap {
  position: relative;
  flex-shrink: 0;
}

.sql-editor {
  width: 100%;
  height: 160px;
  background: #070d1a;
  border: none;
  border-bottom: 2px solid var(--border);
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  padding: 16px;
  resize: vertical;
  outline: none;
  min-height: 80px;
  max-height: 400px;
}
.sql-editor:focus { border-bottom-color: var(--accent); }

.editor-hints {
  position: absolute;
  bottom: 10px;
  right: 12px;
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: var(--text-muted);
}

.query-results {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}

.query-placeholder {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.query-stats {
  font-size: 11px;
  color: var(--text-muted);
  padding-bottom: 10px;
  font-family: var(--mono);
}

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slide-in 0.2s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(4px); } }

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
/* ── Dashboard View ───────────────────────────────────────────── */
.dashboard-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  background: radial-gradient(circle at top right, rgba(59,130,246,0.05), transparent 400px), var(--bg-base);
}

.dashboard-header { margin-bottom: 24px; }
.dashboard-title { font-size: 24px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.dashboard-subtitle { color: var(--text-muted); font-size: 13px; }

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); border-color: var(--accent); }

.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon.patients     { background: rgba(59,130,246,0.1); color: var(--accent); }
.kpi-icon.revenue      { background: rgba(34,197,94,0.1);  color: var(--success); }
.kpi-icon.encounters   { background: rgba(245,158,11,0.1); color: var(--warning); }
.kpi-icon.practitioners { background: rgba(139,92,246,0.1); color: #8b5cf6; }

.kpi-data { display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.kpi-value { font-size: 20px; font-weight: 700; color: #fff; font-family: var(--mono); }

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 300px;
}
.chart-card.large { grid-column: span 2; }
.chart-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chart-body { flex: 1; position: relative; width: 100%; min-height: 0; }

@media (max-width: 1000px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.large { grid-column: span 1; }
}

/* ── Reports View ─────────────────────────────────────────────── */
.reports-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  background: var(--bg-base);
}
.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.report-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
}
.report-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 12px 32px rgba(0,0,0,0.4); }
.report-name { font-size: 16px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.report-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; min-height: 40px; }
.report-meta { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.report-tag { background: rgba(59,130,246,0.1); color: var(--accent); font-size: 10px; padding: 4px 10px; border-radius: 20px; font-weight: 600; text-transform: uppercase; }
.report-date { font-size: 11px; color: var(--text-muted); }

/* AI Panel */
.ai-panel {
  position: absolute;
  top: 60px; right: 24px; bottom: 24px;
  width: 400px;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 50px rgba(0,0,0,0.6);
  z-index: 1000;
  animation: aiSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes aiSlideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.ai-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.02);
}
.ai-badge { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.ai-panel-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.ai-panel-content strong { color: #fff; font-weight: 600; }
.ai-panel-content p { margin-bottom: 16px; }
.ai-panel-content ul { padding-left: 18px; margin-bottom: 16px; }
.ai-panel-content li { margin-bottom: 10px; position: relative; }
.ai-panel-content li::marker { color: var(--accent); }

.ai-panel-footer { padding: 16px 20px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); text-align: center; }

.btn-icon { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-icon:hover { background: var(--bg-hover); color: #fff; }

.ai-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 16px; color: var(--text-muted); }

.spinner-lg {
  width: 32px; height: 32px;
  border: 3px solid rgba(59,130,246,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* NL Generator */
.nl-generator-wrap.large {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 800px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all var(--transition);
  margin-right: 12px;
}
.nl-generator-wrap.large:focus-within {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}
.nl-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 14px;
  outline: none;
  min-width: 0;
}
.nl-input::placeholder { color: var(--text-muted); }
.ai-icon-small { color: var(--accent); flex-shrink: 0; }
.btn-ai-gen {
  padding: 6px 16px;
  font-size: 12px;
  height: 32px;
  white-space: nowrap;
}
.btn-ai-gen.loading { opacity: 0.7; pointer-events: none; }

.btn-voice {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-voice:hover { background: rgba(255,255,255,0.1); color: var(--accent); }
.btn-voice.recording { 
  color: #ef4444; 
  background: rgba(239, 68, 68, 0.1); 
  animation: glow-red 1.5s infinite; 
}
@keyframes glow-red {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Customizations for Query Toolbar alignment */
.query-toolbar {
  flex-direction: column;
  gap: 12px;
  align-items: stretch !important;
}
.nl-generator-wrap.large {
  width: 100%;
}
.query-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-suggest {
  background: rgba(139, 92, 246, 0.1);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.2);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.btn-suggest:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.2);
  border-color: #a78bfa;
  color: #fff;
  transform: translateY(-1px);
}
.btn-suggest.loading {
  opacity: 0.6;
  cursor: wait;
  animation: pulse-purple 1.5s infinite;
}
@keyframes pulse-purple {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* ── Dictionary View ─────────────────────────────────────────── */
.dictionary-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  background: var(--bg-base);
}
.dictionary-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
}
.dictionary-section-header {
  padding: 16px 20px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.dictionary-table-name { font-size: 16px; font-weight: 700; color: var(--accent); }
.dictionary-table-desc { font-size: 13px; color: var(--text-muted); }

.dictionary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
}
.dictionary-item {
  background: var(--bg-surface);
  padding: 16px 20px;
}
.dictionary-item-label { font-size: 12px; font-weight: 700; color: #fff; margin-bottom: 4px; font-family: var(--mono); }
.dictionary-item-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }

.concept-card {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.concept-name { font-size: 14px; font-weight: 600; color: #fff; font-family: var(--mono); }
.concept-sql { 
  font-size: 11px; 
  color: var(--accent); 
  background: rgba(59,130,246,0.05); 
  padding: 8px; 
  border-radius: 4px; 
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Relationships ─────────────────────────────────────────── */
.rel-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.rel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}
.rel-card:hover { border-color: var(--accent); background: rgba(255,255,255,0.02); }
.rel-info { flex: 1; }
.rel-path { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; color: #fff; margin-bottom: 4px; }
.rel-arrow { color: var(--accent); opacity: 0.6; }
.rel-table { color: var(--accent); font-weight: 700; }
.rel-col { color: var(--text-secondary); }
.rel-desc { font-size: 12px; color: var(--text-muted); }

.rel-actions { display: flex; gap: 8px; }
.btn-accept { 
  background: rgba(16, 185, 129, 0.1); 
  color: #10b981; 
  border: 1px solid rgba(16, 185, 129, 0.2); 
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}
.btn-accept:hover { background: #10b981; color: #fff; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  transition: all 0.3s;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 95%;
  max-width: 500px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 60px rgba(0,0,0,0.8);
  animation: modal-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
@keyframes modal-in { 
  from { transform: translateY(30px) scale(0.95); opacity: 0; } 
  to { transform: translateY(0) scale(1); opacity: 1; } 
}

.modal-header { 
  padding: 20px 24px; 
  border-bottom: 1px solid var(--border); 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  background: rgba(255,255,255,0.02);
}
.modal-header h3 { font-size: 18px; font-weight: 700; color: #fff; margin: 0; }
.modal-body { 
  padding: 20px 24px; 
  overflow-y: auto;
  flex: 1;
}
.modal-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 10px; }
.modal-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #fff;
  font-size: 15px;
  outline: none;
  transition: all 0.2s;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }
.modal-footer { 
  padding: 20px 24px; 
  border-top: 1px solid var(--border); 
  display: flex; 
  justify-content: flex-end; 
  gap: 12px; 
  background: rgba(255,255,255,0.01); 
}

.btn-secondary { 
  background: transparent; 
  border: 1px solid var(--border); 
  color: var(--text-secondary); 
  padding: 10px 20px; 
  border-radius: 6px; 
  cursor: pointer; 
  font-size: 14px; 
  font-weight: 500;
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--bg-hover); color: #fff; border-color: var(--text-muted); }

/* ── Reports Table Design ────────────────────────────────────── */
.reports-table-container {
  margin-top: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
}

.reports-table th {
  background: rgba(255,255,255,0.03);
  padding: 14px 20px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.reports-table td {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 13.5px;
  color: var(--text-secondary);
}

.reports-table tr:last-child td { border-bottom: none; }
.reports-table tr:hover { background: rgba(59,130,246,0.03); }

.report-name-cell { color: #fff; font-weight: 600; }
.report-tag-v2 { 
  display: inline-block;
  padding: 2px 10px; 
  border-radius: 20px; 
  background: rgba(59,130,246,0.1); 
  color: var(--accent); 
  font-size: 10px; 
  font-weight: 700;
  text-transform: uppercase;
}

.reports-actions-cell {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-report-action {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-report-action:hover {
  transform: translateY(-2px);
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.btn-report-action.delete:hover {
  background: var(--error);
  border-color: var(--error);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-report-action.excel:hover {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.reports-empty {
  padding: 60px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

.reports-search-wrap .sidebar-search {
  background: var(--bg-surface) !important;
  border-width: 2px !important;
}

/* ── Visual Relationships Editor ─────────────────────────────────────────── */
.node-editor-wrap {
  width: 100%;
  height: 600px;
  background: radial-gradient(circle at 50% 50%, rgba(30,58,95,0.4) 1px, transparent 1px);
  background-size: 20px 20px;
  background-color: #070d1a;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  position: relative;
}

.node-editor-canvas {
  position: relative;
  min-width: 2500px;
  min-height: 2000px;
}

.svg-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

.svg-line {
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
  transition: stroke 0.2s, stroke-width 0.2s;
}
.svg-line.drawing { stroke: var(--accent); stroke-dasharray: 4; animation: march 1s linear infinite; }
@keyframes march { to { stroke-dashoffset: -8; } }

.table-node {
  position: absolute;
  width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.table-node-header {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: grab;
  text-transform: uppercase;
}
.table-node-header:active { cursor: grabbing; }
.table-node-header svg { flex-shrink: 0; color: var(--accent); }

.table-node-body {
  padding: 4px 0;
  display: flex;
  flex-direction: column;
}

.table-node-col {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  position: relative;
}
.table-node-col:hover { background: var(--bg-hover); color: var(--text-primary); }

.col-anchor {
  width: 12px; height: 12px;
  background: var(--bg-elevated);
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  cursor: crosshair;
  transition: all 0.2s;
}
.col-anchor:hover {
  background: var(--accent);
  border-color: #fff;
  transform: scale(1.2);
}
.col-anchor.left { margin-right: 6px; transform: translateX(-4px); }
.col-anchor.right { margin-left: auto; transform: translateX(4px); }

/* -- Power BI Module ------------------------------------------- */
.bi-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f3f2f1; /* PowerBI Light Grey Background */
  color: #252423;
}

.bi-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* BI Internal Sidebar */
.bi-pages-sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid #edebe9;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.bi-sidebar-header {
  padding: 20px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #323130;
  border-bottom: 1px solid #edebe9;
}

.bi-page-list {
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}

.bi-page-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 13px;
  color: #605e5c;
  transition: all 0.2s;
  border-left: 4px solid transparent;
}

.bi-page-item:hover {
  background: #f3f2f1;
  color: #323130;
}

.bi-page-item.active {
  background: #edebe9;
  color: #252423;
  font-weight: 600;
  border-left-color: #ffdb15; /* PowerBI Yellow */
}

/* BI Main Canvas */
.bi-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 30px;
}

.bi-canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edebe9;
}

.bi-canvas-title h2 {
  font-size: 22px;
  font-weight: 700;
  color: #252423;
}

.bi-last-refresh {
  font-size: 11px;
  color: #605e5c;
  margin-top: 4px;
}

.bi-slicers {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bi-slicer {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bi-slicer label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #605e5c;
}

.bi-slicer select {
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 2px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}

.btn-bi-refresh {
  width: 32px;
  height: 32px;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #605e5c;
  transition: all 0.2s;
}

.btn-bi-refresh:hover {
  background: #f3f2f1;
  border-color: #ffdb15;
  color: #252423;
}

/* BI Grid */
.bi-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 100px;
  gap: 16px;
  overflow-y: auto;
  padding-bottom: 40px;
}

/* BI Dashboard Card */
.bi-card {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1.6px 3.6px 0 rgba(0,0,0,0.132), 0 0.3px 0.9px 0 rgba(0,0,0,0.108);
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
}

.bi-card:hover {
  box-shadow: 0 6.4px 14.4px 0 rgba(0,0,0,0.132), 0 1.2px 3.6px 0 rgba(0,0,0,0.108);
}

.bi-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #323130;
  margin-bottom: 12px;
}

.bi-card-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

/* KPI Card specifics */
.bi-kpi {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.bi-kpi-val {
  font-size: 28px;
  font-weight: 700;
  color: #252423;
}

.bi-kpi-label {
  font-size: 12px;
  color: #605e5c;
  margin-top: 4px;
}

/* Helper Grid Spans */
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.row-1 { grid-row: span 1; }
.row-2 { grid-row: span 2; }
.row-3 { grid-row: span 3; }
.row-4 { grid-row: span 4; }


/* -- BI CRUD Extensions ------------------------------------------ */
.bi-sidebar-header {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
}

.btn-bi-add {
  background: transparent;
  border: none;
  color: #0078d4;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  transition: background 0.2s;
}

.btn-bi-add:hover {
  background: #f3f2f1;
}

.bi-page-item {
  justify-content: space-between !important;
  padding-right: 8px !important;
}

.bi-page-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.bi-page-actions {
  display: none;
  gap: 4px;
}

.bi-page-item:hover .bi-page-actions {
  display: flex;
}

.bi-action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 2px;
}

.bi-action-btn.edit { color: #0078d4; }
.bi-action-btn.delete { color: #d13438; }
.bi-action-btn:hover { background: #fff; }

/* Modal Builder */
.bi-config-modal {
    max-width: 800px !important;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.widget-builder-section {
    border-top: 1px solid #edebe9;
    padding-top: 16px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.widget-form-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.bi-widget-form-item {
    background: #f8f9fa;
    border: 1px solid #edebe9;
    border-radius: 4px;
    padding: 12px;
}

.bi-widget-form-item .form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.bi-widget-form-item input, 
.bi-widget-form-item select {
    padding: 6px;
    border: 1px solid #ced4da;
    border-radius: 2px;
    font-size: 12px;
}

.w-title { flex: 1; }
.w-sql {
    width: 100%;
    height: 60px;
    font-family: monospace;
    font-size: 11px;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 2px;
    resize: vertical;
}

.btn-remove {
    background: transparent;
    border: none;
    color: #d13438;
    cursor: pointer;
    font-size: 14px;
}


/* -- Dashboard Last Update ------------------------------------- */
.last-update-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 6px 14px;
  border-radius: 20px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  animation: slide-in-top 0.4s ease-out;
}

.last-update-badge svg {
  color: var(--accent);
  animation: pulse 2s infinite;
}

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

@keyframes pulse {
  0% { opacity: 0.6; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0.6; transform: scale(0.9); }
}

.last-update-badge strong {
  color: #fff;
  font-weight: 600;
  margin-left: 2px;
}

/* -- User Profile ------------------------------------------ */
.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: 16px;
  padding-right: 16px;
  border-right: 1px solid var(--border);
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.user-role-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* -- Visual Query Designer --------------------------------- */
.visual-layout {
  display: flex;
  gap: 20px;
  height: 600px;
  margin-bottom: 30px;
}

.visual-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 20px;
}

.v-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
}

.visual-sidebar {
  width: 280px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.saved-visual-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.visual-design-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.visual-design-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.visual-design-card .name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.visual-design-card .meta {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-node-close {
  background: rgba(239, 68, 68, 0.1);
  border: none;
  color: #ef4444;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s;
}

.table-node:hover .btn-node-close {
  opacity: 1;
}

/* ── Custom Dashboard Styles ────────────────────────────────── */
.btn-report-action {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-report-action:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-report-action.pin:hover {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border-color: #8b5cf6;
}

.dashboard-dynamic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* ── Dashboard Filters ───────────────────────────────────────── */
.dashboard-filters {
  display: flex;
  gap: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.agenda-view .dashboard-filters {
  padding: 8px 16px;
  margin-bottom: 12px;
}

.agenda-view {
  padding-bottom: 40px;
}

.main-panel {
  flex: 1;
  padding: 24px;
  overflow-y: auto !important;
  height: 100%;
  position: relative;
}

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

.filter-group label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.filter-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  min-width: 140px;
  max-width: 280px; /* Prevent overflow */
  outline: none;
  cursor: pointer;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.filter-select:focus {
  border-color: var(--accent);
}

.kpi-value-large {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}

.btn-icon-sm {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.2s;
}

.btn-icon-sm:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* ── Launcher ───────────────────────────────────────────────── */
.launcher-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at top right, #0f172a, #020617);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  padding: 40px;
}

.launcher-content {
  text-align: center;
  max-width: 900px;
  width: 100%;
  padding: 40px;
}

.launcher-header h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #f8fafc;
}

.launcher-header p {
  color: #94a3b8;
  margin-bottom: 48px;
}

.launcher-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.launcher-card {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  padding: 48px 40px;
  cursor: pointer;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(5px);
}

.launcher-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}

.launcher-card:hover {
  transform: translateY(-10px);
  background: rgba(30, 41, 59, 0.8);
  border-color: var(--accent);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.launcher-card:hover::before {
  opacity: 1;
}

.card-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  transition: transform 0.3s ease;
}

.card-icon svg {
  width: 32px;
  height: 32px;
  stroke-width: 1.5;
}

.card-icon.gestion { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.card-icon.agenda { background: rgba(16, 185, 129, 0.1); color: #10b981; }

.launcher-card h3 {
  font-size: 22px;
  font-weight: 600;
  color: #f8fafc;
}

.launcher-card p {
  font-size: 14px;
  color: #94a3b8;
  line-height: 1.6;
}

.card-action {
  margin-top: 10px;
  font-weight: 600;
  color: var(--accent);
  font-size: 14px;
}

/* ── Sidebar Switch ─────────────────────────────────────────── */
.btn-launcher-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 20px;
  transition: all 0.2s;
}

.btn-launcher-switch:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* ── Agenda / Calendar ──────────────────────────────────────── */
.calendar-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 600px;
  padding: 2px;
  margin-top: 20px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  grid-template-rows: 40px repeat(15, 60px); /* Adjusted to 15 slots (6:00 to 20:00) */
  /* Remove restrictive scroll */
}

.calendar-header-cell {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 100;
}

.calendar-time-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  font-size: 10px;
  color: var(--text-muted);
  position: sticky;
  left: 0;
  background: var(--bg-surface);
  z-index: 50;
}

.calendar-slot {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background 0.1s;
}

.calendar-slot:hover {
  background: rgba(255, 255, 255, 0.02);
}

.appointment-item {
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  padding: 6px;
  font-size: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  cursor: grab;
  z-index: 10;
  overflow: hidden;
}

.appointment-item.completed { background: #10b981; }
.appointment-item.cancelled { background: #64748b; opacity: 0.7; text-decoration: line-through; }
.appointment-item.maintenance { background: #f59e0b; color: #fff; }
.appointment-item.training { background: #8b5cf6; color: #fff; }
.appointment-item.clinical { background: var(--accent); color: #fff; }

.infra-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.infra-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Search Popover ─────────────────────────────────────────── */
.search-results-popover {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 4px;
  box-shadow: var(--shadow-lg);
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.search-result-item:hover {
  background: var(--bg-surface);
  color: var(--accent);
}

.search-result-item:last-child {
  border-bottom: none;
}

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

.calendar-nav { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 20px; } .calendar-month-title { font-size: 20px; font-weight: 700; color: #fff; text-transform: capitalize; } .nav-controls { display: flex; gap: 8px; } .calendar-header-cell.today { background: var(--accent-glow); color: var(--accent); position: relative; } .calendar-header-cell.today::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: var(--accent); } .calendar-slot.today { background: rgba(59, 130, 246, 0.03); }
.sidebar-actions-group { padding: 10px 15px; display: flex; flex-direction: column; gap: 8px; } .sidebar-divider { height: 1px; background: var(--border); margin: 8px 0; opacity: 0.5; } .btn-sidebar-action { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; background: var(--accent); color: white; border: none; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 600; transition: all var(--transition); } .btn-sidebar-action svg { opacity: 0.9; } .btn-sidebar-action:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); } .btn-sidebar-action.secondary { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); color: var(--text-secondary); } .btn-sidebar-action.secondary:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--text-muted); color: var(--text-primary); }
/* -- Tabs --------------------------------------------------- */ .tab-container { display: flex; flex-direction: column; gap: 1px; } .tab-header { display: flex; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--border); } .tab-item { padding: 12px 24px; cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 14px; border-radius: 12px 12px 0 0; transition: all 0.2s; position: relative; } .tab-item:hover { color: var(--text-primary); background: rgba(255,255,255,0.03); } .tab-item.active { color: var(--accent); background: rgba(59, 130, 246, 0.05); } .tab-item.active::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: var(--accent); } .tab-pane { padding: 20px 0; } .tab-pane.hidden { display: none; } /* -- Status Pills ------------------------------------------- */ .status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; } .status-pill.connected { background: rgba(16, 185, 129, 0.1); color: #10b981; } .status-pill.error { background: rgba(239, 68, 68, 0.1); color: #ef4444; } .status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; } .table-container { overflow-x: auto; margin-top: 10px; } .data-grid { width: 100%; border-collapse: collapse; } .data-grid th { text-align: left; padding: 12px 16px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; } .data-grid td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 13px; } .data-grid tr:hover { background: rgba(255,255,255,0.02); }
/* -- Enhanced Tabs ----------------------------------------- */ .tab-header { background: rgba(255,255,255,0.02); border-radius: 12px; padding: 6px; border-bottom: none; gap: 8px; margin-bottom: 20px; } .tab-item { flex: 1; text-align: center; border-radius: 8px; padding: 10px; border: 1px solid transparent; background: transparent; color: var(--text-muted); } .tab-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); } .tab-item.active { background: var(--accent); color: white; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); } .tab-item.active::after { display: none; }
