/* ═══════════════════════════════════════════════════════════
   BPharma Admin — Premium Design System
   ═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand — matches Flutter AppTheme */
  --primary: #3F51B5;
  --primary-light: #5C6BC0;
  --primary-dark: #283593;
  --indigo-400: #5C6BC0;
  --indigo-500: #3F51B5;
  --indigo-600: #283593;
  --teal-400: #00BFA5;
  --teal-500: #00BFA5;

  /* Light surfaces */
  --bg-base: #F4F6FC;
  --bg-elevated: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-input: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --border: #E8ECF4;
  --border-hover: #D1D9E6;
  --border-focus: rgba(63, 81, 181, 0.45);

  /* Text */
  --text-primary: #1E293B;
  --text-secondary: #475569;
  --text-muted: #94A3B8;

  /* Semantic */
  --success: #059669;
  --danger: #DC2626;
  --warning: #D97706;

  /* Layout */
  --sidebar-w: 272px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 72px;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  /* Effects */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --glow-indigo: 0 4px 24px rgba(63, 81, 181, 0.12);
  --glow-teal: 0 4px 24px rgba(0, 191, 165, 0.1);
  --gradient-brand: linear-gradient(135deg, #3F51B5 0%, #00BFA5 100%);
  --gradient-text: linear-gradient(135deg, #3F51B5 0%, #00BFA5 100%);

  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* Lucide icons */
[data-lucide] {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

/* ═══════════════ LOGIN ═══════════════ */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: linear-gradient(145deg, #EEF2FF 0%, #ECFDF5 50%, #F8FAFC 100%);
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.login-brand-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(63, 81, 181, 0.12) 0%, transparent 70%);
  top: 20%;
  left: 10%;
  pointer-events: none;
  animation: pulse-glow 8s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

.login-brand-inner {
  position: relative;
  z-index: 1;
  max-width: 400px;
}

.brand-logo svg { width: 56px; height: 56px; margin-bottom: 28px; }

.login-brand h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.brand-tagline {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 36px;
}

.brand-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.brand-features [data-lucide] {
  width: 20px;
  height: 20px;
  color: var(--teal-400);
}

.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

.login-card-header {
  margin-bottom: 32px;
}

.login-card-header h2 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.login-card-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.login-hint {
  margin-top: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.login-hint code {
  background: #EEF2FF;
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.login-error {
  margin-top: 16px;
  padding: 12px 14px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
}

.login-error:empty { display: none; }

/* ═══════════════ APP SHELL ═══════════════ */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  z-index: 0;
}

.ambient-1 {
  width: 600px;
  height: 600px;
  background: rgba(63, 81, 181, 0.06);
  top: -200px;
  right: -100px;
}

.ambient-2 {
  width: 400px;
  height: 400px;
  background: rgba(0, 191, 165, 0.05);
  bottom: -100px;
  left: 200px;
}

/* ═══════════════ SIDEBAR ═══════════════ */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar-header {
  padding: 20px 14px 16px;
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-collapse-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.sidebar-collapse-btn:hover {
  background: #EEF2FF;
  color: var(--primary);
  border-color: #C7D2FE;
}

.sidebar-collapse-btn [data-lucide] {
  width: 18px;
  height: 18px;
}

.sidebar.collapsed .sidebar-collapse-btn [data-lucide] {
  transform: rotate(180deg);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  flex: 1;
}

.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  flex: 0;
}

.logo-mark svg { width: 36px; height: 36px; display: block; }

.logo-text { display: flex; flex-direction: column; }

.logo-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.logo-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

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

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.nav-item.active {
  color: var(--primary-dark);
  background: #EEF2FF;
  border-color: #C7D2FE;
  font-weight: 600;
}

.nav-item.active span:not(.nav-pill) {
  color: var(--primary-dark);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--gradient-brand);
  border-radius: 0 4px 4px 0;
}

.nav-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  transition: background 0.2s;
}

.nav-item.active .nav-icon-wrap {
  background: #C7D2FE;
  color: var(--primary);
}

.nav-icon-wrap [data-lucide] { width: 16px; height: 16px; }

.nav-icon-wrap.featured {
  background: #CCFBF1;
}

.nav-icon-wrap.featured [data-lucide] { color: var(--teal-500); }

.nav-featured { margin-bottom: 4px; }

.nav-pill {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 99px;
  background: var(--gradient-brand);
  color: white;
  letter-spacing: 0.04em;
}

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

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.sidebar.collapsed .user-card {
  flex-direction: column;
  justify-content: center;
  padding: 10px;
  gap: 8px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sign-out {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
  transition: color 0.15s;
}

.sign-out:hover { color: var(--danger); }
.sign-out [data-lucide] { width: 12px; height: 12px; }

/* Collapsed sidebar: icon-only */
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-pill,
.sidebar.collapsed .user-name,
.sidebar.collapsed .sign-out-label {
  display: none;
}

.sidebar.collapsed .user-card-info {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar.collapsed .sign-out {
  padding: 8px;
  border-radius: 8px;
}

.sidebar.collapsed .sign-out:hover {
  background: #FEE2E2;
}

.sidebar.collapsed .sidebar-header-row {
  flex-direction: column;
  gap: 12px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .nav-item.active::before {
  width: 3px;
  height: 24px;
}

.sidebar.collapsed .sidebar-nav {
  padding: 8px 10px 16px;
}

.sidebar.collapsed .nav-icon-wrap {
  margin: 0;
}

/* ═══════════════ MAIN ═══════════════ */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-shell.sidebar-collapsed .main {
  margin-left: var(--sidebar-w-collapsed);
}

.topbar {
  height: var(--topbar-h);
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-content {
  flex: 1;
  padding: 28px 36px 48px;
}

.page {
  display: none;
  animation: page-in 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.page.active { display: block; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════ STATS ═══════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  position: relative;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.stat-card[data-accent="indigo"] .stat-card-glow { background: radial-gradient(circle at 30% 50%, rgba(63,81,181,0.08), transparent 70%); }
.stat-card[data-accent="teal"] .stat-card-glow { background: radial-gradient(circle at 30% 50%, rgba(0,191,165,0.08), transparent 70%); }
.stat-card[data-accent="amber"] .stat-card-glow { background: radial-gradient(circle at 30% 50%, rgba(245,158,11,0.08), transparent 70%); }
.stat-card[data-accent="violet"] .stat-card-glow { background: radial-gradient(circle at 30% 50%, rgba(124,58,237,0.08), transparent 70%); }
.stat-card[data-accent="blue"] .stat-card-glow { background: radial-gradient(circle at 30% 50%, rgba(37,99,235,0.08), transparent 70%); }
.stat-card[data-accent="emerald"] .stat-card-glow { background: radial-gradient(circle at 30% 50%, rgba(5,150,105,0.08), transparent 70%); }
.stat-card[data-accent="rose"] .stat-card-glow { background: radial-gradient(circle at 30% 50%, rgba(225,29,72,0.08), transparent 70%); }
.stat-card[data-accent="lime"] .stat-card-glow { background: radial-gradient(circle at 30% 50%, rgba(101,163,13,0.08), transparent 70%); }

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover .stat-card-glow { opacity: 1; }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card[data-accent="indigo"] .stat-icon { background: #EEF2FF; color: var(--primary); }
.stat-card[data-accent="teal"] .stat-icon { background: #CCFBF1; color: #0D9488; }
.stat-card[data-accent="amber"] .stat-icon { background: #FEF3C7; color: #B45309; }
.stat-card[data-accent="violet"] .stat-icon { background: #EDE9FE; color: #7C3AED; }
.stat-card[data-accent="blue"] .stat-icon { background: #DBEAFE; color: #2563EB; }
.stat-card[data-accent="emerald"] .stat-icon { background: #D1FAE5; color: #059669; }
.stat-card[data-accent="rose"] .stat-icon { background: #FFE4E6; color: #E11D48; }
.stat-card[data-accent="lime"] .stat-icon { background: #ECFCCB; color: #65A30D; }

.stat-icon [data-lucide] { width: 22px; height: 22px; }

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ═══════════════ SECTIONS & ACTIONS ═══════════════ */
.section-header {
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  text-align: left;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.action-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.action-card.featured {
  border-color: #C7D2FE;
  background: linear-gradient(135deg, #EEF2FF 0%, #ECFDF5 100%);
}

.action-card.featured:hover {
  border-color: var(--primary-light);
  box-shadow: var(--glow-indigo);
}

.action-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #EEF2FF;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.action-card.featured .action-icon {
  background: var(--gradient-brand);
  color: white;
}

.action-text { flex: 1; min-width: 0; }

.action-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.action-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.action-arrow {
  color: var(--text-muted);
  width: 18px !important;
  height: 18px !important;
  transition: transform 0.2s;
}

.action-card:hover .action-arrow {
  transform: translateX(4px);
  color: var(--text-secondary);
}

/* ═══════════════ PANELS ═══════════════ */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel.padded { padding: 24px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head.compact { padding: 16px 18px; }

.panel-head h3 {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head h3 [data-lucide] {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ═══════════════ FEED / LIST ═══════════════ */
.feed { padding: 4px 0; }

.feed .list-item,
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.feed .list-item:last-child,
.list-item:last-child { border-bottom: none; }

.feed .list-item:hover,
.list-item:hover { background: var(--bg-subtle); }

.list-avatar, .avatar.sm {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.list-main { flex: 1; min-width: 0; }

.list-name {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.list-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ═══════════════ CONTENT STUDIO ═══════════════ */
.studio-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}

.studio-filters {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.studio-chips {
  padding: 0 18px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.studio-chips .chip,
.unit-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #EEF2FF;
  border: 1px solid #C7D2FE;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
}

.studio-placeholder {
  padding: 80px 40px;
  text-align: center;
}

.placeholder-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  border-radius: 20px;
  background: linear-gradient(135deg, #EEF2FF, #ECFDF5);
  border: 1px solid #C7D2FE;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-icon [data-lucide] {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.studio-placeholder h3 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.studio-placeholder p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.6;
}

.unit-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  margin-bottom: 16px;
}

.unit-hero h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 8px;
}

.studio-breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bc-sep { opacity: 0.35; }

.unit-overview {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.5;
}

.tab-bar {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
  background: var(--bg-elevated);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab [data-lucide] { width: 16px; height: 16px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: page-in 0.25s ease; }

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 520px;
}

.editor-box {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.editor-toolbar span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-area {
  flex: 1;
  min-height: 460px;
  padding: 20px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.7;
  resize: none;
  outline: none;
}

.preview-area {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  max-height: 520px;
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

.preview-area h1, .preview-area h2, .preview-area h3 {
  color: var(--text-primary);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 1.2em 0 0.5em;
}

.preview-area h1 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.35em; }
.preview-area h2 { font-size: 1.2em; color: var(--primary); }
.preview-area h3 { font-size: 1.05em; }
.preview-area strong { color: var(--text-primary); }
.preview-area ul, .preview-area ol { padding-left: 1.4em; margin: 0.6em 0; }
.preview-area li { margin: 0.25em 0; }
.preview-area hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.preview-area code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: #EEF2FF;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--primary);
}

.video-frame {
  margin: 20px 0 24px;
  aspect-ratio: 16/9;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-frame iframe { width: 100%; height: 100%; border: none; }

.video-fallback {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 32px;
  text-align: center;
}

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

/* Item lists in studio */
.item-list { padding: 8px 0; }

.flashcard-item, .quiz-item {
  display: flex;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.flashcard-item:last-child, .quiz-item:last-child { border-bottom: none; }

.fc-num, .quiz-num {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #CCFBF1;
  color: var(--teal-500);
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fc-content, .quiz-content { flex: 1; min-width: 0; }

.fc-front, .fc-back, .quiz-q {
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 4px;
}

.fc-back { color: var(--text-muted); }

.quiz-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.quiz-opt {
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.quiz-opt.correct {
  background: #D1FAE5;
  border-color: #6EE7B7;
  color: var(--success);
  font-weight: 600;
}

.quiz-expl {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}

/* ═══════════════ TABLES ═══════════════ */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover { background: #F8FAFC; }
tbody tr:last-child td { border-bottom: none; }

.td-mono {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.td-truncate {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-truncate.wide { max-width: 400px; }

.td-sub { color: var(--text-muted); font-size: 0.8rem; }

.td-actions {
  display: flex;
  gap: 6px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ═══════════════ BADGES ═══════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-blue   { background: #EEF2FF; color: #4338CA; }
.badge-green  { background: #D1FAE5; color: #047857; }
.badge-orange { background: #FFEDD5; color: #C2410C; }
.badge-purple { background: #EDE9FE; color: #6D28D9; }
.badge-gray   { background: #F1F5F9; color: #475569; }

/* ═══════════════ BUTTONS ═══════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
}

.btn [data-lucide] { width: 16px; height: 16px; }

.btn-primary {
  background: var(--gradient-brand);
  color: white;
  box-shadow: 0 4px 14px rgba(63, 81, 181, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(63, 81, 181, 0.3);
}

.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: linear-gradient(135deg, #EF4444, #F87171);
  color: white;
}

.btn-danger:hover { box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 24px; font-size: 0.95rem; }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.icon-btn.danger:hover {
  background: #FEE2E2;
  color: var(--danger);
  border-color: #FECACA;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
}

.btn-icon:hover {
  background: #E2E8F0;
  color: var(--text-primary);
}

/* ═══════════════ INPUTS ═══════════════ */
.input-wrap {
  margin-bottom: 18px;
}

.input-wrap.sm { margin-bottom: 12px; }

.input-wrap label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-field {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.12);
}

.input-field [data-lucide] {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.input-field input {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 0;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}

.input-field input::placeholder { color: var(--text-muted); }

.select, .search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.select:focus, .search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.12);
}

.select.compact { width: auto; min-width: 160px; }

.search-field {
  width: 220px;
  padding: 0 12px;
}

.search-field input {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
}

/* Modal form (legacy class names) */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.12);
}

.form-group input.readonly { opacity: 0.5; cursor: not-allowed; }

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

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }

.quiz-option-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-option-row input[type="radio"] {
  accent-color: var(--indigo-500);
  width: 18px;
  height: 18px;
}

.quiz-option-row input[type="text"] { flex: 1; }

/* ═══════════════ MODAL ═══════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.open { display: flex; }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-sm { max-width: 420px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-head.danger-head {
  flex-wrap: wrap;
  gap: 12px;
}

.danger-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #FEE2E2;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

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

/* ═══════════════ EMPTY & LOADING ═══════════════ */
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--border);
  border-top-color: var(--indigo-500);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  margin: 48px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.empty-state.compact { padding: 28px 20px; }

.empty-icon,
.empty-lucide {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-muted);
  opacity: 0.45;
}

.empty-state .empty-lucide {
  display: block;
}

.empty-state p { font-size: 0.9rem; }

/* ═══════════════ TOAST ═══════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 2000;
  padding: 14px 20px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  max-width: 360px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

/* ═══════════════ MOBILE ═══════════════ */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .studio-layout { grid-template-columns: 1fr; }
  .editor-grid { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-toggle { display: flex; }
  .sidebar-collapse-btn { display: none; }
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .app-shell.sidebar-collapsed .main { margin-left: 0; }
  .topbar { padding: 0 20px 0 64px; }
  .page-content { padding: 20px 16px 40px; }
  .form-row, .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
