:root {
  --bg-deep: #06080d;
  --bg-sidebar: #0b0f17;
  --bg-surface: #111722;
  --bg-elevated: #172030;
  --bg-glass: rgba(14, 19, 29, 0.88);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-highlight: rgba(0, 229, 163, 0.35);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-emerald: #00e5a3;
  --accent-emerald-glow: rgba(0, 229, 163, 0.16);
  --accent-cyan: #38bdf8;
  --accent-purple: #a855f7;
  --accent-amber: #f59e0b;
  --accent-danger: #ef4444;
  --sidebar-width: 292px;
  --topbar-height: 46px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   APP SHELL & CURTAIN SIDEBAR
   ========================================================================== */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

.curtain-hover-edge {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: 7px;
  height: calc(100vh - var(--topbar-height));
  z-index: 90;
  display: none;
}

body.curtain-closed .curtain-hover-edge {
  display: block;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.26s cubic-bezier(0.16, 1, 0.3, 1), transform 0.26s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.26s ease;
  z-index: 100;
  user-select: none;
}

/* Curtain Collapsed State */
body.curtain-closed .sidebar {
  margin-left: calc(var(--sidebar-width) * -1);
}

/* Auto-Peek Floating Curtain State when hovered */
body.curtain-closed.curtain-peek .sidebar {
  margin-left: calc(var(--sidebar-width) * -1);
  transform: translateX(var(--sidebar-width));
  box-shadow: 16px 0 48px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 229, 163, 0.2);
}

/* Sidebar Brand Header */
.sidebar-header {
  height: var(--topbar-height);
  padding: 0 12px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.01);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(0, 229, 163, 0.2), rgba(56, 189, 248, 0.15));
  border: 1px solid rgba(0, 229, 163, 0.35);
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(0, 229, 163, 0.15);
}

.brand-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffffff;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Search & Quick Filter Pills */
.sidebar-search-wrap {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 8px 0 10px;
  height: 34px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-box:focus-within {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 2px rgba(0, 229, 163, 0.15);
}

.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 12.5px;
  padding: 0 8px;
}

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

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  flex-shrink: 0;
}

.quick-pills {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.quick-pill {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-align: center;
}

.quick-pill:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
}

.quick-pill.active {
  background: var(--accent-emerald-glow);
  border-color: rgba(0, 229, 163, 0.4);
  color: var(--accent-emerald);
  font-weight: 600;
}

/* Categories Tree Navigation */
.categories-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 14px;
}

.category-group {
  margin-bottom: 8px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s ease;
}

.category-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.cat-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.cat-chevron {
  transition: transform 0.18s ease;
  color: var(--text-muted);
  flex-shrink: 0;
}

.category-group.collapsed .cat-chevron {
  transform: rotate(-90deg);
}

.cat-color-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 99px;
}

.cat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.category-header:hover .cat-header-actions {
  opacity: 1;
}

.cat-mini-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.cat-mini-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Category Items List */
.category-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 6px;
  margin-top: 2px;
}

.category-group.collapsed .category-items {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all 0.14s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(0, 229, 163, 0.14), rgba(0, 229, 163, 0.03));
  border-color: rgba(0, 229, 163, 0.28);
  color: #ffffff;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.nav-item-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

/* Active in memory badge dot on icon */
.nav-item.in-memory .nav-item-icon::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
  border: 1.5px solid var(--bg-sidebar);
}

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

.nav-item-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.nav-item-title {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item.active .nav-item-title {
  font-weight: 600;
  color: #ffffff;
}

.nav-item-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.health-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}

.health-dot.online {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.health-dot.offline {
  background: #ef4444;
}

.item-hover-actions {
  display: none;
  align-items: center;
  gap: 2px;
}

.nav-item:hover .item-hover-actions {
  display: flex;
}

.nav-item:hover .health-dot {
  display: none;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.footer-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.footer-action-btn.primary {
  flex: 1.4;
  background: var(--accent-emerald);
  color: #04130e;
}

.footer-action-btn.primary:hover {
  background: #14f5b4;
  box-shadow: 0 0 16px rgba(0, 229, 163, 0.35);
}

.footer-action-btn.secondary {
  flex: 1;
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.footer-action-btn.secondary:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-elevated);
}

/* ==========================================================================
   MAIN WORKSPACE & TOPBAR
   ========================================================================== */
.workspace-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  background: var(--bg-deep);
}

.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  gap: 8px;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.curtain-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(0, 229, 163, 0.1);
  border: 1px solid rgba(0, 229, 163, 0.3);
  color: var(--accent-emerald);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.curtain-btn:hover {
  background: rgba(0, 229, 163, 0.2);
  box-shadow: 0 0 12px rgba(0, 229, 163, 0.25);
}

/* Open Tabs Strip (Keep-Alive Tabs) */
.open-tabs-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  min-width: 0;
  flex: 1;
  padding: 2px 0;
}

.open-Tabs-strip::-webkit-scrollbar {
  height: 0;
}

.workspace-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 31px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
  flex-shrink: 0;
  max-width: 200px;
}

.workspace-tab:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
}

.workspace-tab.active {
  background: var(--bg-elevated);
  border-color: rgba(0, 229, 163, 0.45);
  color: #ffffff;
  box-shadow: inset 0 -2px 0 var(--accent-emerald);
}

.workspace-tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-tab-close {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 2px;
}

.workspace-tab-close:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

/* Topbar Right Controls */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.active-frame-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.url-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: pointer;
  max-width: 240px;
}

.url-indicator:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.url-domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.latency-tag {
  font-size: 10px;
  color: var(--accent-emerald);
  background: rgba(0, 229, 163, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
}

.embed-mode-select {
  height: 30px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 11.5px;
  font-family: var(--font-sans);
  outline: none;
  cursor: pointer;
}

.embed-mode-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s ease;
}

.toolbar-btn:hover, .toolbar-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

.toolbar-btn.active {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.toolbar-btn.accent-subtle {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--accent-cyan);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 2px;
}

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

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* ==========================================================================
   VIEWPORT CONTAINER (CRM OVERVIEW + KEEP-ALIVE IFRAMES + SPLIT VIEW)
   ========================================================================== */
.viewport-container {
  flex: 1;
  display: flex;
  width: 100%;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
  position: relative;
}

.viewport-pane {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.secondary-pane {
  border-left: 2px solid rgba(0, 229, 163, 0.3);
  background: var(--bg-deep);
}

/* 1. Executive CRM Overview Dashboard */
.crm-overview {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 24px 28px 60px;
  background:
    radial-gradient(circle at 15% 0%, rgba(0, 229, 163, 0.07), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(56, 189, 248, 0.06), transparent 40%),
    var(--bg-deep);
}

.overview-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 26px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(17, 23, 34, 0.92), rgba(11, 15, 23, 0.95));
  border: 1px solid var(--border-subtle);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.hero-left {
  max-width: 620px;
}

.eyebrow-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-emerald);
  background: rgba(0, 229, 163, 0.1);
  border: 1px solid rgba(0, 229, 163, 0.25);
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 10px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.overview-hero h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 6px;
}

.overview-hero p {
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.5;
}

.hero-stats {
  display: flex;
  gap: 12px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  min-width: 105px;
  text-align: center;
}

.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: #ffffff;
}

.stat-value.emerald {
  color: var(--accent-emerald);
}

.stat-value.cyan {
  color: var(--accent-cyan);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Overview Action Bar */
.overview-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.overview-filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-chip.active {
  background: var(--accent-emerald);
  color: #04130e;
  border-color: var(--accent-emerald);
}

.overview-cta-group {
  display: flex;
  gap: 8px;
}

/* Overview Category Sections & Cards */
.overview-cat-section {
  margin-bottom: 28px;
}

.overview-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.overview-cat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 14px;
}

.crm-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  position: relative;
  overflow: hidden;
}

.crm-card:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 229, 163, 0.4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.crm-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.crm-card-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.crm-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.crm-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2px;
}

.crm-card-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.crm-card-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  white-space: nowrap;
}

.crm-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.crm-card-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 175px;
}

.crm-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 2. Keep-Alive Iframes Stage */
.iframes-stage {
  width: 100%;
  height: 100%;
  position: relative;
  background: #0a0e16;
}

.frame-wrapper {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  position: relative;
}

.frame-wrapper.active {
  display: flex;
}

.app-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
  flex: 1;
}

/* Smart Docked / External OAuth Assist Bar inside Frame Wrapper */
.frame-assist-banner {
  background: linear-gradient(90deg, #0f172a, #131c2e);
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.frame-assist-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Docked Mode Placeholder Canvas when Window is Docked Over Right Pane */
.docked-canvas-card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(0, 229, 163, 0.08), var(--bg-deep));
  padding: 24px;
}

.docked-card-inner {
  max-width: 520px;
  background: var(--bg-surface);
  border: 1px solid rgba(0, 229, 163, 0.35);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.docked-card-inner h3 {
  font-size: 18px;
  color: #ffffff;
  margin: 12px 0 8px;
}

.docked-card-inner p {
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 18px;
}

.docked-btn-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Split Screen Secondary Pane */
.split-pane-header {
  height: 36px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
}

.split-pane-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.split-select {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 12px;
}

.split-right-stage {
  flex: 1;
  width: 100%;
  height: calc(100% - 36px);
}

/* ==========================================================================
   NOTES DRAWER (SLIDE-OVER RIGHT)
   ========================================================================== */
.notes-drawer {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  width: 340px;
  height: calc(100vh - var(--topbar-height));
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.6);
  z-index: 85;
  display: flex;
  flex-direction: column;
}

.drawer-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h3 {
  font-size: 14px;
  color: #ffffff;
}

.drawer-header p {
  font-size: 11px;
  color: var(--text-muted);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.scratchpad-textarea {
  width: 100%;
  min-height: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.scratchpad-textarea:focus {
  border-color: var(--accent-emerald);
}

.scratchpad-status {
  font-size: 11px;
  color: var(--accent-emerald);
  text-align: right;
}

.prompts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.snippets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.snippet-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.snippet-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 12px;
  color: #ffffff;
}

.snippet-card p {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   MODALS, COMMAND PALETTE & LOCK SCREEN
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 9, 0.78);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.modal-card.sm {
  max-width: 440px;
}

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.form-row.three-col {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.6fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  height: 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent-emerald);
}

.color-picker-input {
  padding: 2px 4px !important;
  width: 100%;
  cursor: pointer;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.modal-footer-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Buttons */
.btn-primary {
  background: var(--accent-emerald);
  color: #04130e;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: #14f5b4;
  box-shadow: 0 0 14px rgba(0, 229, 163, 0.35);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}

.btn-primary.sm, .btn-secondary.sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-secondary.xs {
  padding: 3px 8px;
  font-size: 11px;
}

.full-width {
  width: 100%;
}

/* Command Palette (Ctrl + K) */
.cmd-palette-card {
  width: 100%;
  max-width: 580px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(0, 229, 163, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.cmd-search-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.cmd-search-top input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 15px;
}

.cmd-palette-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}

.cmd-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.cmd-result-item:hover, .cmd-result-item.selected {
  background: rgba(0, 229, 163, 0.12);
}

/* Lock Screen */
.lock-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #0f172a, #05070b);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-sidebar);
  border: 1px solid rgba(0, 229, 163, 0.3);
  border-radius: 16px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
}

.lock-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-emerald);
  margin-bottom: 14px;
}

.brand-orb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 12px var(--accent-emerald);
}

.lock-card h2 {
  font-size: 20px;
  color: #ffffff;
  margin-bottom: 6px;
}

.lock-card p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
}

#pinInput {
  width: 100%;
  height: 46px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  text-align: center;
  font-size: 22px;
  letter-spacing: 0.35em;
  color: #ffffff;
  margin-bottom: 14px;
  outline: none;
}

#pinInput:focus {
  border-color: var(--accent-emerald);
}

.lock-error {
  color: #f87171;
  font-size: 12px;
  margin-bottom: 10px;
}

.lock-meta {
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Settings Modal Helpers */
.settings-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.muted-sm {
  font-size: 11.5px;
  color: var(--text-muted);
}

.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
}

.pin-change-row {
  display: flex;
  gap: 8px;
}

.pin-change-row input {
  flex: 1;
}

.settings-actions-bottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid rgba(0, 229, 163, 0.4);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
  .hide-sm {
    display: none;
  }
  .hero-stats {
    width: 100%;
    justify-content: space-between;
  }
  .form-row.two-col, .form-row.three-col {
    grid-template-columns: 1fr;
  }
}
