:root {
  /* --- Theme Variables --- */
  --bg-body: #09090b;       /* Very Dark Zinc */
  --bg-sidebar: #121214;    /* Dark Panel */
  --bg-card: #18181b;       /* Panel */
  --bg-input: #27272a;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-sub: #71717a;
  
  --primary: #6366f1;       /* Indigo */
  --primary-hover: #4f46e5;
  --danger: #ef4444;
  --success: #10b981;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font-sans: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* --- Base Styles --- */
body {
  background-color: var(--bg-body);
  /* Subtle Grid Background */
  background-image: linear-gradient(var(--border-subtle) 1px, transparent 1px),
  linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center top;
  color: var(--text-muted);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  font-size: 0.88rem;
}

h1, h2, h3, h4, h5, h6 { color: var(--text-main); font-weight: 600; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* --- Layout --- */
.wrapper { display: flex; height: 100%; width: 100%; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: rgba(18, 18, 20, 0.95);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; padding: 1.5rem 1rem;
  z-index: 50; flex-shrink: 0;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 0.5rem 1.5rem 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}
.brand-logo { height: 32px; width: auto; }
.brand-text { font-size: 1rem; font-weight: 600; color: var(--text-main); letter-spacing: -0.02em; }

.nav-label {
  font-size: 0.7rem; font-weight: 600; color: var(--text-sub);
  text-transform: uppercase; letter-spacing: 0.05em; margin: 1rem 0.75rem 0.5rem;
}

.nav-item {
  padding: 10px 12px; margin-bottom: 4px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-muted); font-weight: 500;
  display: flex; align-items: center; gap: 12px; transition: all 0.2s;
  font-size: 0.9rem;
}
.nav-item:hover { background-color: rgba(255, 255, 255, 0.03); color: var(--text-main); }
.nav-item.active {
  background-color: rgba(99, 102, 241, 0.1);
  color: #818cf8;
}
.nav-item i { font-size: 1.1rem; }

/* Main Content */
.main-content { 
    flex: 1; 
    padding: 0; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    position: relative; 
}

/* --- Header & Controls --- */
.top-bar {
    height: 70px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(8px);
}
.page-title { font-size: 1.25rem; margin: 0; letter-spacing: -0.02em; }

.search-group { position: relative; width: 300px; }
.search-input {
  width: 100%; padding: 8px 12px 8px 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input); color: var(--text-main); font-size: 0.85rem;
  transition: all 0.2s;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-sub); font-size: 0.9rem; }

.btn-action {
  background: var(--primary); color: #ffffff; border: none;
  padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 500; font-size: 0.85rem;
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px;
}
.btn-action:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-action:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

/* --- Content Area --- */
.content-area {
    flex: 1; padding: 1.5rem 2rem; overflow: hidden; display: flex; flex-direction: column;
}

.content-panel {
  background: var(--bg-card); border-radius: var(--radius-md); 
  border: 1px solid var(--border-subtle);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* --- Table Styles --- */
.table-wrapper { overflow: auto; flex: 1; }
.modern-table { width: 100%; border-collapse: collapse; }
.modern-table th { 
  background: var(--bg-card);
  color: var(--text-sub); font-weight: 600; font-size: 0.75rem; 
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 16px 24px; text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 10;
}
.modern-table td { 
    padding: 14px 24px; 
    border-bottom: 1px solid var(--border-subtle); 
    color: var(--text-main); vertical-align: middle; 
    transition: background 0.1s;
}
.modern-table tr:hover td { background-color: rgba(255,255,255,0.02); }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid transparent; 
  background: transparent; color: var(--text-sub);
  display: inline-flex; align-items: center; justify-content: center; transition: 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-main); border-color: var(--border-subtle); }
.icon-btn.text-danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); border-color: rgba(239, 68, 68, 0.2); }

/* --- Script Editor Styles --- */
.script-container { display: flex; flex-direction: column; height: 100%; gap: 16px; }
.editors-row { display: flex; gap: 16px; flex: 1; min-height: 0; }

.code-window { 
    flex: 1; background: #0d0d0f; border-radius: var(--radius-md); 
    overflow: hidden; display: flex; flex-direction: column; 
    border: 1px solid var(--border-subtle); 
}
.window-header { 
    background: #18181b; padding: 8px 16px; 
    display: flex; justify-content: space-between; align-items: center; 
    border-bottom: 1px solid var(--border-subtle); height: 40px;
}
.window-title-badge { 
    font-family: var(--font-mono); font-size: 0.75rem; 
    color: var(--text-sub); display: flex; align-items: center; gap: 8px;
}
.monaco-host { flex: 1; }

.script-toolbar { 
    background: var(--bg-card); border: 1px solid var(--border-subtle); 
    padding: 12px 20px; border-radius: var(--radius-md); 
    display: flex; justify-content: space-between; align-items: center;
}
.ver-pill { 
    background: var(--bg-input); color: var(--text-main); border: 1px solid var(--border-subtle); 
    padding: 6px 12px; border-radius: var(--radius-sm); text-align: center; 
    font-family: var(--font-mono); width: 80px; font-size: 0.85rem; outline: none; 
}
.ver-pill:focus { border-color: var(--primary); }

/* --- Modal & Forms --- */
.modal-content { 
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); border-radius: var(--radius-md);
}
.modal-header { border-bottom: 1px solid var(--border-subtle); padding: 1.25rem 1.5rem; }
.modal-footer { border-top: 1px solid var(--border-subtle); padding: 1rem 1.5rem; }
.modal-title { font-size: 1.1rem; }
.btn-close { filter: invert(1); opacity: 0.5; }

.form-label { color: var(--text-sub); font-weight: 500; font-size: 0.75rem; margin-bottom: 0.4rem; }
.form-control-modern {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-subtle) !important; 
    color: var(--text-main) !important;
    border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.9rem;
}
.form-control-modern:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15) !important; }

/* Avatar Preview */
.avatar-preview-container {
    width: 60px; height: 60px; flex-shrink: 0;
    border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);
    background: #000; overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.avatar-preview-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder { font-size: 1.2rem; color: var(--text-sub); opacity: 0.3; }

/* Color Picker */
.color-picker-wrapper { display: flex; align-items: center; gap: 8px; padding: 4px; }
.color-input { width: 32px; height: 32px; border: none; background: none; cursor: pointer; border-radius: 4px; }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out; }
.status-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* Overrides for dynamic JS content */
.text-danger { color: var(--danger) !important; }