/* ============================================================
   OPAL SYSTEM ENTERPRISE — Premium Design System v4.0
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================================
   DESIGN TOKENS — Light Mode (Default)
   ============================================================ */
:root {
  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;

  /* Colors — Light */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-glass-strong: rgba(255, 255, 255, 0.88);
  --bg-overlay: rgba(15, 23, 42, 0.6);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-tertiary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #8b5cf6 100%);
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-glow-strong: rgba(99, 102, 241, 0.45);

  --opal-gradient: linear-gradient(135deg, #06b6d4, #6366f1, #a78bfa, #f472b6);
  --opal-glow: 0 0 20px rgba(99, 102, 241, 0.3), 0 0 60px rgba(139, 92, 246, 0.15);

  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  --border-color: #e2e8f0;
  --border-color-light: #f1f5f9;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --shadow-card-hover: 0 8px 30px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  --sidebar-width: 272px;
  --header-height: 64px;
}

/* ============================================================
   DARK MODE
   ============================================================ */
[data-theme="dark"] {
  --bg-primary: #0b0f1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1e293b;
  --bg-card: #151c2c;
  --bg-sidebar: #0f1525;
  --bg-glass: rgba(17, 24, 39, 0.78);
  --bg-glass-strong: rgba(17, 24, 39, 0.92);
  --bg-overlay: rgba(0, 0, 0, 0.7);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --accent-primary: #818cf8;
  --accent-secondary: #a78bfa;
  --accent-tertiary: #22d3ee;
  --accent-gradient: linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #c4b5fd 100%);
  --accent-gradient-hover: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  --accent-glow: rgba(129, 140, 248, 0.3);
  --accent-glow-strong: rgba(129, 140, 248, 0.5);

  --opal-glow: 0 0 20px rgba(129, 140, 248, 0.35), 0 0 60px rgba(167, 139, 250, 0.2);

  --success-bg: rgba(16, 185, 129, 0.12);
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info-bg: rgba(59, 130, 246, 0.12);

  --border-color: #1e293b;
  --border-color-light: #1a2332;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.35);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.15);
  --shadow-card-hover: 0 8px 30px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg-primary: #0b0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1e293b;
    --bg-card: #151c2c;
    --bg-sidebar: #0f1525;
    --bg-glass: rgba(17, 24, 39, 0.78);
    --bg-glass-strong: rgba(17, 24, 39, 0.92);
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;
    --accent-primary: #818cf8;
    --accent-secondary: #a78bfa;
    --accent-tertiary: #22d3ee;
    --accent-gradient: linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #c4b5fd 100%);
    --accent-gradient-hover: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
    --accent-glow: rgba(129, 140, 248, 0.3);
    --accent-glow-strong: rgba(129, 140, 248, 0.5);
    --opal-glow: 0 0 20px rgba(129, 140, 248, 0.35), 0 0 60px rgba(167, 139, 250, 0.2);
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning-bg: rgba(245, 158, 11, 0.12);
    --danger-bg: rgba(239, 68, 68, 0.12);
    --info-bg: rgba(59, 130, 246, 0.12);
    --border-color: #1e293b;
    --border-color-light: #1a2332;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.35);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.15);
    --shadow-card-hover: 0 8px 30px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
  }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes gemFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33% { transform: translateY(-8px) rotate(2deg); }
  66% { transform: translateY(-4px) rotate(-1deg); }
}
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: var(--opal-glow); }
  50% { box-shadow: 0 0 30px var(--accent-glow-strong), 0 0 80px var(--accent-glow); }
}
@keyframes borderGlow {
  0%, 100% { border-color: var(--accent-primary); }
  50% { border-color: var(--accent-secondary); }
}

/* ============================================================
   BASE STYLES
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

::selection {
  background: var(--accent-primary);
  color: white;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  overflow: hidden;
}
.login-overlay.active {
  display: flex;
}

.login-bg-pattern {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
  animation: scaleIn 0.4s var(--transition-spring);
}

.login-card-header {
  padding: 40px 32px 28px;
  text-align: center;
  background: var(--accent-gradient);
  position: relative;
}
.login-card-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 40px;
  background: var(--bg-glass-strong);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
}

.login-gem {
  font-size: 3.5rem;
  display: inline-block;
  animation: gemFloat 3s ease-in-out infinite;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin-top: 12px;
  letter-spacing: -0.025em;
  position: relative;
  z-index: 1;
}

.login-subtitle {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.8);
  margin-top: 6px;
  position: relative;
  z-index: 1;
}

.login-form {
  padding: 32px;
}

.login-version {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  margin-top: 10px;
  position: relative;
  z-index: 1;
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder {
  color: var(--text-muted);
}
.form-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  border-radius: var(--radius-xs);
  cursor: pointer;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 4px 16px var(--accent-glow-strong);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: var(--border-color);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
  background: var(--success);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}
.btn-block {
  width: 100%;
}
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-normal);
  z-index: 200;
  position: relative;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  box-shadow: var(--opal-glow);
  animation: glowPulse 4s ease-in-out infinite;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-name {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.sidebar-menu-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  background: var(--accent-gradient);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  transition: transform var(--transition-fast);
}

.sidebar-menu-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-menu-item.active {
  background: linear-gradient(135deg, var(--accent-glow), rgba(139, 92, 246, 0.08));
  color: var(--accent-primary);
  font-weight: 600;
}
.sidebar-menu-item.active::before {
  transform: translateY(-50%) scaleY(1);
}

.sidebar-menu-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 1.8;
}

.sidebar-menu-item .menu-badge {
  margin-left: auto;
  padding: 1px 7px;
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
}

/* Theme Switcher */
.theme-switcher {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.theme-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
}
.theme-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.theme-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-primary);
}

/* Header */
.main-header {
  height: var(--header-height);
  background: var(--bg-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.25rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-clock {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 500;
}

.header-timer {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}
.status-badge.online {
  background: var(--success-bg);
  color: var(--success);
}
.status-badge.offline {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s ease-in-out infinite;
}

/* Main Body */
.main-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.main-section {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}
.main-section.active {
  opacity: 1;
  visibility: visible;
  animation: fadeInUp 0.3s ease;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-normal);
}
.card:hover {
  box-shadow: var(--shadow-card-hover);
}

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

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   CHAT UI
   ============================================================ */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.chat-welcome-hero {
  text-align: center;
  padding: 48px 24px 32px;
}
.chat-welcome-gem {
  font-size: 4rem;
  display: inline-block;
  animation: gemFloat 3s ease-in-out infinite;
  margin-bottom: 16px;
}
.chat-welcome-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--opal-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.chat-welcome-sub {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-message {
  display: flex;
  gap: 10px;
  max-width: 80%;
  animation: fadeInUp 0.3s ease;
}
.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-message.assistant {
  align-self: flex-start;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
}
.chat-avatar.user-avatar {
  background: var(--accent-primary);
  color: white;
}
.chat-avatar.opal-avatar {
  background: var(--accent-gradient);
  box-shadow: var(--opal-glow);
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.55;
  font-size: 0.9375rem;
}
.chat-message.assistant .chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-xs);
}
.chat-message.user .chat-bubble {
  background: var(--accent-gradient);
  color: white;
  border-bottom-right-radius: var(--radius-xs);
}

.chat-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  animation: fadeIn 0.3s ease;
}
.typing-dots {
  display: flex;
  gap: 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
.typing-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Chat input */
.chat-input-bar {
  padding: 16px 24px 20px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
}

.chat-input-wrapper {
  display: flex;
  gap: 10px;
  max-width: 860px;
  margin: 0 auto;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.9375rem;
  resize: none;
  outline: none;
  min-height: 46px;
  max-height: 120px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.chat-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-send-btn {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--accent-gradient);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.chat-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow-strong);
}
.chat-send-btn:active {
  transform: scale(0.95);
}
.chat-send-btn svg {
  width: 20px;
  height: 20px;
}

.context-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.06));
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 0.8125rem;
  color: var(--accent-primary);
}
.context-banner strong {
  font-weight: 700;
}

/* ============================================================
   AGENT CARD
   ============================================================ */
.agent-card {
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.agent-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}
.agent-card:hover::before {
  opacity: 0.03;
}

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.agent-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}
.agent-icon.opal {
  animation: glowPulse 4s ease-in-out infinite;
}

.agent-info h3 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.agent-model {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.agent-badge {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.agent-badge.leader { background: var(--warning-bg); color: var(--warning); }
.agent-badge.secretary { background: var(--info-bg); color: var(--info); }
.agent-badge.participant { background: var(--success-bg); color: var(--success); }

.agent-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 14px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.agent-detail-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

/* ============================================================
   MODEL CARD
   ============================================================ */
.model-card {
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
}
.model-card:hover {
  transform: translateY(-2px);
}
.model-card.selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow), var(--shadow-card-hover);
}

.model-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.model-icon {
  font-size: 2rem;
}
.model-percent {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-primary);
  letter-spacing: -0.03em;
}
.model-name {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 6px;
}
.model-id {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
  word-break: break-all;
}

.progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 12px;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

/* ============================================================
   MEETING ROOM
   ============================================================ */
.meeting-room-card {
  background: var(--accent-gradient);
  padding: 24px;
  border-radius: var(--radius-xl);
  color: white;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.meeting-room-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 100% 0%, rgba(255,255,255,0.1) 0%, transparent 60%);
  pointer-events: none;
}

.meeting-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  position: relative;
}
.meeting-title h3 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.meeting-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
}

.meeting-info {
  font-size: 0.875rem;
  opacity: 0.9;
  line-height: 1.8;
  position: relative;
}

.meeting-chat {
  margin-top: 20px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
}
.meeting-chat h4 {
  margin-bottom: 12px;
  font-weight: 600;
}
.meeting-messages {
  min-height: 120px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.meeting-message {
  padding: 10px 14px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
.meeting-message .speaker {
  font-weight: 700;
  font-size: 0.8125rem;
  margin-bottom: 3px;
}
.meeting-message .text {
  opacity: 0.92;
  font-size: 0.875rem;
}

.meeting-empty {
  text-align: center;
  padding: 60px 24px;
  background: var(--bg-card);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-xl);
}
.meeting-empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

/* ============================================================
   LOGS TABLE
   ============================================================ */
.logs-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.logs-table th {
  padding: 12px 16px;
  text-align: left;
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
.logs-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color-light);
}
.logs-table tr:hover td {
  background: var(--bg-tertiary);
}
.logs-table tr:last-child td {
  border-bottom: none;
}

.log-level {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.log-level.debug { background: var(--bg-tertiary); color: var(--text-muted); }
.log-level.info { background: var(--info-bg); color: var(--info); }
.log-level.warn { background: var(--warning-bg); color: var(--warning); }
.log-level.error { background: var(--danger-bg); color: var(--danger); }

/* ============================================================
   TERMINAL
   ============================================================ */
.terminal {
  background: #0d1117;
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  box-shadow: var(--shadow-xl);
  border: 1px solid #21262d;
}

.terminal-header {
  padding: 10px 16px;
  background: linear-gradient(180deg, #161b22, #0d1117);
  border-bottom: 1px solid #21262d;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.terminal-dots {
  display: flex;
  gap: 8px;
}
.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transition: opacity var(--transition-fast);
}
.terminal-dot:hover { opacity: 0.8; }
.terminal-dot.red { background: #ff5f56; }
.terminal-dot.yellow { background: #ffbd2e; }
.terminal-dot.green { background: #27c93f; }

.terminal-title {
  color: #8b949e;
  font-size: 0.75rem;
}

.terminal-output {
  padding: 16px;
  min-height: 360px;
  max-height: 480px;
  overflow-y: auto;
  color: #e6edf3;
  line-height: 1.6;
}
.terminal-output .command { color: #7ee787; font-weight: 600; margin-top: 14px; }
.terminal-output .output { color: #e6edf3; margin: 2px 0; }
.terminal-output .error { color: #ff7b72; }
.terminal-output .success { color: #7ee787; }
.terminal-output .info { color: #79c0ff; }
.terminal-output .warning { color: #d29922; }

.terminal-input-line {
  padding: 10px 16px;
  border-top: 1px solid #21262d;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0d1117;
}
.terminal-prompt {
  color: #7ee787;
  font-weight: 700;
  white-space: nowrap;
}
.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #e6edf3;
  font-family: inherit;
  font-size: inherit;
  outline: none;
}
.terminal-input::placeholder {
  color: #484f58;
}

.terminal-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-2xl);
  animation: scaleIn 0.25s ease;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-tertiary);
  cursor: pointer;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.modal-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-glass-strong);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideInRight 0.3s ease;
  min-width: 280px;
  max-width: 420px;
}
.toast.toast-leaving {
  animation: slideOutRight 0.3s ease forwards;
}
.toast-icon { font-size: 1.125rem; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

/* ============================================================
   LOADING & SKELETON
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ============================================================
   MOBILE OVERLAY
   ============================================================ */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  z-index: 150;
}
.mobile-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    box-shadow: var(--shadow-2xl);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex !important;
  }

  .main-section {
    padding: 16px;
  }
  .main-header {
    padding: 0 16px;
  }

  .page-title { font-size: 1.1rem; }
  .card-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .chat-message { max-width: 90%; }
  .header-clock, .header-timer { display: none; }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-content {
    max-width: 100%;
    border-radius: var(--radius-lg);
    max-height: 90vh;
  }
}

/* ============================================================
   RESPONSIVE — Tablet
   ============================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --sidebar-width: 240px;
  }
}

/* ============================================================
   TOUCH DEVICE
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  .card:hover { box-shadow: var(--shadow-card); }
  .model-card:hover { transform: none; }
  .btn:active { transform: scale(0.97); }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   HIGH CONTRAST
   ============================================================ */
@media (prefers-contrast: high) {
  :root {
    --border-color: currentColor;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }
  .card { border-width: 2px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ============================================================
   MEETING ROOM FIXES
   ============================================================ */
#meeting-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.meeting-room-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - 220px);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.meeting-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  margin-top: 12px;
}

.meeting-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 8px;
}
