/* AIM Dashboard Design System & Styling Rules */

:root {
  --bg-primary: #080c16;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --accent-color: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.25);

  --success-color: #10b981;
  --success-glow: rgba(16, 185, 129, 0.2);
  --error-color: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.2);

  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --border-color: #1f2937;
  --border-active: #3b82f6;

  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Utilities */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Form Styles & Controls */
input,
textarea,
select {
  font-family: inherit;
  color: inherit;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

select option {
  background-color: #111827;
  color: #f3f4f6;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background-color: rgba(255, 255, 255, 0.08);
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border: none;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--text-secondary);
}

/* Authentication Layout */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(5, 8, 15, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  z-index: 1000;
  padding: 3rem 1.5rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  padding: 2.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  animation: modalEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.logo-orb {
  width: 48px;
  height: 48px;
  background: radial-gradient(circle, var(--accent-color) 0%, #1d4ed8 100%);
  border-radius: 50%;
  margin: 0 auto 1rem;
  box-shadow: 0 0 20px var(--accent-color);
  position: relative;
}

.logo-orb::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border: 1px solid var(--accent-color);
  border-radius: 50%;
  opacity: 0.3;
  animation: orbPulse 2s infinite ease-out;
}

@keyframes orbPulse {
  0% {
    transform: scale(1);
    opacity: 0.4;
  }

  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

.login-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff 40%, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.error-msg {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--error-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  text-align: center;
  font-weight: 500;
}

/* Quick Select Section */
.quick-select-section {
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.quick-select-section .section-title {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  text-align: center;
}

.profiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn-quick-select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
}

.btn-quick-select:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--accent-color);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.15);
}

.btn-quick-select strong {
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}

.btn-quick-select span {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Dashboard Header & Badges */
header {
  background: rgba(17, 24, 39, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-indicator {
  width: 8px;
  height: 8px;
  background-color: var(--success-color);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--success-color);
  animation: blink 2.5s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

h1 {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff 40%, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: right;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.context-badges {
  display: flex;
  gap: 0.4rem;
}

.badge {
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-zone {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-level {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Panels */
main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.panel-header {
  margin-bottom: 1.25rem;
}

.panel-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: #fff;
}

.panel-header p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Control Panel Filters */
.filters-row {
  display: flex;
  gap: 1.5rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.filter-group select {
  cursor: pointer;
  font-weight: 500;
  width: 100%;
}

.filter-group select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Metrics Section */
.section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.metrics-grid {
  display: flex;
  gap: 1.5rem;
  align-items: stretch;
}

.attendance-classification-column {
  flex: 1.3;
  display: flex;
  flex-direction: column;
}

.metric-tiles-column {
  flex: 1.7;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

@media (max-width: 1024px) {
  .metrics-grid {
    flex-direction: column;
  }

  .attendance-classification-column,
  .metric-tiles-column {
    flex: none;
    width: 100%;
  }
}

@media (max-width: 580px) {
  .metric-tiles-column {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.metric-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-2px);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.metric-scope {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-color);
  letter-spacing: 0.02em;
}

.metric-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-color);
}

.metric-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.metric-body {
  display: flex;
  align-items: baseline;
  margin-top: auto;
}

.metric-value {
  font-size: 2.25rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.metric-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 0.25rem;
}

.empty-metrics {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  color: var(--text-secondary);
}

/* Query Engine Interface */
.query-interface {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1.5rem;
  min-height: 280px;
}

.editor-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.editor-area textarea {
  width: 100%;
  height: 100%;
  min-height: 160px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  background-color: #060911;
  padding: 1rem;
  resize: vertical;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.sql-cheat-sheet {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.sql-cheat-sheet code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  color: #ff79c6;
  margin-left: 0.25rem;
}

/* Results Area */
.query-results-area {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: #060911;
  overflow: hidden;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background-color: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
}

.results-header h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.result-count {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-color);
}

.table-wrapper {
  flex: 1;
  overflow: auto;
  max-height: 220px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  text-align: left;
}

th {
  background-color: rgba(255, 255, 255, 0.01);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.03);
}

.error-cell {
  color: var(--error-color);
  background-color: rgba(239, 68, 68, 0.05);
  padding: 1rem;
  line-height: 1.5;
}

/* Diagnostics Area */
.debug-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.debug-card h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.console-box {
  background-color: #05080e;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  height: 150px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.console-row {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  padding-bottom: 0.15rem;
}

.c-time {
  color: var(--text-secondary);
}

.c-action {
  font-weight: 600;
  padding: 0 0.25rem;
  border-radius: 4px;
  min-width: 60px;
  text-align: center;
}

.action-normal {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.action-http {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.action-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.action-error {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.c-detail {
  color: #cbd5e1;
}

.c-inactive {
  color: var(--text-secondary);
  margin: auto;
  font-style: italic;
}

/* JWT Inspector Styles */
.jwt-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 150px;
}

.jwt-part {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
  padding-bottom: 0.3rem;
  overflow-x: auto;
  white-space: nowrap;
}

.jwt-lbl {
  color: #ff79c6;
  font-weight: 600;
  margin-right: 0.25rem;
}

.jwt-val {
  color: #50fa7b;
}

.jwt-tok {
  color: #8be9fd;
  word-break: break-all;
  white-space: normal;
  display: inline-block;
}

/* Footer */
footer {
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: auto;
}

/* Responsive Rules */
@media (max-width: 992px) {
  .query-interface {
    grid-template-columns: 1fr;
  }

  .debug-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }

  .user-profile-badge {
    width: 100%;
    justify-content: space-between;
  }

  .profiles-grid {
    grid-template-columns: 1fr;
  }

  .filters-row {
    .filters-row {
      flex-direction: column;
      gap: 1rem;
    }
  }

  /* Premium Drill Down Modal Custom Styling */
  .drilldown-card {
    max-width: 1100px !important;
    width: 95% !important;
    display: flex;
    flex-direction: column;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 16px;
    padding: 2rem !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(16px);
    margin-bottom: 2rem;
  }

  .drilldown-content-layout {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.5rem;
  }

  .drilldown-table-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .drilldown-student-panel {
    flex: 1.3;
    background: rgba(255, 255, 255, 0.02);
    border-left: 1px solid var(--border-color);
    padding-left: 1.5rem;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes slideIn {
    from {
      opacity: 0;
      transform: translateX(30px);
    }

    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  .panel-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
  }

  .panel-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
  }

  .panel-header-inline h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
  }

  .btn-sm {
    padding: 0.35rem 0.75rem !important;
    font-size: 0.75rem !important;
    border-radius: 6px !important;
  }

  /* Tables Layout inside Drilldown */
  .table-container {
    overflow-y: auto;
    max-height: 480px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.25);
  }

  .table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  .table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
  }

  .table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
  }

  th,
  td {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border-color);
  }

  th {
    background-color: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .interactive-table tbody tr {
    cursor: pointer;
    transition: var(--transition-smooth);
  }

  .interactive-table tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.12);
    transform: translateX(2px);
  }

  .interactive-table tbody tr.active-row {
    background-color: rgba(59, 130, 246, 0.2) !important;
    border-left: 3px solid var(--accent-color);
  }

  .btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-smooth);
  }

  .btn-close:hover {
    color: var(--text-primary);
    transform: scale(1.15) rotate(90deg);
  }

  .empty-table-msg {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
  }

  /* Adjust class card hover cursor */
  .metric-card {
    cursor: pointer;
    transition: var(--transition-smooth);
  }

  .metric-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
  }

  /* Attendance Donut Chart Widget Styling */
  .attendance-pie-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    gap: 2rem;
    padding: 1.75rem !important;
    cursor: default !important;
    /* Overrule card cursor since it's not a drilldown trigger */
    width: 100%;
    height: 100%;
  }

  .attendance-pie-card:hover {
    transform: none !important;
    box-shadow: none !important;
    border-color: var(--border-color) !important;
  }

  @media (max-width: 768px) {
    .attendance-pie-card {
      flex-direction: column;
      gap: 1.5rem;
    }
  }

  .pie-chart-container {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
  }

  .donut-chart {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    /* Start at 12 o'clock */
  }

  .donut-chart circle {
    transition: stroke-dasharray 0.3s ease, stroke-dashoffset 0.3s ease;
  }

  .pie-chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .pie-center-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
  }

  .pie-center-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.2rem;
  }

  .pie-chart-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
  }

  .pie-chart-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.25rem;
  }

  .threshold-slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
  }

  .slider-control {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  .slider-control label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
  }

  .slider-val {
    color: var(--accent-color);
    font-weight: 700;
  }

  .slider-control input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: #1f2937;
    outline: none;
    padding: 0;
    border: none;
    cursor: pointer;
  }

  .slider-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 0 8px var(--accent-color);
    transition: transform 0.1s ease;
  }

  .slider-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
  }

  .pie-legend {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .pie-legend li {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
  }

  .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.6rem;
    flex-shrink: 0;
  }

  .legend-label {
    flex: 1;
    font-weight: 500;
  }

  .legend-pct {
    color: var(--text-secondary);
    margin-left: 0.4rem;
    font-size: 0.8rem;
  }

  /* --- Admin Suite & In-Place Query Editor Styles --- */

  .btn-card-edit-query {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #a5b4fc;
    border-radius: 6px;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
  }

  .btn-card-edit-query:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.7);
    color: #fff;
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  }

  .btn-card-edit-query:active {
    transform: translateY(0) scale(0.95);
  }

  .cte-explainer-details summary::-webkit-details-marker {
    display: none;
  }

  .cte-explainer-details summary {
    list-style: none;
  }

  .cte-explainer-details[open] summary {
    margin-bottom: 0.6rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    padding-bottom: 0.4rem;
  }

  .admin-modal-card {
    border: 1px solid rgba(99, 102, 241, 0.25);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7), 0 0 30px rgba(99, 102, 241, 0.15);
  }

  .query-editor-card {
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.8), 0 0 35px rgba(99, 102, 241, 0.2);
  }

  #editor-sql-input:focus,
  #input-user-email:focus,
  #select-user-role:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
  }

  /* ========================================================
   --- CUSTOM MULTI-SELECT DROPDOWN COMPONENT STYLES ---
   ======================================================== */

  .custom-multiselect {
    position: relative;
    width: 100%;
  }

  .multiselect-trigger {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.5rem;
    user-select: none;
  }

  .multiselect-trigger:hover {
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(0, 0, 0, 0.45);
  }

  .multiselect-trigger:focus,
  .multiselect-trigger.active {
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
    background: rgba(0, 0, 0, 0.5);
  }

  .multiselect-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex: 1;
    max-height: 85px;
    overflow-y: auto;
    align-items: center;
  }

  .multiselect-placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: normal;
  }

  .multiselect-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 5px;
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
    border: 1px solid rgba(99, 102, 241, 0.4);
    animation: fadeIn 0.15s ease-in-out;
  }

  .multiselect-tag.universal {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.4);
  }

  .multiselect-tag-remove {
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    opacity: 0.7;
    transition: all 0.15s ease;
    margin-left: 0.15rem;
  }

  .multiselect-tag-remove:hover {
    opacity: 1;
    color: #f87171;
    transform: scale(1.2);
  }

  .multiselect-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s ease, color 0.2s ease;
    margin-left: auto;
    flex-shrink: 0;
  }

  .multiselect-trigger.active .multiselect-arrow {
    transform: rotate(180deg);
    color: var(--accent-color);
  }

  .multiselect-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.85), 0 0 20px rgba(99, 102, 241, 0.15);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(16px);
    animation: fadeIn 0.15s ease-in-out;
  }

  .multiselect-menu.hidden {
    display: none !important;
  }

  .multiselect-search-box {
    padding: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .multiselect-search-input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    color: #fff;
    outline: none;
  }

  .multiselect-search-input:focus {
    border-color: var(--accent-color);
  }

  .multiselect-actions {
    display: flex;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    justify-content: flex-end;
  }

  .btn-quick {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    font-size: 0.75rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .btn-quick:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.5);
    color: #fff;
  }

  .multiselect-options {
    max-height: 190px;
    overflow-y: auto;
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .multiselect-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #cbd5e1;
    user-select: none;
    transition: background 0.15s ease;
  }

  .multiselect-option:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #fff;
  }

  .multiselect-option.selected {
    background: rgba(99, 102, 241, 0.2);
    color: #e0e7ff;
    font-weight: 500;
  }

  .multiselect-option.universal-option {
    color: #34d399;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.2rem;
    padding-bottom: 0.5rem;
  }

  .multiselect-option input[type="checkbox"] {
    accent-color: var(--accent-color);
    width: 15px;
    height: 15px;
    cursor: pointer;
  }
}

/* Pending C-Forms Status Badges */
.badge-status-critical {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-status-overdue {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-status-pending {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}