:root {
  --bg: #06080f;
  --sidebar-bg: #090c17;
  --card-bg: rgba(15, 20, 36, 0.75);
  --card-elevated: #101528;
  --popover-bg: #0c101d;
  --border: rgba(139, 92, 246, 0.22);
  --border-light: rgba(230, 235, 244, 0.08);
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-bright: #a855f7;
  --accent-cyan: #38bdf8;
  --green: #4ade80;
  --amber: #f59e0b;
  --red: #f43f5e;
  --text: #E6EBF4;
  --text-muted: #9aa3b5;
  --text-dim: #626b7a;
  --font-heading: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* Ambient Radial Glow */
.app-bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 60% 40% at 85% 10%, rgba(139, 92, 246, 0.12), transparent 60%),
              radial-gradient(circle at 15% 90%, rgba(56, 189, 248, 0.08), transparent 50%);
}

/* Sidebar */
aside#sidebar {
  width: 270px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 12px;
  flex-shrink: 0;
  z-index: 20;
  transition: width 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Perfect Collapsed Sidebar State (Vipeo9 Fix) */
aside#sidebar.collapsed {
  width: 72px;
  padding: 16px 8px;
}
aside#sidebar.collapsed .org-mount-btn {
  padding: 6px;
  justify-content: center;
}
aside#sidebar.collapsed .org-info div,
aside#sidebar.collapsed .org-mount-btn > span {
  display: none !important;
}
aside#sidebar.collapsed .nav-group-title {
  display: none !important;
}
aside#sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
  gap: 0;
}
aside#sidebar.collapsed .nav-item span {
  display: none !important;
}
aside#sidebar.collapsed .user-pill {
  padding: 6px;
  justify-content: center;
}
aside#sidebar.collapsed .user-pill div:not(.user-avatar),
aside#sidebar.collapsed .user-pill a {
  display: none !important;
}

/* Org Switcher Mount */
.org-container {
  position: relative;
  width: 100%;
  margin-bottom: 18px;
}

.org-mount-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
  color: var(--text);
  font-family: var(--font-body);
}
.org-mount-btn:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: var(--primary);
}
.org-info { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.org-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.2);
  border: 1px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.org-name { font-weight: 700; font-size: 14px; color: white; white-space: nowrap; font-family: var(--font-heading); letter-spacing: -0.02em; }
.org-plan { font-size: 11.5px; color: #38bdf8; font-weight: 500; }

/* Org Dropdown Popover */
.org-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 260px;
  background: var(--popover-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(139, 92, 246, 0.15);
  z-index: 100;
  backdrop-filter: blur(20px);
}
.org-dropdown.open { display: block; animation: dropIn 0.15s ease-out; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.user-identity-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 8px;
}
.user-identity-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #8B5CF6 0%, #38bdf8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: white;
  font-family: var(--font-heading);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 0;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  background: transparent;
  border: none;
  text-align: left;
  transition: all 0.15s;
  font-family: var(--font-body);
}
.dropdown-item:hover {
  background: rgba(139, 92, 246, 0.15);
  color: white;
}
.dropdown-item.active {
  color: #38bdf8;
  font-weight: 600;
}

/* Workspace sublist */
.workspace-list {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 4px;
  margin: 4px 0 8px;
}
.ws-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-muted);
}
.ws-item:hover, .ws-item.active { background: rgba(255, 255, 255, 0.05); color: white; }

/* Navigation List */
.nav-scroll-area { flex: 1; overflow-y: auto; overflow-x: hidden; padding-right: 2px; }
.nav-scroll-area::-webkit-scrollbar { width: 4px; }
.nav-scroll-area::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }

.nav-group { margin-bottom: 20px; }
.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0 10px 8px;
  font-family: var(--font-heading);
  white-space: nowrap;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.15s ease;
  margin-bottom: 3px;
  text-decoration: none;
  font-family: var(--font-body);
  white-space: nowrap;
}
.nav-item:hover { background: rgba(230, 235, 244, 0.06); color: white; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.2) 0%, rgba(139, 92, 246, 0.05) 100%);
  border-left: 3px solid var(--primary);
  color: white;
  font-weight: 600;
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .nav-icon { opacity: 1; color: var(--primary); }

/* Sidebar Footer */
.user-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8B5CF6 0%, #38bdf8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  color: white;
  font-family: var(--font-heading);
  flex-shrink: 0;
}

/* Main Area */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

header.dashboard-header {
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 12, 23, 0.7);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.toggle-sidebar-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s;
}
.toggle-sidebar-btn:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.breadcrumb { font-size: 14px; font-weight: 600; color: var(--text); font-family: var(--font-body); }
.breadcrumb span { color: var(--text-dim); margin: 0 6px; }

.header-right { display: flex; align-items: center; gap: 12px; }
.status-pill {
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: #4ade80;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}
.credits-pill {
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
}
.credits-pill b { color: #38bdf8; font-family: var(--font-mono); }

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 30px 40px;
}
.content-body::-webkit-scrollbar { width: 6px; }
.content-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }

.view-panel { display: none; }
.view-panel.active { display: block; animation: fadeIn 0.2s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Buttons */
.btn-vega {
  background: linear-gradient(135deg, #8B5CF6 0%, #6d28d9 100%);
  color: white;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 10px 22px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s;
  text-decoration: none;
}
.btn-vega:hover { transform: translateY(-1px); box-shadow: 0 6px 25px rgba(139, 92, 246, 0.6); }

.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  font-family: var(--font-body);
  text-decoration: none;
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--primary); color: white; }

.grid-2col { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
@media (max-width: 1024px) { .grid-2col { grid-template-columns: 1fr; } }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  backdrop-filter: blur(14px);
}
.card-title { font-size: 18px; font-weight: 700; font-family: var(--font-heading); margin-bottom: 4px; letter-spacing: -0.02em; }
.card-desc { font-size: 13.5px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.5; }

.ssml-editor {
  width: 100%;
  height: 190px;
  background: #090c17;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: white;
  padding: 16px;
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  outline: none;
  font-family: var(--font-body);
  margin-bottom: 16px;
}
.ssml-editor:focus { border-color: var(--primary); box-shadow: 0 0 12px rgba(139, 92, 246, 0.25); }

.chip-wrap { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { background: rgba(139, 92, 246, 0.2); border-color: var(--primary); color: white; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-select, .form-input {
  width: 100%;
  background: #090c17;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: white;
  font-size: 13.5px;
  outline: none;
  font-family: var(--font-body);
}
.form-select:focus, .form-input:focus { border-color: var(--primary); }

.wave-strip {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 30px;
}
.w-bar {
  width: 3px;
  height: 6px;
  background: var(--text-dim);
  border-radius: 2px;
  transition: height 0.15s;
}
.playing .w-bar {
  background: #38bdf8;
  animation: wave 0.4s infinite alternate ease-in-out;
}
.playing .w-bar:nth-child(2) { animation-delay: 0.1s; }
.playing .w-bar:nth-child(3) { animation-delay: 0.2s; }
.playing .w-bar:nth-child(4) { animation-delay: 0.3s; }
.playing .w-bar:nth-child(5) { animation-delay: 0.15s; }
@keyframes wave { 0% { height: 6px; } 100% { height: 28px; } }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13.5px; font-family: var(--font-body); }
th {
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-family: var(--font-heading);
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

.progress-bar-wrap {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 99px;
  overflow: hidden;
  margin: 12px 0 8px;
  display: flex;
}
.pb-fill-primary { background: var(--primary); height: 100%; transition: width 0.3s; }
.pb-fill-reserved { background: #f59e0b; height: 100%; transition: width 0.3s; }

/* Pricing Plans in Billing */
.billing-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.billing-plan-card {
  background: #090c17;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: all 0.2s;
}
.billing-plan-card.current {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.1) 0%, #090c17 100%);
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.25);
}

/* Role Pills */
.role-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  display: inline-block;
  font-family: var(--font-heading);
}
.role-owner { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; border: 1px solid var(--primary); }
.role-admin { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.4); }
.role-engineer { background: rgba(74, 222, 128, 0.15); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.4); }
.role-viewer { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); border: 1px solid var(--border-light); }

/* Switch Toggle */
.switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}
.switch-label:hover { background: rgba(255, 255, 255, 0.04); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.15s ease-out; }
.modal-card {
  background: #0b0f1d;
  border: 1px solid var(--border);
  border-radius: 20px;
  max-width: 520px;
  width: 100%;
  padding: 28px;
  position: relative;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8);
  max-height: 90vh;
  overflow-y: auto;
}

/* Modern In-UI Toast System (Vipeo9 Inspired) */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100vw - 32px);
}
.toast-card {
  pointer-events: auto;
  background: rgba(13, 17, 30, 0.95);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  color: white;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(139, 92, 246, 0.2);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: slideInToast 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition: all 0.25s ease;
}
.toast-card.success { border-color: rgba(74, 222, 128, 0.4); }
.toast-card.error { border-color: rgba(244, 63, 94, 0.4); }
.toast-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 5px;
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--primary);
}
.toast-card.success .toast-dot { background: #4ade80; box-shadow: 0 0 10px #4ade80; }
.toast-card.error .toast-dot { background: #f43f5e; box-shadow: 0 0 10px #f43f5e; }
.toast-title { font-weight: 700; font-size: 13.5px; color: white; font-family: var(--font-heading); }
.toast-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.45; }

@keyframes slideInToast {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
