/* EasyTLG Professional B2B Styles - 2025 */

/* Big Save Button */
.bigsave {
  width: 400px !important;
  font-size: 1.2rem !important;
  padding: 1.25rem 2.5rem !important;
  text-align: center !important;
  font-weight: 600 !important;
}

:root {
  /* Brand Colors - Premium Dark Theme */
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #93c5fd;
  --primary-dark: #1d4ed8;
  --secondary-color: #0ea5e9;
  --accent-color: #06b6d4;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;

  /* Premium Dark Background & Surface - Glassmorphic Blue-Black */
  --bg-color: #000511;
  --bg-light: #0a0f1c;
  --bg-gradient: linear-gradient(135deg, #000511 0%, #0a0f1c 25%, #1a1625 50%, #0f1419 75%, #000511 100%);

  --surface-color: rgba(10, 15, 28, 0.85);
  --surface-elevated: rgba(26, 22, 37, 0.9);
  --surface-overlay: rgba(15, 20, 25, 0.95);
  --glass-bg: rgba(20, 25, 35, 0.4);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

  /* Premium Dark Borders & Dividers */
  --border-color: rgba(255, 255, 255, 0.12);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --divider-color: rgba(255, 255, 255, 0.15);

  /* Premium Dark Text Colors */
  --text-color: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-inverse: #0f172a;

  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Premium 3D Shadows & Glass Effects */
  --shadow-sm: 0 2px 4px 0 rgb(0 0 0 / 0.4), 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 8px 16px -4px rgb(0 0 0 / 0.4), 0 4px 8px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 20px 40px -8px rgb(0 0 0 / 0.5), 0 8px 16px -4px rgb(0 0 0 / 0.3);
  --shadow-xl: 0 32px 64px -12px rgb(0 0 0 / 0.6), 0 16px 32px -8px rgb(0 0 0 / 0.4);
  --shadow-focus: 0 0 0 3px rgb(59 130 246 / 0.3), 0 0 20px rgb(59 130 246 / 0.2);
  --shadow-glow: 0 0 32px rgb(59 130 246 / 0.15);
  --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.2);

  /* Typography */
  --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-family-sans);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-color);
  background: var(--bg-gradient);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'rlig' 1, 'calt' 1;
  position: relative;
  overflow-x: hidden;
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navigation with Glass Effect */
.navbar {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: var(--glass-shadow);
  position: relative;
  z-index: 100;
}

.navbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2) 50%, transparent);
}

.nav-brand a {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
}

.nav-menu {
  display: flex;
  gap: 2rem;
}

.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 1.125rem;
  padding: 0.75rem 1.5rem;
  position: relative;
  transition: all 0.3s ease;
  border-radius: 12px;
  letter-spacing: 0.025em;
}

.nav-link:hover,
.nav-link.active {
  color: white;
  background: rgba(59, 130, 246, 0.15);
}

.nav-link.active::after {
  display: none;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-right: 15px;
}

.user-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.user-name {
  font-weight: 500;
  color: var(--text-color);
  text-align: right;
  width: 100%;
  top: 10px;
  position: relative;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  min-width: 120px;
}

.user-role {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: right;
  width: 100%;
}

.btn-link.sign-out-btn {
  text-align: right;
  justify-content: flex-end;
  align-items: center;
  display: flex;
  padding: 0px 0px 6px 0px !important;
}

/* Navigation Context Display */
.nav-context {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0 1rem;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  margin: 0 1rem;
}

.context-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.context-label {
  color: var(--text-muted);
  font-weight: 500;
}

.context-value {
  color: var(--text-color);
  font-weight: 600;
  background: rgba(99, 102, 241, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Disabled Navigation Links */
.nav-link.disabled {
  color: var(--text-subtle);
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.nav-link.disabled:hover {
  background: none;
  transform: none;
}

/* Study Context */
.study-context {
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border-color);
}

.study-name {
  padding: 1rem 1rem 0.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.study-name h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
}

/* Study Submenu */
.study-submenu {
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0;
  position: relative;
  z-index: 99;
}

.study-submenu::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1) 50%, transparent);
}

.submenu-container {
  display: flex;
  gap: 0;
  padding: 0 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.submenu-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  position: relative;
  transition: all 0.2s ease;
  border-radius: 0;
  white-space: nowrap;
}

.submenu-link:hover {
  color: var(--text-color);
  background: rgba(99, 102, 241, 0.08);
}

.submenu-link.active {
  color: white;
  background: rgba(99, 102, 241, 0.15);
}

.submenu-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-color);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.6);
}

/* Main Content with Glass Effect */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

.main-content.with-submenu {
  padding-top: 1rem;
}

.main-content > * {
  position: relative;
}

/* Page Headers with Glass Effect */
.page-header {
  margin-bottom: 2rem;
  padding: 2rem;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--glass-shadow);
  position: relative;
}

.page-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2) 50%, transparent);
  border-radius: 20px 20px 0 0;
}

.page-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-color);
}

.page-subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
}

/* Cards with Enhanced Glass Effect */

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

.card-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.card-content {
  padding: 1.5rem;
}

/* Study Cards */
.study-grid {
  display: grid;
  gap: 1rem;
}

.table-group-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface-color);
}

.study-header h3 {
  margin: 0 0 0.5rem 0;
}

.study-header a {
  color: var(--primary-color);
  text-decoration: none;
}

.study-header a:hover {
  text-decoration: underline;
}

.study-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.study-description {
  color: var(--text-muted);
  margin: 0.5rem 0;
}

.study-actions {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

.study-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-small,
.btn-link {
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.875rem;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--secondary-color);
  border-color: var(--border-color);
}

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

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-link {
  background: transparent;
  color: var(--primary-color);
  border: none;
  padding: 0.25rem 0;
}

.btn-link:hover {
  text-decoration: underline;
}

.text-danger {
  color: var(--error-color);
}

/* Enhanced Loading and Empty States */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-2xl);
  gap: var(--space-lg);
}

.loading::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: var(--space-md);
}

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text-color);
}

.empty-state p {
  color: var(--text-muted);
  margin: 0 0 1.5rem 0;
}

/* Error Messages */
.error-message {
  display: flex;
  align-items: start;
  gap: 1rem;
  padding: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--error-color);
}

.error-icon {
  font-size: 1.25rem;
}

.error-text strong {
  display: block;
  margin-bottom: 0.25rem;
}

/* Premium Query Builder Styles */
.query-builder-page {
  padding: 0;
  background: var(--bg-light);
  min-height: 100vh;
}

.query-builder-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  height: calc(100vh - 60px);
  gap: 1px;
  background: var(--border-light);
}

.query-sidebar {
  background: var(--surface-color);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  position: relative;
}

.query-main {
  display: flex;
  flex-direction: column;
  background: var(--surface-color);
  box-shadow: var(--shadow-lg);
  border-radius: 0 var(--radius-lg) 0 0;
  overflow: hidden;
}

/* Premium Sidebar Sections */
.query-form {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--border-light);
  background: linear-gradient(180deg, var(--surface-color) 0%, #fafbfc 100%);
}

.query-datasets {
  padding: var(--space-xl);
  flex: 1;
  background: var(--surface-color);
}

.query-form h3,
.query-datasets h3 {
  margin: 0 0 var(--space-lg) 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.query-form h3::before {
  content: '⚙️';
  font-size: 1rem;
}

.query-datasets h3::before {
  content: '📊';
  font-size: 1rem;
}

/* Premium Form Styles */
.form-group {
  margin-bottom: var(--space-xl);
  position: relative;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  position: relative;
}

.form-group label[for*='name']::after,
.form-group label[for*='study']::after {
  content: '*';
  color: var(--error-color);
  margin-left: var(--space-xs);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 1rem var(--space-lg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  font-weight: 500;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all var(--transition-base);
  font-family: inherit;
  color: var(--text-color);
  box-shadow: var(--glass-shadow);
  position: relative;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-focus), var(--shadow-md);
  transform: translateY(-1px);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
  background: var(--bg-color);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--border-light);
  box-shadow: none;
  transform: none;
}

/* Required fields have solid white borders */
.form-group input:required,
.form-group select:required,
.form-group textarea:required {
  border-color: rgba(255, 255, 255, 1);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
  font-family: var(--font-family-sans);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23667085' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 1rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  padding-right: 3rem;
}

/* Form Input Classes - same styling as form-group elements */
.form-input {
  width: 100%;
  padding: 1rem var(--space-lg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: var(--font-family-sans);
  transition: all var(--transition-base);
  backdrop-filter: blur(10px);
  position: relative;
}

.form-input:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-focus), var(--shadow-md);
  transform: translateY(-1px);
}

.form-input:disabled {
  background: var(--bg-color);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--glass-border);
  opacity: 0.6;
}

.form-input:required {
  border-color: rgba(255, 255, 255, 1);
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23667085' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 1rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  padding-right: 3rem;
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
  font-family: var(--font-family-sans);
}

/* Input Icons */
.form-group.has-icon {
  position: relative;
}

.form-group.has-icon input {
  padding-left: 3rem;
}

.form-group.has-icon .form-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

/* Premium SQL Editor Container */
.sql-editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-xl);
  padding-bottom: 0;
  background: linear-gradient(180deg, var(--surface-color) 0%, #fcfcfd 100%);
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 2px solid var(--border-light);
  background: var(--surface-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.editor-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.editor-header h3::before {
  content: '💻';
  font-size: 1.125rem;
}

.editor-actions {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.query-templates {
  margin-bottom: var(--space-lg);
  padding: var(--space-lg);
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  border: 1px solid var(--primary-color);
}

.query-templates label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 600;
  color: var(--primary-dark);
  font-size: 0.875rem;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.query-templates select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--primary-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--surface-color);
  color: var(--text-color);
  transition: all var(--transition-base);
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%232563eb' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 1rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  padding-right: 3rem;
}

.query-templates select:hover {
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.query-templates select:focus {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Premium SQL Editor */
.sql-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

#sql-textarea {
  flex: 1;
  padding: var(--space-xl);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-family: var(--font-family-mono);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.7;
  background: linear-gradient(135deg, #fafbfc 0%, #ffffff 100%);
  color: var(--text-color);
  resize: none;
  min-height: 350px;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow-y: auto;
}

#sql-textarea:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-lg);
}

#sql-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-focus), var(--shadow-lg);
  background: var(--surface-color);
}

#sql-textarea::placeholder {
  color: var(--text-subtle);
  font-style: italic;
  line-height: 1.6;
}

/* Code syntax highlighting hint */
.sql-editor::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color), var(--warning-color));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 1;
}

/* Premium Query Actions */
.query-actions {
  padding: var(--space-xl);
  border-top: 2px solid var(--border-light);
  background: linear-gradient(180deg, var(--bg-light) 0%, var(--surface-color) 100%);
  display: flex;
  gap: var(--space-lg);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.8);
}

.query-actions .btn-primary {
  padding: 1rem 2rem;
  font-weight: 700;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  letter-spacing: 0.025em;
  min-width: 140px;
  justify-content: center;
}

.query-actions .btn-secondary {
  padding: 1rem 1.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: 0.025em;
}

.btn-icon {
  font-size: 1.125rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Template table icon buttons - white icons on dark circle background */
.btn-icon.btn-danger,
.btn-icon.btn-secondary {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 2px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon.btn-danger {
  background: #1f2937;
  color: white;
}

.btn-icon.btn-danger:hover {
  background: #ef4444;
  transform: scale(1.1);
}

.btn-icon.btn-secondary {
  background: #1f2937;
  color: white;
}

.btn-icon.btn-secondary:hover {
  background: #6366f1;
  transform: scale(1.1);
}

/* Template table header styling */
.template-header-row th {
  background: var(--surface-elevated);
  border-bottom: 2px solid var(--border-color);
  padding: 1rem;
}

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

.template-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-color);
}

.template-header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Stats list styling */
.stats-list {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-color);
}

.stat-row {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row .stat-field {
  padding: 0.5rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-color);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stat-row .stat-field:hover {
  background: var(--bg-color);
  border-color: var(--border-color);
}

.stat-row .stat-field:focus {
  background: var(--surface-elevated);
  border-color: var(--primary-color);
  outline: none;
}

.stat-row .stat-field.order-field {
  width: 60px;
  text-align: center;
}

.stat-row .stat-field.decimals-field {
  width: 80px;
  text-align: center;
}

.stat-row .stat-field.stat-type-field {
  flex: 1;
  min-width: 150px;
}

/* Template table containers */
.template-table-container {
  overflow: hidden;
  border-radius: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  box-shadow: var(--shadow-md);
}

.template-table-container .data-table {
  margin: 0;
  border: none;
  border-radius: 0;
}

.template-table-container .template-header-row th {
  background: var(--surface-elevated);
  border-bottom: 2px solid var(--border-color);
  padding: 1.5rem;
}

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

.template-table-container .template-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
}

.template-table-container .template-header-actions {
  display: flex;
  gap: 0.75rem;
}

.template-table-container tbody tr:hover {
  background: var(--bg-color);
}

/* Stat Select Dropdowns */
.stat-select.search-input {
  flex: 1 !important;
  min-width: 0 !important;
  width: 100% !important;
  max-width: none !important;
}

/* Small Text Fields */
.search-input.small-field {
  width: 100px !important;
  min-width: 100px !important;
  max-width: 100px !important;
}

/* Query Results */
.query-results {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface-color);
}

.results-placeholder {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.placeholder-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Premium Page Header */
.query-builder-page .page-header {
  padding: var(--space-xl) var(--space-2xl);
  margin: 0;
  background: linear-gradient(135deg, var(--surface-color) 0%, var(--bg-light) 100%);
  border-bottom: 2px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.query-builder-page .page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.query-builder-page .page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-color);
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.query-builder-page .page-header h1::before {
  content: '🔧';
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.page-actions {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
}

/* Dataset Browser Styles */
.datasets-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  height: calc(100vh - 60px - 4rem);
  gap: 0;
}

.datasets-panel,
.dataset-details-panel {
  background: var(--surface-color);
  overflow-y: auto;
}

.datasets-panel {
  border-right: 1px solid var(--border-color);
}

.panel-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-color);
}

.panel-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.panel-content {
  padding: 1rem;
}

/* Dataset Items */
.dataset-item {
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface-color);
}

.dataset-item:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.1);
}

.dataset-item.active {
  border-color: var(--primary-color);
  background: rgb(37 99 235 / 0.05);
}

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

.dataset-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color);
}

.dataset-type {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-color);
  border-radius: 4px;
  color: var(--text-muted);
}

.dataset-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.dataset-description {
  margin: 0.5rem 0 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Dataset Details */
.dataset-info {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.dataset-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1rem 0;
}

.stat {
  text-align: center;
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 6px;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-color);
}

.dataset-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Columns Table */
.columns-section {
  padding: 1.5rem;
}

.columns-section h4 {
  margin: 0 0 1rem 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.columns-table {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.table-header {
  display: grid;
  grid-template-columns: 2fr 1fr 3fr;
  background: var(--bg-color);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-color);
}

.table-header > div,
.table-row > div {
  padding: 0.75rem;
  border-right: 1px solid var(--border-color);
}

.table-header > div:last-child,
.table-row > div:last-child {
  border-right: none;
}

.table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 3fr;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.table-row:last-child {
  border-bottom: none;
}

.table-row:hover {
  background: var(--bg-color);
}

.col-name strong {
  color: var(--text-color);
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

.badge.primary-key {
  background: #dbeafe;
  color: #1e40af;
}

.badge.required {
  background: #fef3c7;
  color: #92400e;
}

.stat-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  margin: 0.125rem;
  background: var(--glass-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  backdrop-filter: blur(8px);
}

.template-main-row {
  background: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
}

.template-sub-row {
  background: var(--bg-light);
}

.template-sub-row:last-of-type {
  border-bottom: 2px solid var(--border-color);
}

/* Global Text Utilities */
.text-subtle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  opacity: 0.8;
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-color);
  font-weight: 400;
  text-transform: none;
  opacity: 1;
  font-style: italic;
}

/* Premium Button System */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-link {
  font-weight: 600;
  padding: 0.875rem 1.75rem;
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
  font-size: 0.9375rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: inherit;
  letter-spacing: 0.025em;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: white;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  border: 2px solid var(--primary-color);
}

.btn-primary .plus-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  position: relative;
  margin-right: 8px;
}

.btn-primary .plus-icon::before,
.btn-primary .plus-icon::after {
  content: '';
  position: absolute;
  background: white;
  border-radius: 1px;
}

.btn-primary .plus-icon::before {
  width: 14px;
  height: 2px;
  top: 6px;
  left: 0;
}

.btn-primary .plus-icon::after {
  width: 2px;
  height: 14px;
  top: 0;
  left: 6px;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left var(--transition-slow);
}

.btn-primary:hover {
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-dark) 100%);
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:active {
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  background: linear-gradient(135deg, var(--text-muted) 0%, #94a3b8 100%);
  transform: none;
  box-shadow: var(--shadow-sm);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-primary:disabled::before {
  display: none;
}

.btn-success {
  background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
  color: white;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  border: 2px solid var(--success-color);
}

.btn-success .plus-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  position: relative;
  margin-right: 8px;
}

.btn-success .plus-icon::before,
.btn-success .plus-icon::after {
  content: '';
  position: absolute;
  background: white;
  border-radius: 1px;
}

.btn-success .plus-icon::before {
  width: 14px;
  height: 2px;
  top: 6px;
  left: 0;
}

.btn-success .plus-icon::after {
  width: 2px;
  height: 14px;
  top: 0;
  left: 6px;
}

.btn-success::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left var(--transition-slow);
}

.btn-success:hover {
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.btn-success:hover::before {
  left: 100%;
}

.btn-success:active {
  box-shadow: var(--shadow-md);
}

.btn-success:disabled {
  background: linear-gradient(135deg, var(--text-muted) 0%, #94a3b8 100%);
  transform: none;
  box-shadow: var(--shadow-sm);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-success:disabled::before {
  display: none;
}

.btn-secondary {
  background: var(--surface-color);
  color: var(--text-color);
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: var(--shadow-md);
  background: var(--primary-light);
}

.btn-secondary:active {
  box-shadow: var(--shadow-sm);
}

.btn-link {
  color: var(--primary-color);
  background: none;
  border: none;
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  font-size: 0.875rem;
  letter-spacing: 0.025em;
}

.btn-link:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  text-decoration: none;
}

.btn-link:active {
  opacity: 0.8;
}

/* Focus styles for accessibility */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-success:focus-visible,
.btn-link:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.form-group input:focus-visible,
.form-group select:focus-visible,
.form-group textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Loading states */
.btn-loading {
  position: relative;
  color: transparent;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Micro-interactions */
.form-group input:required:valid,
.form-group select:required:valid,
.form-group textarea:required:valid {
  border-color: var(--success-color);
}

.form-group input:invalid:not(:placeholder-shown),
.form-group select:invalid:not(:placeholder-shown),
.form-group textarea:invalid:not(:placeholder-shown) {
  border-color: var(--error-color);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Tooltips */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-color);
  color: var(--surface-color);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--space-xs);
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text-color);
  z-index: 1000;
}

/* Loading States */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  color: var(--text-muted);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Premium Responsive Design */
@media (max-width: 1400px) {
  .query-builder-layout,
  .datasets-layout {
    grid-template-columns: 380px 1fr;
  }
}

@media (max-width: 1200px) {
  .query-builder-layout,
  .datasets-layout {
    grid-template-columns: 350px 1fr;
  }

  .query-builder-page .page-header {
    padding: var(--space-lg) var(--space-xl);
  }

  .query-builder-page .page-header h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 968px) {
  .query-builder-layout,
  .datasets-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: calc(100vh - 60px);
  }

  .query-sidebar,
  .datasets-panel {
    border-right: none;
    border-bottom: 2px solid var(--border-light);
    max-height: 400px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .query-main {
    border-radius: 0;
  }

  .dataset-stats {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .sql-editor-container {
    min-height: 500px;
  }
}

@media (max-width: 768px) {
  :root {
    --space-xs: 0.25rem;
    --space-sm: 0.375rem;
    --space-md: 0.75rem;
    --space-lg: 1rem;
    --space-xl: 1.25rem;
    --space-2xl: 1.5rem;
  }

  .nav-menu {
    display: none;
  }

  .main-content {
    padding: var(--space-md);
  }

  .query-builder-page {
    padding: 0;
  }

  .query-builder-page .page-header {
    padding: var(--space-lg);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-lg);
  }

  .query-builder-page .page-header h1 {
    font-size: 1.375rem;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 0.875rem var(--space-md);
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .btn-primary,
  .btn-secondary,
  .btn-success {
    padding: 1rem var(--space-lg);
    font-size: 0.875rem;
    flex: 1;
    min-width: 120px;
  }

  .query-actions {
    flex-direction: column;
    gap: var(--space-md);
  }

  .query-actions .btn-primary,
  .query-actions .btn-secondary {
    width: 100%;
    flex: none;
  }

  #sql-textarea {
    padding: var(--space-lg);
    font-size: 14px;
    min-height: 250px;
  }

  .run-header {
    flex-direction: column;
    align-items: start;
    gap: var(--space-sm);
  }

  .status-grid {
    flex-direction: column;
    gap: var(--space-md);
  }

  .table-header,
  .table-row {
    grid-template-columns: 1fr;
  }

  .table-header > div,
  .table-row > div {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .table-header > div:last-child,
  .table-row > div:last-child {
    border-bottom: none;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #0f172a;
    --bg-light: #1e293b;
    --surface-color: #1e293b;
    --surface-elevated: #334155;
    --border-color: #334155;
    --border-light: #475569;
    --text-color: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;
  }

  #sql-textarea {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: var(--text-color);
  }

  .query-templates {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.3);
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-color: #000000;
    --primary-color: #0000ff;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .btn-primary::before {
    display: none;
  }
}

/* Premium Authentication Styles */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  position: relative;
}

.auth-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 3rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3) 50%, transparent);
}

.auth-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.auth-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.auth-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.125rem;
  font-weight: 500;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#email-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#email-input {
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--surface-elevated);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-color);
  transition: all var(--transition-base);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#email-input:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-focus);
}

#email-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-focus);
}

#email-input::placeholder {
  color: var(--text-subtle);
}

.auth-divider {
  position: relative;
  text-align: center;
  margin: 1rem 0;
}

.auth-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border) 50%, transparent);
}

.auth-divider span {
  background: var(--glass-bg);
  padding: 0 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  position: relative;
}

/* Premium Auth Buttons */
.auth-form .btn-primary,
.auth-form .btn-secondary {
  padding: 1rem 1.5rem;
  border-radius: 16px;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.auth-form .btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
  color: white;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.auth-form .btn-primary:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.auth-form .btn-secondary {
  background: var(--surface-elevated);
  color: var(--text-color);
  border-color: var(--glass-border);
}

.auth-form .btn-secondary:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-focus);
}

.auth-footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--glass-border);
}

.auth-footer p {
  margin: 0;
  color: var(--text-subtle);
  font-size: 0.875rem;
  font-weight: 500;
}

.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  padding: 1rem;
  color: #fca5a5;
  font-weight: 500;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Simple white SVG icons */
.auth-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.auth-icon-email {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='white'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75' /%3e%3c/svg%3e")
    no-repeat center;
  background-size: contain;
}

.auth-icon-google {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='white' d='M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z'/%3e%3cpath fill='white' d='M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z'/%3e%3cpath fill='white' d='M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z'/%3e%3cpath fill='white' d='M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z'/%3e%3c/svg%3e")
    no-repeat center;
  background-size: contain;
}

.auth-icon-key {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='white'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z' /%3e%3c/svg%3e")
    no-repeat center;
  background-size: contain;
}

/* Premium Admin Interface Styles */
.admin-tabs {
  display: flex;
  gap: 1rem;
  border-bottom: 2px solid var(--surface-overlay);
  padding-bottom: 0;
}

.tab-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  border-radius: 12px 12px 0 0;
  background: transparent;
  border: none;
  cursor: pointer;
  background: transparent;
  border: 2px solid transparent;
  border-bottom: none;
  transition: all var(--transition-base);
  position: relative;
  margin-bottom: -2px;
}

.tab-link:hover {
  color: var(--text-color);
  background: var(--surface-elevated);
}

.tab-link.active {
  color: var(--primary-color);
  /*background: var(--surface-elevated);*/
  border-color: var(--glass-border);
  border-bottom: 2px solid var(--glass-bg);
}

.tab-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color);
}

.tab-icon {
  font-size: 1.125rem;
}

/* Status Badges */
.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-active {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.status-draft {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.status-completed {
  background: rgba(99, 102, 241, 0.2);
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.status-badge.status-archived {
  background: rgba(107, 114, 128, 0.2);
  color: #6b7280;
  border: 1px solid rgba(107, 114, 128, 0.3);
}

/* Company Row Hover */
.company-row {
  transition: background-color 0.2s ease;
}

.company-row:hover {
  background-color: rgba(99, 102, 241, 0.08);
}

.tab-content {
  background: var(--glass-bg);
  border-radius: 0 16px 16px 16px;
  padding: 2rem;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  position: relative;
}

.tab-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1) 50%, transparent);
}

.section-header {
  display: block;
  margin-bottom: 2rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--text-color);
}

.form-panel {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: nowrap;
  min-height: 3rem;
}

.search-input,
.filter-select {
  padding: 1rem 1.25rem;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: var(--glass-bg);
  color: var(--text-color);
  font-weight: 500;
  backdrop-filter: blur(10px);
  min-width: 300px;
  max-width: 350px;
  font-size: 1rem;
  -webkit-backdrop-filter: blur(10px);
  transition: all var(--transition-base);
}

.search-input:hover,
.filter-select:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-focus);
}

.search-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-focus);
  transform: translateY(-1px);
}

.search-input::placeholder {
  color: var(--text-subtle);
}

.data-table-container {
  overflow: hidden;
  position: relative;
}

.data-table-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1) 50%, transparent);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.data-table thead {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.data-table th {
  padding: 1.25rem 1.5rem;
  text-align: left;
  font-weight: 700;
  color: var(--text-color);
  border-bottom: 2px solid var(--glass-border);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-weight: 500;
}

.data-table tbody tr {
  transition: all var(--transition-base);
}

.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.role-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-user {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-color);
}

.role-admin {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-color);
}

.role-company_admin {
  background: rgba(139, 92, 246, 0.1);
  color: var(--secondary-color);
}

.role-site_admin {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  border-radius: 8px;
  font-weight: 600;
}

/* Premium Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.25);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: black; /* var(--glass-bg);*/
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  position: relative;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-color);
  flex: 1;
}

.modal-close {
  position: absolute;
  top: 0.33rem;
  right: 0.33rem;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  font-size: 1.8rem;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.modal-body {
  padding: 0rem 2rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1rem;
  border-top: 1px solid var(--glass-border);
}

.permissions-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--glass-bg);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-base);
}

.checkbox-label:hover {
  color: var(--text-color);
}

.checkbox-label input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.05em;
}

.status-badge.active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.status-badge.inactive {
  background: rgba(107, 114, 128, 0.1);
  color: var(--text-muted);
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
}

.status-badge.draft {
  background: rgba(107, 114, 128, 0.1);
  color: var(--text-muted);
}

.status-badge.completed {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.status-badge.archived {
  background: rgba(75, 85, 99, 0.1);
  color: var(--text-subtle);
}

/* Studies Grid */
.studies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 2rem;
}

.study-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-md);
}

.study-card:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: var(--border-color);
}

.table-group-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2rem;
  margin: 10px 0;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-md);
}

.table-group-card:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.study-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 1rem;
  gap: 1rem;
}

.study-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.study-header a {
  color: var(--text-color);
  text-decoration: none;
  transition: color var(--transition-base);
}

.study-header a:hover {
  color: var(--primary-color);
}

.study-description {
  color: var(--text-secondary);
  margin: 0 0 1.5rem 0;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.study-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--surface-elevated);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meta-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
}

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

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  background: var(--glass-bg);
  border-radius: 20px;
  border: 2px dashed var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-color);
}

.empty-state p {
  margin: 0 0 2rem 0;
  color: var(--text-muted);
  font-size: 1.125rem;
}

/* ===========================================
   Impersonation Banner
   =========================================== */

.impersonation-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  padding: 0.75rem 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.impersonation-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.impersonation-icon {
  font-size: 1.2rem;
}

.impersonation-text {
  font-weight: 500;
  flex-grow: 1;
  text-align: center;
}

.impersonation-stop-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.impersonation-stop-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Adjust app layout when impersonation banner is shown */
body:has(.impersonation-banner) .app-shell {
  padding-top: 60px;
}

/* Print styles */
@media print {
  .query-sidebar,
  .query-actions,
  .page-header {
    display: none;
  }

  .query-builder-layout {
    grid-template-columns: 1fr;
  }

  #sql-textarea {
    border: 2px solid #000;
    background: white;
    color: black;
  }
}
