/* ==========================================================================
   EasyBot Dashboard — Modern Calm UI layer
   Loaded LAST. Re-skins the dashboard (not the landing page) with calmer
   tokens, a consistent component set and a tidier layout. Organization helpers
   (.mui-*) are injected by modern-ui.js.
   ========================================================================== */

/* tokens apply to the dashboard only — the public landing page keeps its look */
body:not(.landing-mode) {
  /* Surfaces — soft graphite instead of pitch black, lower contrast = less eye strain */
  --bg-dark: #0C0E13;
  --bg-sidebar: #10131A;
  --bg-card: #141821;
  --bg-card-hover: #1A1F2A;
  --bg-card-active: #1F2531;
  --bg-input: #0F1218;
  --bg-input-hover: #12161E;
  --bg-modal: #151922;

  --border: #232835;
  --border-subtle: #1B1F29;
  --border-strong: #2F3544;
  --border-focus: #7C83F5;

  /* One calm accent */
  --primary: #6F78F2;
  --primary-hover: #5F68E6;
  --mui-btn: #5A62E0;        /* white text 4.9:1 (WCAG AA) */
  --mui-btn-hover: #4F58D2;
  --primary-subtle: rgba(111, 120, 242, 0.12);
  --primary-border: rgba(111, 120, 242, 0.30);

  --success: #34C38F;
  --success-subtle: rgba(52, 195, 143, 0.12);
  --danger: #EF5B5B;
  --danger-subtle: rgba(239, 91, 91, 0.12);
  --warning: #F2B544;
  --warning-subtle: rgba(242, 181, 68, 0.12);
  --info: #4FB3E8;

  --text-primary: #E7E9EE;
  --text-secondary: #A2A8B6;
  --text-muted: #878D9D;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 48px -12px rgba(0, 0, 0, 0.6);

  --mui-sidebar-w: 264px;
  --mui-topbar-h: 60px;
  --mui-content-max: 1280px;
  --mui-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --mui-fast: 120ms;
}

html[lang="ar"] body:not(.landing-mode) {
  --font-sans: 'Cairo', 'Inter', -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --font-family: var(--font-sans);
  font-family: var(--font-sans);
}

body.dashboard-mode,
body:not(.landing-mode) {
  background: var(--bg-dark);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body:not(.landing-mode) ::selection { background: rgba(111, 120, 242, 0.35); }

/* Thin, quiet scrollbars */
body:not(.landing-mode) * { scrollbar-width: thin; scrollbar-color: #2A2F3C transparent; }
body:not(.landing-mode) ::-webkit-scrollbar { width: 10px; height: 10px; }
body:not(.landing-mode) ::-webkit-scrollbar-thumb { background: #2A2F3C; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
body:not(.landing-mode) ::-webkit-scrollbar-thumb:hover { background-color: #3A4050; }
body:not(.landing-mode) ::-webkit-scrollbar-track { background: transparent; }

/* Keyboard focus is always visible, mouse focus stays clean */
body:not(.landing-mode) :focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ==========================================================================
   1. APP SHELL — sidebar flush to the edge (removes the empty 68px rail gap)
   ========================================================================== */
@media (min-width: 901px) {
  html[dir="ltr"] .sidebar { left: 0; right: auto; }
  html[dir="rtl"] .sidebar { right: 0; left: auto; }

  html[dir="ltr"] body:not(.landing-mode) .main-content { margin-left: var(--mui-sidebar-w); margin-right: 0; }
  html[dir="rtl"] body:not(.landing-mode) .main-content { margin-right: var(--mui-sidebar-w); margin-left: 0; }
}

body:not(.landing-mode) .main-content {
  padding: 0 32px 64px;
  transition: none;
}

/* Every module page shares one readable width */
body:not(.landing-mode) .main-content > .tab-panel,
body:not(.landing-mode) .main-content > .dash-top-bar > .mui-topbar-inner {
  max-width: var(--mui-content-max);
  margin-inline: auto;
}

/* ==========================================================================
   2. SIDEBAR
   ========================================================================== */
.sidebar {
  width: var(--mui-sidebar-w);
  background: var(--bg-sidebar);
  border-inline-end: 1px solid var(--border-subtle);
  padding: 14px 12px 12px;
  gap: 10px;
}

.sidebar-brand-header {
  padding: 2px 6px 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: none;
}
.sidebar-brand-title { font-size: 14px; letter-spacing: 0; color: var(--text-primary); }
.sidebar-brand-subtitle { font-size: 11px; }

.server-workspace-switcher {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: none !important;
  transition: border-color var(--mui-fast) var(--mui-ease), background var(--mui-fast) var(--mui-ease);
}
.server-workspace-switcher:hover { border-color: var(--border-strong) !important; background: var(--bg-card-hover) !important; }
.workspace-dropdown {
  background: var(--bg-modal) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
}

.sidebar-search-box {
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border-color: var(--border);
}
#dashboard-sidebar .sidebar-search-box input {
  height: 100%;
  padding: 0;
  font-size: 12.5px;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.sidebar-search-box:focus-within { box-shadow: 0 0 0 3px rgba(111, 120, 242, 0.18); }

.nav-menu { gap: 4px; }

.nav-group + .nav-group { margin-top: 2px; }

.nav-group-header {
  padding: 10px 10px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: transparent !important;
}
html[lang="ar"] .nav-group-header { letter-spacing: 0; font-size: 11.5px; }
.nav-group-header:hover { color: var(--text-secondary); }
.nav-group-chevron { font-size: 9px; opacity: 0.7; }

.nav-group-items { gap: 1px; }

.sidebar .nav-item,
.nav-item {
  position: relative;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border-inline-start: 0 !important;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--mui-fast) var(--mui-ease), color var(--mui-fast) var(--mui-ease);
}
.nav-item .nav-icon { color: var(--text-muted); opacity: 0.9; transition: color var(--mui-fast) var(--mui-ease); }
.nav-item .nav-icon svg { width: 16px; height: 16px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-primary); }
.nav-item:hover .nav-icon { color: var(--text-secondary); }

.sidebar .nav-item.active,
.nav-item.active {
  background: var(--primary-subtle) !important;
  color: var(--text-primary) !important;
  font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--primary); }
.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
html[dir="rtl"] .nav-item.active::before { border-radius: 3px 0 0 3px; }

.sidebar-footer { border-top-color: var(--border-subtle); padding-top: 10px; }

/* ==========================================================================
   3. TOP BAR — one sticky, compact header (breadcrumb · language · actions)
   ========================================================================== */
body:not(.landing-mode) .dashboard-language-bar.mui-merged { display: none !important; }

body:not(.landing-mode) .dash-top-bar {
  position: sticky;
  top: 0;
  z-index: 85;
  margin: 0 -32px 24px;
  padding: 0 32px;
  min-height: var(--mui-topbar-h);
  background: rgba(12, 14, 19, 0.92);
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  box-shadow: none;
}
@supports (backdrop-filter: blur(1px)) {
  body:not(.landing-mode) .dash-top-bar {
    background: rgba(12, 14, 19, 0.78);
    backdrop-filter: saturate(140%) blur(10px);
  }
}

.dash-top-bar .mui-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: var(--mui-topbar-h);
}

.dash-top-left { gap: 10px; min-width: 0; flex-wrap: nowrap; }
.dash-top-left .server-selector-pill { display: none; } /* duplicated by the sidebar workspace switcher */

.breadcrumb-bar { flex: 1 1 auto; gap: 6px; font-size: 13px; min-width: 0; overflow: hidden; white-space: nowrap; }
.breadcrumb-item { flex: 0 1 auto; min-width: 0; color: var(--text-muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb-item.active { flex-shrink: 0; max-width: 45%; }
.breadcrumb-separator { flex-shrink: 0; }
/* "Dashboard" root crumb is implied — drop it to give the useful parts room */
.breadcrumb-bar > .breadcrumb-item:first-child,
.breadcrumb-bar > .breadcrumb-item:first-child + .breadcrumb-separator { display: none; }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 600; }
.breadcrumb-separator { opacity: 0.5; }

.dash-top-actions { gap: 6px !important; flex-wrap: nowrap !important; }

/* Quiet ghost buttons in the bar (overrides their inline colours) */
.dash-top-actions > a.btn,
.dash-top-actions > button.btn {
  height: 34px;
  padding: 0 12px;
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--text-secondary) !important;
  font-weight: 600 !important;
  border-radius: var(--radius-sm);
}
.dash-top-actions > a.btn:hover,
.dash-top-actions > button.btn:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
}
.dash-top-actions > a[href="/design-system.html"] { display: none !important; } /* dev-only reference */
#topbar-admin-link { color: var(--warning) !important; }
.dash-top-actions > .btn-danger:hover { color: var(--danger) !important; background: var(--danger-subtle) !important; }

/* user chip */
.dash-top-actions > div[style*="bg-input"] {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  border-radius: 999px !important;
  padding: 3px 10px 3px 4px !important;
}
html[dir="rtl"] .dash-top-actions > div[style*="bg-input"] { padding: 3px 4px 3px 10px !important; }
#user-info-badge { color: var(--text-primary) !important; font-weight: 600 !important; }

/* language picker inside the bar */
.dash-top-actions .dashboard-language-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
}
.dash-top-actions .dashboard-language-control > span { display: none; }

/* Sidebar toggle becomes a small icon button at the start of the bar */
@media (min-width: 901px) {
  #dashboard-nav-toggle.mui-in-topbar {
    position: static !important;
    inset: auto !important;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: none;
    color: var(--text-secondary);
  }
  #dashboard-nav-toggle.mui-in-topbar > span { display: none; }
  #dashboard-nav-toggle.mui-in-topbar:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); border-color: var(--border-strong); }
}

/* ==========================================================================
   4. MODULE HEADER — calm title block + sticky segmented sub-tabs
   ========================================================================== */
body:not(.landing-mode) .section-hero-header,
body:not(.landing-mode) .tab-header {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 4px 0 18px;
  margin-bottom: 0;
  overflow: visible;
}
body:not(.landing-mode) .section-hero-header::before,
body:not(.landing-mode) .tab-header::before { display: none; }

body:not(.landing-mode) .section-hero-left { align-items: flex-start; min-width: 0; }

body:not(.landing-mode) .section-hero-icon,
body:not(.landing-mode) .tab-header-icon {
  width: 44px;
  height: 44px;
  font-size: 22px;
  border-radius: 12px;
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
}

body:not(.landing-mode) .section-hero-title,
body:not(.landing-mode) .tab-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
body:not(.landing-mode) .section-hero-desc,
body:not(.landing-mode) .tab-subtitle {
  max-width: 72ch;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.status-badge,
.badge-status {
  font-size: 11px !important;
  font-weight: 600 !important;
  padding: 2px 9px !important;
  border-radius: 999px !important;
}

/* Sub-tabs: segmented control, stays reachable while scrolling */
body:not(.landing-mode) .system-subnav {
  position: sticky;
  top: var(--mui-topbar-h);
  z-index: 60;
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  margin: 0 0 22px;
  padding: 4px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  scrollbar-width: none;
  box-shadow: 0 6px 16px -10px rgba(0, 0, 0, 0.6);
}
body:not(.landing-mode) .system-subnav::-webkit-scrollbar { display: none; }
/* desktop: wrap instead of hiding tabs off-screen; mobile keeps a swipeable row */
@media (min-width: 901px) {
  body:not(.landing-mode) .system-subnav { flex-wrap: wrap; overflow: visible; }
}

body:not(.landing-mode) .subnav-btn {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border: 0 !important;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--mui-fast) var(--mui-ease), color var(--mui-fast) var(--mui-ease);
}
body:not(.landing-mode) .subnav-btn:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-primary); }
body:not(.landing-mode) .subnav-btn.active {
  background: var(--bg-card-active) !important;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--border-strong), 0 1px 2px rgba(0, 0, 0, 0.3);
}
body:not(.landing-mode) .subnav-icon { font-size: 14px; opacity: 0.85; }

/* Gentle page transitions — short, so the UI feels instant */
.tab-panel.active,
.subtab-pane.active { animation: muiFade 160ms var(--mui-ease); }
@keyframes muiFade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   5. "ON THIS PAGE" — quick jump between the sections of a long pane
   ========================================================================== */
.mui-pane-toc {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: -6px 0 18px;
}
.mui-pane-toc-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-inline-end: 4px;
}
.mui-pane-toc button {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all var(--mui-fast) var(--mui-ease);
}
.mui-pane-toc button:hover { border-color: var(--primary-border); color: var(--text-primary); background: var(--primary-subtle); }

/* jump targets land below the sticky top bar + sub-tabs */
body:not(.landing-mode) .main-content .card-title,
body:not(.landing-mode) .main-content .card h3,
body:not(.landing-mode) .main-content .card h4 { scroll-margin-top: calc(var(--mui-topbar-h) + 72px); }

.mui-flash { animation: muiFlash 1.2s var(--mui-ease); border-radius: 8px; }
@keyframes muiFlash {
  0% { box-shadow: 0 0 0 0 rgba(111, 120, 242, 0.55); }
  100% { box-shadow: 0 0 0 10px rgba(111, 120, 242, 0); }
}

/* ==========================================================================
   6. CARDS
   ========================================================================== */
body:not(.landing-mode) .main-content .card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 24px 22px;
  margin-bottom: 18px;
  box-shadow: none;
  scroll-margin-top: calc(var(--mui-topbar-h) + 64px);
}
/* card without a title row keeps normal top padding */
body:not(.landing-mode) .main-content .card:not(:has(> .card-title:first-child, > .card-header:first-child)) { padding-top: 22px; }

/* Title row = card header with a hairline divider */
body:not(.landing-mode) .main-content .card > .card-title:first-child,
body:not(.landing-mode) .main-content .card > .card-header:first-child {
  margin: 0 -24px 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
}
body:not(.landing-mode) .card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  line-height: 1.4;
}
body:not(.landing-mode) .main-content .card > .card-header:first-child .card-title { margin: 0; padding: 0; border: 0; }
body:not(.landing-mode) .card-desc,
body:not(.landing-mode) .card-description { color: var(--text-secondary); font-size: 13px; line-height: 1.6; }

/* nested cards read as inset panels, not cards-in-cards */
body:not(.landing-mode) .main-content .card .card {
  background: var(--bg-input);
  border-color: var(--border-subtle);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   7. FORMS
   ========================================================================== */
/* .form-grid had no layout before — fields simply stacked. Two tidy columns now. */
body:not(.landing-mode) .form-grid,
body:not(.landing-mode) .form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  align-items: start;
}
body:not(.landing-mode) .form-grid > .full-width,
body:not(.landing-mode) .form-grid-2 > .full-width,
body:not(.landing-mode) .form-grid > .form-group:has(textarea),
body:not(.landing-mode) .form-grid > :not(.form-group):not(.switch-group):not(.toggle-group) {
  grid-column: 1 / -1;
}
body:not(.landing-mode) .form-group { margin-bottom: 14px; }
body:not(.landing-mode) .form-grid > .form-group,
body:not(.landing-mode) .form-grid-2 > .form-group { margin-bottom: 0; }

body:not(.landing-mode) .form-group > label,
body:not(.landing-mode) .form-group label:not(.switch):not(.toggle-switch) {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  line-height: 1.5;
}

body:not(.landing-mode) .form-control,
body:not(.landing-mode) .form-select,
body:not(.landing-mode) input[type="text"],
body:not(.landing-mode) input[type="number"],
body:not(.landing-mode) input[type="password"],
body:not(.landing-mode) input[type="email"],
body:not(.landing-mode) input[type="url"],
body:not(.landing-mode) input[type="search"],
body:not(.landing-mode) select:not([size]),
body:not(.landing-mode) select[size="1"],
body:not(.landing-mode) textarea {
  height: 40px;
  border-radius: 10px;
  background-color: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  font-size: 13.5px;
  transition: border-color var(--mui-fast) var(--mui-ease), box-shadow var(--mui-fast) var(--mui-ease);
}
body:not(.landing-mode) textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.6; }
body:not(.landing-mode) select[size]:not([size="1"]),
body:not(.landing-mode) select[multiple] { height: auto; min-height: 96px; }
body:not(.landing-mode) input::placeholder,
body:not(.landing-mode) textarea::placeholder { color: var(--text-muted); opacity: 1; }

body:not(.landing-mode) .form-control:hover,
body:not(.landing-mode) input[type="text"]:hover,
body:not(.landing-mode) input[type="number"]:hover,
body:not(.landing-mode) select:hover,
body:not(.landing-mode) textarea:hover { border-color: var(--border-strong) !important; }

body:not(.landing-mode) .form-control:focus,
body:not(.landing-mode) input[type="text"]:focus,
body:not(.landing-mode) input[type="number"]:focus,
body:not(.landing-mode) input[type="password"]:focus,
body:not(.landing-mode) input[type="email"]:focus,
body:not(.landing-mode) input[type="url"]:focus,
body:not(.landing-mode) input[type="search"]:focus,
body:not(.landing-mode) select:focus,
body:not(.landing-mode) textarea:focus {
  border-color: var(--border-focus) !important;
  background-color: var(--bg-input-hover) !important;
  box-shadow: 0 0 0 3px rgba(111, 120, 242, 0.18) !important;
  outline: none;
}
body:not(.landing-mode) select option { background: var(--bg-modal); color: var(--text-primary); }

body:not(.landing-mode) input[type="color"] {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
}
body:not(.landing-mode) input[type="range"] { accent-color: var(--primary); }
body:not(.landing-mode) input[type="checkbox"]:not(.switch input):not(.toggle-switch input),
body:not(.landing-mode) input[type="radio"] { accent-color: var(--primary); }

/* Toggle rows: a clean, clickable settings row */
body:not(.landing-mode) .switch-group,
body:not(.landing-mode) .toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
  transition: border-color var(--mui-fast) var(--mui-ease);
}
body:not(.landing-mode) .switch-group:hover,
body:not(.landing-mode) .toggle-group:hover { border-color: var(--border-strong); }

/* Switch */
body:not(.landing-mode) .switch { width: 40px; height: 22px; }
body:not(.landing-mode) .slider {
  background-color: #2A2F3B;
  border: 0;
  transition: background-color 160ms var(--mui-ease);
}
body:not(.landing-mode) .slider:before {
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #C9CDD6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: transform 160ms var(--mui-ease), background-color 160ms var(--mui-ease);
}
body:not(.landing-mode) input:checked + .slider { background-color: var(--primary); }
body:not(.landing-mode) input:checked + .slider:before { transform: translateX(18px); background: #fff; }
body:not(.landing-mode) input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(111, 120, 242, 0.35); }

/* Inline info boxes inside forms → one calm callout style */
body:not(.landing-mode) .form-group.full-width[style*="background"] {
  background: var(--primary-subtle) !important;
  border: 1px solid var(--primary-border) !important;
  border-radius: var(--radius-md) !important;
}

/* Action rows (save / test buttons) sit in a tidy footer */
body:not(.landing-mode) .form-group.full-width:has(> .btn:only-child),
body:not(.landing-mode) .form-group.full-width:has(> .btn + .btn) {
  display: flex !important;
  flex-wrap: wrap;
  gap: 10px !important;
  justify-content: flex-end;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   8. BUTTONS — one primary colour across every module
   ========================================================================== */
body:not(.landing-mode) .btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  transition: background var(--mui-fast) var(--mui-ease), border-color var(--mui-fast) var(--mui-ease), color var(--mui-fast) var(--mui-ease), transform 80ms ease;
}
body:not(.landing-mode) .btn:active { transform: translateY(1px); }
body:not(.landing-mode) .btn[style*="padding: 12px"],
body:not(.landing-mode) .btn[style*="padding: 14px"] { height: auto; min-height: 42px; }
body:not(.landing-mode) .btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
body:not(.landing-mode) .btn-lg { height: 44px; padding: 0 22px; font-size: 14px; }

body:not(.landing-mode) .main-content .btn-primary {
  background: var(--mui-btn) !important;
  border-color: var(--mui-btn) !important;
  color: #fff !important;
  box-shadow: none !important;
  font-weight: 600 !important;
}
body:not(.landing-mode) .main-content .btn-primary:hover {
  background: var(--mui-btn-hover) !important;
  border-color: var(--mui-btn-hover) !important;
}

body:not(.landing-mode) .main-content .btn-secondary {
  background: transparent !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--text-primary) !important;
  box-shadow: none !important;
}
body:not(.landing-mode) .main-content .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: #3B4252 !important;
}

body:not(.landing-mode) .main-content .btn-danger {
  background: var(--danger-subtle) !important;
  border: 1px solid rgba(239, 91, 91, 0.3) !important;
  color: var(--danger) !important;
}
body:not(.landing-mode) .main-content .btn-danger:hover { background: var(--danger) !important; color: #fff !important; }

body:not(.landing-mode) .main-content .btn-success {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: #08130E !important;
}

/* ==========================================================================
   9. TABLES, STATS, BADGES, MODALS
   ========================================================================== */
body:not(.landing-mode) .data-table { border-collapse: separate; border-spacing: 0; font-size: 13px; }
body:not(.landing-mode) .data-table th {
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
body:not(.landing-mode) .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); }
body:not(.landing-mode) .data-table tr:last-child td { border-bottom: 0; }
body:not(.landing-mode) .data-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

body:not(.landing-mode) .stat-card,
body:not(.landing-mode) .quick-action-card,
body:not(.landing-mode) .module-card,
body:not(.landing-mode) .guild-card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: none !important;
  transition: border-color var(--mui-fast) var(--mui-ease), background var(--mui-fast) var(--mui-ease);
}
body:not(.landing-mode) .module-card:hover,
body:not(.landing-mode) .quick-action-card:hover,
body:not(.landing-mode) .guild-card:hover {
  border-color: var(--border-strong) !important;
  background: var(--bg-card-hover) !important;
  transform: none !important;
}
body:not(.landing-mode) .stat-value { font-weight: 700; letter-spacing: -0.02em; }
body:not(.landing-mode) .stat-label { color: var(--text-muted); font-size: 12px; }

body:not(.landing-mode) .hero-welcome-banner {
  background: linear-gradient(135deg, rgba(111, 120, 242, 0.10), rgba(111, 120, 242, 0.02) 60%), var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: none !important;
}

body:not(.landing-mode) .onboarding-card,
body:not(.landing-mode) .plan-limits-card,
body:not(.landing-mode) .overview-pinned-container {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: none !important;
}

.modal-overlay {
  background: rgba(6, 8, 12, 0.72) !important;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: var(--bg-modal) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
}

/* Discord live previews keep Discord's own palette — only soften the frame */
body:not(.landing-mode) .discord-preview-card,
body:not(.landing-mode) .discord-embed-box { border-radius: 10px; }

/* ==========================================================================
   10. RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
  body:not(.landing-mode) .main-content { padding: 0 20px 48px; }
  body:not(.landing-mode) .dash-top-bar { margin: 0 -20px 20px; padding: 0 20px; }
  .dash-top-actions #topbar-context-doc-link,
  .dash-top-actions > button[onclick="showLandingView()"] { display: none !important; }
}

@media (max-width: 900px) {
  body:not(.landing-mode) { --mui-topbar-h: 56px; }
  body:not(.landing-mode) .main-content { padding: 0 14px 40px !important; }
  /* the mobile app header already gives us a bar */
  body:not(.landing-mode) .dash-top-bar { display: none !important; }
  body:not(.landing-mode) .dashboard-language-bar.mui-merged { display: flex !important; }
  body:not(.landing-mode) .system-subnav { top: 56px; margin-inline: -14px; border-radius: 0; border-inline: 0; }
  body:not(.landing-mode) .main-content .card { padding: 0 16px 16px !important; border-radius: var(--radius-md); }
  body:not(.landing-mode) .main-content .card > .card-title:first-child,
  body:not(.landing-mode) .main-content .card > .card-header:first-child { margin: 0 -16px 16px; padding: 14px 16px; }
  body:not(.landing-mode) .section-hero-title { font-size: 1.2rem; }
  body:not(.landing-mode) .form-grid,
  body:not(.landing-mode) .form-grid-2 { grid-template-columns: 1fr !important; }
  body:not(.landing-mode) .form-group.full-width:has(> .btn + .btn) > .btn { flex: 1 1 100%; }
  .mui-pane-toc { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
}

/* Phones: inline multi-column grids (editor + live preview etc.) stack into one column */
@media (max-width: 700px) {
  body:not(.landing-mode) .main-content [style*="grid-template-columns"]:not(.mui-keep-grid) {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  body:not(.landing-mode) .main-content [style*="grid-template-columns"] > * { min-width: 0; }
  body:not(.landing-mode) .main-content [style*="position: sticky"] { position: static !important; }
}

@media (prefers-reduced-motion: reduce) {
  body:not(.landing-mode) *,
  body:not(.landing-mode) *::before,
  body:not(.landing-mode) *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   11. SEARCHABLE DROPDOWNS (searchable-select.js)
   ========================================================================== */
.mui-select-pop {
  position: fixed;
  z-index: 20000; /* above modals (10000) */
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--bg-modal, #151922);
  border: 1px solid var(--border-strong, #2F3544);
  border-radius: 12px;
  box-shadow: 0 18px 48px -12px rgba(0, 0, 0, 0.7);
  color: var(--text-primary, #E7E9EE);
  font-family: inherit;
  animation: muiPop 120ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mui-select-pop[hidden] { display: none; }
@keyframes muiPop { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.mui-select-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  margin-bottom: 6px;
  background: var(--bg-input, #0F1218);
  border: 1px solid var(--border, #232835);
  border-radius: 8px;
  color: var(--text-muted, #878D9D);
}
.mui-select-search-row:focus-within { border-color: var(--border-focus, #7C83F5); box-shadow: 0 0 0 3px rgba(111, 120, 242, 0.18); }
#mui-select-pop input.mui-select-search,
#mui-select-pop input.mui-select-search:hover,
#mui-select-pop input.mui-select-search:focus {
  flex: 1;
  min-width: 0;
  height: 100% !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  outline: none;
  color: var(--text-primary, #E7E9EE) !important;
  font: inherit;
  font-size: 13.5px;
}
.mui-select-pop input.mui-select-search::-webkit-search-cancel-button { cursor: pointer; }

.mui-select-list { overflow-y: auto; overscroll-behavior: contain; }
.mui-select-group {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted, #878D9D);
}
.mui-select-item {
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary, #A2A8B6);
}
.mui-select-item.is-empty { color: var(--text-muted, #878D9D); }
.mui-select-item.is-active { background: rgba(255, 255, 255, 0.06); color: var(--text-primary, #E7E9EE); }
.mui-select-item[aria-selected="true"] {
  background: var(--primary-subtle, rgba(111, 120, 242, 0.12));
  color: var(--text-primary, #E7E9EE);
  font-weight: 600;
}
.mui-select-item[aria-selected="true"].is-active { background: rgba(111, 120, 242, 0.2); }
.mui-select-item[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.mui-select-item[hidden], .mui-select-group[hidden] { display: none; }

.mui-select-meta {
  padding: 6px 10px 2px;
  margin-top: 4px;
  border-top: 1px solid var(--border-subtle, #1B1F29);
  font-size: 11.5px;
  color: var(--text-muted, #878D9D);
}
.mui-select-meta.is-empty { padding: 14px 10px; border-top: 0; text-align: center; font-size: 13px; }

/* filter box above multi-selects */
.mui-multi-filter { margin-bottom: 6px; }
body:not(.landing-mode) .mui-multi-filter input { height: 34px; font-size: 12.5px; }
