/* immoAI.guru — Dashboard Web 4.0 shell (Faza 1) */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --accent: #5271d8;
  --accent-hover: #425fbf;
  --accent-dark: #334a9e;
  --accent-pale: #96aee8;
  --accent-light: #d4e0f7;
  --accent-soft: rgba(82, 113, 216, 0.08);
  --accent-glow: rgba(82, 113, 216, 0.18);
  --accent-rgb: 82, 113, 216;

  --bg: #f5f7fc;
  --bg-soft: linear-gradient(165deg, #f8fafd 0%, #eef2fa 45%, #f5f7fc 100%);
  --surface: #ffffff;
  --surface-elevated: #f8fafc;
  --surface-glass: rgba(255, 255, 255, 0.88);
  --inbox-bg: #f1f5f9;
  --text: #111827;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #b4c8eb;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --sidebar-w: 260px;
  --topbar-h: 72px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
}

body.app-v4 {
  font-family: var(--font) !important;
  background: var(--bg) !important;
  background: var(--bg-soft) !important;
  min-height: 100vh;
  padding: 0 !important;
  color: var(--text);
  overflow-x: hidden;
}

body.app-v4 .app-shell {
  display: flex;
  min-height: 100vh;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ── Sidebar ── */
body.app-v4 .app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform 0.25s ease;
}

body.app-v4 .sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

body.app-v4 .sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

body.app-v4 .sidebar-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-pale) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  box-shadow: 0 4px 14px var(--accent-glow);
}

body.app-v4 .sidebar-brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

body.app-v4 .sidebar-brand-text span {
  color: var(--accent);
}

body.app-v4 .sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

body.app-v4 .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  text-align: left;
}

body.app-v4 .nav-item iconify-icon {
  font-size: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

body.app-v4 .nav-item:hover:not(.active) {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

body.app-v4 .nav-item.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 14px var(--accent-glow);
}

body.app-v4 .nav-item.active iconify-icon {
  opacity: 1;
}

/* ─── Nav group expandabil (sub-items în sidebar) ─────────────────────────
   Pattern: header click → toggle vizibilitate sub-items + caret rotește.
   Sub-items au indentare + dimensiune mai mică, sub-item activ moștenește
   stilul .nav-item.active (gradient + sombră). */
body.app-v4 .nav-group {
  display: flex;
  flex-direction: column;
}
body.app-v4 .nav-item--group {
  position: relative;
  padding-right: 32px; /* loc pentru caret */
}
body.app-v4 .nav-caret {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.6;
  transition: transform 0.2s, opacity 0.2s;
  pointer-events: none;
}
body.app-v4 .nav-group.is-expanded > .nav-item--group .nav-caret {
  transform: translateY(-50%) rotate(180deg);
  opacity: 1;
}
body.app-v4 .nav-subitems {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 6px 8px;
  padding-left: 18px;
  border-left: 2px solid var(--border, rgba(148, 163, 184, 0.25));
}
body.app-v4 .nav-group.is-expanded > .nav-subitems {
  display: flex;
}
body.app-v4 .nav-item--sub {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
}
body.app-v4 .nav-item--sub iconify-icon {
  font-size: 17px;
}

body.app-v4 .sidebar-footer {
  padding: 16px 14px 20px;
  border-top: 1px solid var(--border);
}

body.app-v4 .sidebar-cta {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(82, 113, 216, 0.1) 0%, rgba(150, 174, 232, 0.15) 100%);
  border: 1px solid var(--border-strong);
  text-decoration: none;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.15s;
}

body.app-v4 .sidebar-cta:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

body.app-v4 .sidebar-cta-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 1px;
  opacity: 0.9;
}

body.app-v4 .sidebar-cta-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

body.app-v4 .sidebar-cta-title {
  display: block;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--accent-dark);
}

body.app-v4 .sidebar-cta-hint,
body.app-v4 .sidebar-cta small {
  display: block;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 3px;
  font-size: 10.5px;
  line-height: 1.35;
}

/* ── Main area ── */
body.app-v4 .app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.app-v4 .app-topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 150;
}

body.app-v4 .topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

body.app-v4 .topbar-mobile-logo {
  display: none;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  min-width: 0;
  flex-shrink: 1;
}

body.app-v4 .topbar-mobile-logo img {
  height: 32px;
  width: auto;
  max-width: 110px;
  flex-shrink: 0;
  display: block;
}

body.app-v4 .topbar-mobile-logo-text {
  display: flex;
  align-items: baseline;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  white-space: nowrap;
}

body.app-v4 .topbar-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

body.app-v4 .sidebar-toggle {
  display: none !important;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

body.app-v4 .topbar-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

body.app-v4 .topbar-page-header__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
}

body.app-v4 .topbar-page-header__icon iconify-icon {
  font-size: 22px;
}

body.app-v4 .topbar-page-header__text {
  min-width: 0;
}

body.app-v4 .topbar-page-header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

body.app-v4 .topbar-page-header__subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.app-v4 .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

body.app-v4 .topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-width: 220px;
  color: var(--text-dim);
  font-size: 13px;
}

body.app-v4 .topbar-search iconify-icon {
  font-size: 18px;
}

body.app-v4 .topbar-bell {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color 0.15s, background 0.15s;
}

body.app-v4 .topbar-bell:hover {
  border-color: var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent);
}

body.app-v4 .topbar-bell iconify-icon {
  font-size: 22px;
}

body.app-v4 #notificationBadge {
  top: 2px !important;
  right: 0 !important;
}

body.app-v4 .app-content {
  flex: 1;
  padding: 24px 28px 40px;
}

body.app-v4 .app-page {
  max-width: 1400px;
}

/* ── Page cards (tab panels) ── */
body.app-v4 .tab-content > .page-card,
body.app-v4 .tab-content > .info-box:first-child,
body.app-v4 #knowledgeTab > div:not(.hidden),
body.app-v4 #agentsTab,
body.app-v4 #channelsTab,
body.app-v4 #announcementsTab,
body.app-v4 #crmTab,
body.app-v4 #campaignsTab,
body.app-v4 #settingsTab {
  /* inherit from existing .card where wrapped */
}

body.app-v4 .page-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

body.app-v4 .card {
  background: var(--surface) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  border: 1px solid rgba(226, 232, 240, 0.8) !important;
}

body.app-v4 .header {
  display: none !important;
}

body.app-v4 .tabs {
  display: none !important;
}

/* ── Overview ── */
body.app-v4 .overview-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

body.app-v4 .kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}

body.app-v4 .kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

body.app-v4 .kpi-card--primary {
  background: linear-gradient(135deg, var(--accent) 0%, #6b8ae8 55%, var(--accent-pale) 100%);
  border: none;
  color: white;
}

body.app-v4 .kpi-card--primary .kpi-label,
body.app-v4 .kpi-card--primary .kpi-meta {
  color: rgba(255, 255, 255, 0.85);
}

body.app-v4 .kpi-card--primary .kpi-value {
  color: white;
}

body.app-v4 .kpi-card--primary .kpi-card-icon {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

body.app-v4 .kpi-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

body.app-v4 .kpi-card-body {
  flex: 1;
  min-width: 0;
}

body.app-v4 .kpi-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

body.app-v4 .kpi-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

body.app-v4 .kpi-meta {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

body.app-v4 .kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 8px;
}

body.app-v4 .kpi-trend--up {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

body.app-v4 .overview-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

body.app-v4 .overview-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

body.app-v4 .overview-panel--wide {
  grid-column: 1 / -1;
}

body.app-v4 .overview-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

body.app-v4 .overview-panel-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

body.app-v4 .activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 140px;
  padding-top: 8px;
}

body.app-v4 .activity-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

body.app-v4 .activity-bar {
  width: 100%;
  max-width: 36px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--accent-pale) 0%, var(--accent) 100%);
  min-height: 8px;
  transition: height 0.4s ease;
}

body.app-v4 .activity-bar.is-today {
  background: linear-gradient(180deg, #7c9ef0 0%, var(--accent-dark) 100%);
  box-shadow: 0 4px 12px var(--accent-glow);
}

body.app-v4 .activity-bar-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}

body.app-v4 .quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

body.app-v4 .quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-align: left;
}

body.app-v4 .quick-action-btn:hover {
  border-color: var(--border-strong);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

body.app-v4 .quick-action-btn iconify-icon {
  font-size: 22px;
  color: var(--accent);
}

body.app-v4 .recent-conv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.app-v4 .recent-conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

body.app-v4 .recent-conv-item:hover {
  background: var(--accent-soft);
  border-color: var(--border-strong);
}

body.app-v4 .recent-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

body.app-v4 .recent-conv-body {
  flex: 1;
  min-width: 0;
}

body.app-v4 .recent-conv-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.app-v4 .recent-conv-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.app-v4 .recent-conv-meta {
  text-align: right;
  flex-shrink: 0;
}

body.app-v4 .recent-conv-time {
  font-size: 11px;
  color: var(--text-dim);
}

body.app-v4 .status-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
}

body.app-v4 .status-pill--active {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

body.app-v4 .status-pill--pending {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

body.app-v4 .overview-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Override legacy purple accents ── */
body.app-v4 .tab.active,
body.app-v4 .conv-seg-btn.active,
body.app-v4 .conv-filter-trigger.has-value,
body.app-v4 .conv-start-btn-compact {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%) !important;
  box-shadow: 0 2px 8px var(--accent-glow) !important;
}

body.app-v4 input:focus,
body.app-v4 textarea:focus,
body.app-v4 select:focus,
body.app-v4 .custom-select-trigger.open {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-soft) !important;
}

body.app-v4 .stat-number {
  color: var(--accent) !important;
}

body.app-v4 .stat-card {
  border-left-color: var(--accent) !important;
  border-radius: var(--radius-sm) !important;
}

body.app-v4 #emailVerificationAlert {
  margin-bottom: 16px;
  border-radius: var(--radius-sm) !important;
}

body.app-v4 .profile-picture,
body.app-v4 .profile-picture-placeholder {
  border-color: var(--border-strong) !important;
  width: 42px !important;
  height: 42px !important;
}

body.app-v4 .user-dropdown-menu {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
}

body.app-v4 #notificationDropdown {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  body.app-v4 .overview-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  body.app-v4 .app-sidebar {
    transform: translateX(-100%);
  }

  body.app-v4 .app-sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  body.app-v4 .app-main {
    margin-left: 0;
  }

  body.app-v4 .sidebar-toggle {
    display: flex !important;
  }

  body.app-v4 .topbar-search {
    display: none;
  }

  body.app-v4 .topbar-page-header {
    display: none;
  }

  body.app-v4 .topbar-mobile-logo {
    display: flex;
  }

  body.app-v4 .app-topbar {
    padding: 0 10px;
    gap: 6px;
  }

  body.app-v4 .topbar-right {
    gap: 5px;
  }

  body.app-v4 .topbar-actions {
    gap: 5px;
  }

  /* All 3 round buttons (intro `?`, theme toggle, bell) at the SAME size on
     mobile + slightly smaller avatar so the whole row fits comfortably with
     the logo. Without uniform sizes, the topbar reads visually jagged.
     !important needed because dashboard-polish.css loads after shell.css and
     sets width/height: 42px on .topbar-theme-toggle (no media query) — that
     rule would otherwise win the cascade. */
  body.app-v4 .topbar-theme-toggle,
  body.app-v4 .topbar-bell {
    width: 34px !important;
    height: 34px !important;
  }

  body.app-v4 .topbar-theme-toggle iconify-icon,
  body.app-v4 .topbar-bell iconify-icon {
    font-size: 18px !important;
  }

  body.app-v4 .profile-picture,
  body.app-v4 .profile-picture-placeholder {
    width: 36px !important;
    height: 36px !important;
  }

  /* Notification dropdown — inline style fixes width to 380px which spills
     past a 360px viewport. Pin to viewport edges with small gutter, fixed
     position so it doesn't inherit the bell's absolute origin. */
  body.app-v4 #notificationDropdown {
    position: fixed !important;
    top: calc(var(--topbar-h, 56px) + 4px) !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: none !important;
  }

  /* Persistent toast container (#persistentToastContainer) — created by JS
     with inline `right: 20px; max-width: 400px;`. On narrow viewports we
     widen it to use the full row minus 8px gutters so the message + close
     button don't get squeezed. */
  body.app-v4 #persistentToastContainer {
    left: 8px !important;
    right: 8px !important;
    bottom: 12px !important;
    max-width: none !important;
  }

  /* Widget customizer (Canale → Widget): inline `grid-template-columns:
     1fr 1fr` forces the controls + live preview side-by-side, which on
     mobile gives a 50% column with a 320px-wide chat panel inside —
     guaranteed horizontal overflow. Collapse to a single column, drop
     sticky positioning, and shrink the preview stage so the bubble +
     chat fit within the column. !important required to beat inline styles. */
  body.app-v4 .widget-customizer-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  body.app-v4 .widget-preview-wrapper {
    position: static !important;
  }
  body.app-v4 .widget-preview-stage {
    min-height: 360px !important;
    padding: 12px !important;
  }
  body.app-v4 #widgetPreviewChat {
    width: calc(100% - 24px) !important;
    max-width: 300px !important;
    height: 340px !important;
  }

  /* Asistenți (Agents) editor: three inline grids that don't collapse on
     mobile and produce overflow + letter-per-line text wrapping. Stack
     them all into one column.
       1. .agent-form-row-2 — "Limba implicită" + "Canal asociat" row.
       2. .agent-lang-row   — language select + "Alte limbi" button (was
                              60/40 split; button text gets clipped).
       3. #agentPersonalityGrid — 4 sliders + System Prompt textarea
                              (was minmax(280px,360px) + 1fr; on a 360px
                              viewport the System Prompt column collapses
                              to ~50px and wraps one letter per line). */
  body.app-v4 .agent-form-row-2,
  body.app-v4 .agent-lang-row,
  body.app-v4 #agentPersonalityGrid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  body.app-v4 .overview-grid {
    grid-template-columns: 1fr;
  }

  body.app-v4 .overview-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* KPI compact: [icon + valoare centrate] apoi titlu + subtitlu centrate */
  body.app-v4 .kpi-card {
    display: grid;
    grid-template-columns: 1fr auto auto 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 4px 8px;
    padding: 12px 10px !important;
  }

  body.app-v4 .kpi-card-icon {
    grid-column: 2;
    grid-row: 1;
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    font-size: 18px !important;
  }

  body.app-v4 .kpi-card-body {
    display: contents;
  }

  body.app-v4 .kpi-value {
    grid-column: 3;
    grid-row: 1;
    align-self: center;
    margin: 0 !important;
    font-size: 22px !important;
    text-align: left;
  }

  body.app-v4 .kpi-label {
    grid-column: 1 / -1;
    grid-row: 2;
    text-align: center;
    margin: 4px 0 0 !important;
    font-size: 10px !important;
  }

  body.app-v4 .kpi-meta {
    grid-column: 1 / -1;
    grid-row: 3;
    text-align: center;
    margin: 0 !important;
    font-size: 10px !important;
    line-height: 1.3;
  }

  body.app-v4 .kpi-sparkline {
    display: none !important;
  }

  body.app-v4 .app-content {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  body.app-v4 .overview-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  body.app-v4 .kpi-card {
    padding: 10px 8px !important;
    gap: 3px 8px;
  }

  body.app-v4 .kpi-card-icon {
    width: 32px !important;
    height: 32px !important;
    font-size: 16px !important;
  }

  body.app-v4 .kpi-value {
    font-size: 20px !important;
  }

  body.app-v4 .kpi-label,
  body.app-v4 .kpi-meta {
    font-size: 9px !important;
  }

  body.app-v4 .quick-actions {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  body.app-v4 .quick-action-btn {
    align-items: center;
    text-align: center;
    padding: 12px 10px;
    font-size: 12px;
  }

  body.app-v4 .topbar-mobile-logo-text {
    font-size: 15px;
  }
}
